Skip to content

Commit

Permalink
add test for group loading in sim_data
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerflex committed Oct 11, 2022
1 parent 0d621d9 commit 333405a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/test_components/test_IO.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@
from ..utils import SIM_MONITORS as SIM2
from ..utils import clear_tmp
from ..test_data.test_monitor_data import make_flux_data
from ..test_data.test_sim_data import make_sim_data
from tidy3d.components.data.data_array import FluxDataArray
from tidy3d.components.data.monitor_data import FieldData

# Store an example of every minor release simulation to test updater in the future
SIM_DIR = "tests/sims"
Expand Down Expand Up @@ -200,6 +202,20 @@ def test_to_hdf5_group_path():
assert np.all(flux_data_array == data.flux)


@clear_tmp
def _test_to_hdf5_group_path_sim_data():
"""Tests that the json string with data in separate file behaves correctly in SimulationData."""

# type saved in the combined json file?
data = make_sim_data()
FNAME = "tests/tmp/sim_data.hdf5"
data.to_file(fname=FNAME)
field_data_index = 0
group_path = f"/data/data_{field_data_index}"
field_data = FieldData.from_file(fname=FNAME, group_path=group_path)
assert field_data == data.data[field_data_index]


@clear_tmp
def test_none_hdf5():
"""Tests that values of None where None is not the default are loaded correctly."""
Expand Down

0 comments on commit 333405a

Please sign in to comment.