Skip to content

Commit 80cff46

Browse files
committed
Revert "Disable tests related to new exporT"
This reverts commit e547568.
1 parent ff3688d commit 80cff46

File tree

2 files changed

+73
-80
lines changed

2 files changed

+73
-80
lines changed

tests/dataset/measurement/test_inferred_parameters_fix.py

Lines changed: 47 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -308,54 +308,53 @@ def test_inferred_parameters_in_actual_measurement_2d(
308308
)
309309

310310
# xarray export
311-
# disabled until we renable new export
312-
# caplog.clear()
313-
# with caplog.at_level("INFO"):
314-
# xarr = dataset.to_xarray_dataset()
315-
316-
# assert len(caplog.records) == 1
317-
# if set_shape:
318-
# assert (
319-
# caplog.records[0].message
320-
# == "Exporting meas_parameter to xarray using direct method"
321-
# )
322-
# else:
323-
# assert (
324-
# caplog.records[0].message
325-
# == "Exporting meas_parameter to xarray via pandas index"
326-
# )
327-
328-
# assert "meas_parameter" in xarr.data_vars
329-
330-
# assert "del_param_1" in xarr.coords
331-
# assert xarr.coords["del_param_1"].shape == (num_points_x,)
332-
# assert xarr.coords["del_param_1"].dims == ("del_param_1",)
333-
334-
# assert "del_param_2" in xarr.coords
335-
# assert xarr.coords["del_param_2"].shape == (num_points_y,)
336-
# assert xarr.coords["del_param_2"].dims == ("del_param_2",)
337-
338-
# if set_shape:
339-
# assert "dummy_dac_ch1" in xarr.coords
340-
# assert xarr.coords["dummy_dac_ch1"].shape == (num_points_x,)
341-
# assert xarr.coords["dummy_dac_ch1"].dims == ("del_param_1",)
342-
343-
# assert "dummy_dac_ch2" in xarr.coords
344-
# assert xarr.coords["dummy_dac_ch2"].shape == (num_points_y,)
345-
# assert xarr.coords["dummy_dac_ch2"].dims == ("del_param_2",)
346-
# else:
347-
# assert "dummy_dac_ch1" not in xarr.coords
348-
# assert "dummy_dac_ch2" not in xarr.coords
349-
# assert xarr["meas_parameter"].dims == ("del_param_1", "del_param_2")
350-
# assert xarr["meas_parameter"].shape == (num_points_x, num_points_y)
351-
352-
# # pandas export
353-
# df = dataset.to_pandas_dataframe()
354-
# assert "meas_parameter" in df.columns
355-
# assert df.index.names == ["del_param_1", "del_param_2"]
356-
# assert "dummy_dac_ch1" not in df.columns
357-
# assert "dummy_dac_ch2" not in df.columns
358-
# assert len(df) == total_points
311+
caplog.clear()
312+
with caplog.at_level("INFO"):
313+
xarr = dataset.to_xarray_dataset()
314+
315+
assert len(caplog.records) == 1
316+
if set_shape:
317+
assert (
318+
caplog.records[0].message
319+
== "Exporting meas_parameter to xarray using direct method"
320+
)
321+
else:
322+
assert (
323+
caplog.records[0].message
324+
== "Exporting meas_parameter to xarray via pandas index"
325+
)
326+
327+
assert "meas_parameter" in xarr.data_vars
328+
329+
assert "del_param_1" in xarr.coords
330+
assert xarr.coords["del_param_1"].shape == (num_points_x,)
331+
assert xarr.coords["del_param_1"].dims == ("del_param_1",)
332+
333+
assert "del_param_2" in xarr.coords
334+
assert xarr.coords["del_param_2"].shape == (num_points_y,)
335+
assert xarr.coords["del_param_2"].dims == ("del_param_2",)
336+
337+
if set_shape:
338+
assert "dummy_dac_ch1" in xarr.coords
339+
assert xarr.coords["dummy_dac_ch1"].shape == (num_points_x,)
340+
assert xarr.coords["dummy_dac_ch1"].dims == ("del_param_1",)
341+
342+
assert "dummy_dac_ch2" in xarr.coords
343+
assert xarr.coords["dummy_dac_ch2"].shape == (num_points_y,)
344+
assert xarr.coords["dummy_dac_ch2"].dims == ("del_param_2",)
345+
else:
346+
assert "dummy_dac_ch1" not in xarr.coords
347+
assert "dummy_dac_ch2" not in xarr.coords
348+
assert xarr["meas_parameter"].dims == ("del_param_1", "del_param_2")
349+
assert xarr["meas_parameter"].shape == (num_points_x, num_points_y)
350+
351+
# pandas export
352+
df = dataset.to_pandas_dataframe()
353+
assert "meas_parameter" in df.columns
354+
assert df.index.names == ["del_param_1", "del_param_2"]
355+
assert "dummy_dac_ch1" not in df.columns
356+
assert "dummy_dac_ch2" not in df.columns
357+
assert len(df) == total_points
359358

360359

361360
def test_multiple_dependent_parameters_no_cross_contamination(

tests/dataset/test_dataset_export.py

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,6 @@ def test_netcdf_export_with_mixed_timestamp_raw(
19231923
assert loaded_ds.completed_timestamp_raw is None
19241924

19251925

1926-
@pytest.mark.skip(reason="Disabled until we renable new export")
19271926
@given(data=hst.data())
19281927
@settings(
19291928
max_examples=10,
@@ -2114,11 +2113,10 @@ def test_measurement_2d_with_inferred_setpoint(
21142113
with caplog.at_level(logging.INFO):
21152114
xr_ds = ds.to_xarray_dataset()
21162115

2117-
# disabled until we renable new export
2118-
# assert any(
2119-
# "Exporting signal to xarray using direct method" in record.message
2120-
# for record in caplog.records
2121-
# )
2116+
assert any(
2117+
"Exporting signal to xarray using direct method" in record.message
2118+
for record in caplog.records
2119+
)
21222120

21232121
# Sizes and coords
21242122
assert xr_ds.sizes == {"x": nx, "y": ny}
@@ -2130,16 +2128,15 @@ def test_measurement_2d_with_inferred_setpoint(
21302128
expected_signal = x_vals[:, None] + 3.0 * y_vals[None, :]
21312129
np.testing.assert_allclose(xr_ds["signal"].values, expected_signal)
21322130

2133-
# disabled until we renable new export
2134-
# # Inferred coords for y_b0 and y_b1 exist with dims only along y
2135-
# for name, vals in ("y_b0", y_b0_vals), ("y_b1", y_b1_vals):
2136-
# assert name in xr_ds.coords
2137-
# assert xr_ds.coords[name].dims == ("y",)
2138-
# np.testing.assert_allclose(xr_ds.coords[name].values, vals)
2139-
# # Indexes of inferred coords should correspond to the y axis index
2140-
# inf_idx = xr_ds.coords[name].indexes
2141-
# assert set(inf_idx.keys()) == {"y"}
2142-
# assert inf_idx["y"].equals(xr_ds.indexes["y"])
2131+
# Inferred coords for y_b0 and y_b1 exist with dims only along y
2132+
for name, vals in ("y_b0", y_b0_vals), ("y_b1", y_b1_vals):
2133+
assert name in xr_ds.coords
2134+
assert xr_ds.coords[name].dims == ("y",)
2135+
np.testing.assert_allclose(xr_ds.coords[name].values, vals)
2136+
# Indexes of inferred coords should correspond to the y axis index
2137+
inf_idx = xr_ds.coords[name].indexes
2138+
assert set(inf_idx.keys()) == {"y"}
2139+
assert inf_idx["y"].equals(xr_ds.indexes["y"])
21432140

21442141

21452142
def test_measurement_2d_with_inferred_setpoint_from_setpoint(
@@ -2181,11 +2178,10 @@ def test_measurement_2d_with_inferred_setpoint_from_setpoint(
21812178
with caplog.at_level(logging.INFO):
21822179
xr_ds = ds.to_xarray_dataset()
21832180

2184-
# disabled until we renable new export
2185-
# assert any(
2186-
# "Exporting signal to xarray using direct method" in record.message
2187-
# for record in caplog.records
2188-
# )
2181+
assert any(
2182+
"Exporting signal to xarray using direct method" in record.message
2183+
for record in caplog.records
2184+
)
21892185

21902186
# Sizes and coords
21912187
assert xr_ds.sizes == {"x": nx, "y": ny}
@@ -2240,24 +2236,22 @@ def test_measurement_2d_top_level_inferred_is_data_var(
22402236
xr_ds = ds.to_xarray_dataset()
22412237

22422238
# Direct path log should be present
2243-
# disabled until we renable new export
2244-
# assert any(
2245-
# "Exporting signal to xarray using direct method" in record.message
2246-
# for record in caplog.records
2247-
# )
2239+
assert any(
2240+
"Exporting signal to xarray using direct method" in record.message
2241+
for record in caplog.records
2242+
)
22482243

22492244
# The derived param should be a data variable with dims (x, y), not a coord
2250-
# assert "derived" in xr_ds.data_vars
2251-
# assert "derived" not in xr_ds.coords
2252-
# assert xr_ds["derived"].dims == ("x", "y")
2245+
assert "derived" in xr_ds.data_vars
2246+
assert "derived" not in xr_ds.coords
2247+
assert xr_ds["derived"].dims == ("x", "y")
22532248

22542249
expected_signal = x_vals[:, None] + y_vals[None, :]
2255-
# expected_derived = 2.0 * expected_signal
2250+
expected_derived = 2.0 * expected_signal
22562251
np.testing.assert_allclose(xr_ds["signal"].values, expected_signal)
2257-
# np.testing.assert_allclose(xr_ds["derived"].values, expected_derived)
2252+
np.testing.assert_allclose(xr_ds["derived"].values, expected_derived)
22582253

22592254

2260-
@pytest.mark.skip(reason="Disabled until we renable new export")
22612255
def test_with_without_shape_is_the_same(experiment: Experiment) -> None:
22622256
nx, ny = 2, 3
22632257
x_vals = np.linspace(0.0, -1.0, nx)

0 commit comments

Comments
 (0)