TNO Intern

Commit 469a7220 authored by Hen Brett's avatar Hen Brett 🐔
Browse files

Fixing the tests

parent 835a1d82
Loading
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -68,7 +68,7 @@ nav:
      - utc_properties: reference/utc_properties.md
      - deterministic doublet simulation: reference/doublet_simulation_deterministic.md
      - stochastic doublet simulation: reference/doublet_simulation_stochastic.md
      - assess optimal chunk size: reference/doublet_simulation_stochastic.md
      - assess optimal chunk size: reference/assess_optimal_chunk_size.md



+5 −5
Original line number Diff line number Diff line
from os import path
from pathlib import Path
import timeit
from pathlib import Path

import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt

from pythermogis.doublet_simulation.deterministic_doublet import calculate_doublet_performance


def assess_optimal_chunk_size(n_simulations: int = 1000, chunk_step_size: int = 100, plot_outfile : str | Path = None):
    """
    This runs the same set of doublet simulations using different chunk sizes and prints the results to the terminal to show find which chunk size is optimal.
    It runs each chunk size 3 times and takes the average of their times to find the time taken for that chunk size.

    The chunks which are tested go from 1 -> n_simulations with steps of chunk_step_size.

    Parameters
    ----------
@@ -35,7 +35,7 @@ def assess_optimal_chunk_size(n_simulations: int = 1000, chunk_step_size: int =
        coords={"sample": np.arange(n_simulations)}
    )

    n_attempts = 2 # do the same operation n_attempts and take an average of their times.
    n_attempts = 3 # do the same operation n_attempts and take an average of their times.
    sample_chunks = np.arange(1, n_simulations + 2, chunk_step_size)

    # run in series
−276 B (21.3 KiB)
Loading image diff...
+1 −1
Original line number Diff line number Diff line
@@ -10,7 +10,7 @@ def test_dask_parralelization():
    output_data_path = Path(path.dirname(__file__), "resources") / "test_output" / "parallelization"
    output_data_path.mkdir(parents=True, exist_ok=True)

    assess_optimal_chunk_size(n_simulations = 1000, chunk_step_size=100, plot_outfile = output_data_path / "parallelization.png")
    assess_optimal_chunk_size(n_simulations = 100, chunk_step_size=50, plot_outfile = output_data_path / "parallelization.png")

    assert output_data_path.exists()