Skip to content

Commit f64e8c3

Browse files
authored
Fix tests that fail from new Xarray variable and attribute assignment updates (#1433)
* add .values to change water level scalar value * add .values to fillna * fix assign attributes * remove test1 * update echodata properly * remove print statement
1 parent a35430f commit f64e8c3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

echopype/tests/consolidate/test_add_depth.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def test_ek_depth_utils_group_variable_NaNs_logger_warnings(caplog):
196196
ds_Sv = ep.calibrate.compute_Sv(ed, **{"waveform_mode":"CW", "encode_mode":"power"})
197197

198198
# Set first index of group variables to NaN
199-
ed["Platform"]["water_level"] = np.nan # Is a scalar
199+
ed["Platform"]["water_level"].values = np.nan # Is a scalar
200200
ed["Platform"]["vertical_offset"].values[0] = np.nan
201201
ed["Platform"]["transducer_offset_z"].values[0] = np.nan
202202
ed["Platform"]["pitch"].values[0] = np.nan
@@ -337,7 +337,7 @@ def test_add_depth_errors():
337337
with pytest.raises(NotImplementedError, match=(
338338
"`use_platform/beam_...` not implemented yet for `AZFP`."
339339
)):
340-
ed["Sonar"].attrs["sonar_model"] = "AZFP"
340+
ed["Sonar"] = ed["Sonar"].assign_attrs(sonar_model="AZFP")
341341
ep.consolidate.add_depth(ds_Sv, ed, use_platform_angles=True)
342342

343343

@@ -375,9 +375,9 @@ def test_add_depth_EK_with_platform_vertical_offsets(file, sonar_model, compute_
375375
ds_Sv = ds_Sv.isel(range_sample=slice(0,5))
376376

377377
# Replace any Platform Vertical Offset NaN values with 0
378-
ed["Platform"]["water_level"] = ed["Platform"]["water_level"].fillna(0)
379-
ed["Platform"]["vertical_offset"] = ed["Platform"]["vertical_offset"].fillna(0)
380-
ed["Platform"]["transducer_offset_z"] = ed["Platform"]["transducer_offset_z"].fillna(0)
378+
ed["Platform"]["water_level"].values = ed["Platform"]["water_level"].fillna(0).values
379+
ed["Platform"]["vertical_offset"].values = ed["Platform"]["vertical_offset"].fillna(0).values
380+
ed["Platform"]["transducer_offset_z"].values = ed["Platform"]["transducer_offset_z"].fillna(0).values
381381

382382
# Compute `depth` using platform vertical offset values
383383
ds_Sv_with_depth = ep.consolidate.add_depth(ds_Sv, ed, use_platform_vertical_offsets=True)
@@ -431,8 +431,8 @@ def test_add_depth_EK_with_platform_angles(file, sonar_model, compute_Sv_kwargs)
431431
ds_Sv = ep.calibrate.compute_Sv(ed, **compute_Sv_kwargs)
432432

433433
# Replace any Beam Angle NaN values with 0
434-
ed["Platform"]["pitch"] = ed["Platform"]["pitch"].fillna(0)
435-
ed["Platform"]["roll"] = ed["Platform"]["roll"].fillna(0)
434+
ed["Platform"]["pitch"].values = ed["Platform"]["pitch"].fillna(0).values
435+
ed["Platform"]["roll"].values = ed["Platform"]["roll"].fillna(0).values
436436

437437
# Compute `depth` using platform angle values
438438
ds_Sv_with_depth = ep.consolidate.add_depth(ds_Sv, ed, use_platform_angles=True)
@@ -485,9 +485,9 @@ def test_add_depth_EK_with_beam_angles(file, sonar_model, compute_Sv_kwargs):
485485
ds_Sv = ep.calibrate.compute_Sv(ed, **compute_Sv_kwargs)
486486

487487
# Replace Beam Angle NaN values
488-
ed["Sonar/Beam_group1"]["beam_direction_x"] = ed["Sonar/Beam_group1"]["beam_direction_x"].fillna(0)
489-
ed["Sonar/Beam_group1"]["beam_direction_y"] = ed["Sonar/Beam_group1"]["beam_direction_y"].fillna(0)
490-
ed["Sonar/Beam_group1"]["beam_direction_z"] = ed["Sonar/Beam_group1"]["beam_direction_z"].fillna(1)
488+
ed["Sonar/Beam_group1"]["beam_direction_x"].values = ed["Sonar/Beam_group1"]["beam_direction_x"].fillna(0).values
489+
ed["Sonar/Beam_group1"]["beam_direction_y"].values = ed["Sonar/Beam_group1"]["beam_direction_y"].fillna(0).values
490+
ed["Sonar/Beam_group1"]["beam_direction_z"].values = ed["Sonar/Beam_group1"]["beam_direction_z"].fillna(1).values
491491

492492
# Compute `depth` using beam angle values
493493
ds_Sv_with_depth = ep.consolidate.add_depth(ds_Sv, ed, use_beam_angles=True)

0 commit comments

Comments
 (0)