Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Feb 14, 2024
1 parent d76e971 commit e0a3660
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion e3sm_diags/driver/utils/regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ def _hybrid_to_plevs(

# Vertical regriding sets the units to "mb", but the original units
# should be preserved.
result[var_key].attrs["units"] = ds[var_key].units
result[var_key].attrs["units"] = ds[var_key].attrs["units"]

return result

Expand Down
6 changes: 3 additions & 3 deletions tests/e3sm_diags/driver/utils/test_regrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ def test_regrids_hybrid_levels_to_pressure_levels_with_existing_z_bounds(self):
# updating the arrays and attributes of data variables and coordinates.
expected = ds.sel(lev=[800, 200]).drop_vars(["ps", "hyam", "hybm"])
expected["so"].data[:] = np.nan
expected["so"].attrs["units"] = "mb"
expected["so"].attrs["units"] = "ppt"
expected["lev"].attrs = {
"axis": "Z",
"coordinate": "vertical",
Expand Down Expand Up @@ -364,7 +364,7 @@ def test_regrids_hybrid_levels_to_pressure_levels_with_generated_z_bounds(self):
# updating the arrays and attributes of data variables and coordinates.
expected = ds.sel(lev=[800, 200]).drop_vars(["ps", "hyam", "hybm"])
expected["so"].data[:] = np.nan
expected["so"].attrs["units"] = "mb"
expected["so"].attrs["units"] = "ppt"
expected["lev"].attrs = {
"axis": "Z",
"coordinate": "vertical",
Expand Down Expand Up @@ -393,7 +393,7 @@ def test_regrids_hybrid_levels_to_pressure_levels_with_Pa_units(self):
# updating the arrays and attributes of data variables and coordinates.
expected = ds.sel(lev=[800, 200]).drop_vars(["ps", "hyam", "hybm"])
expected["so"].data[:] = np.nan
expected["so"].attrs["units"] = "mb"
expected["so"].attrs["units"] = "ppt"
expected["lev"].attrs = {
"axis": "Z",
"coordinate": "vertical",
Expand Down
1 change: 1 addition & 0 deletions tests/e3sm_diags/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def generate_lev_dataset(
name="so",
data=np.ones((5, 4, 4, 4)),
coords={"time": time_decoded, "lev": lev, "lat": lat, "lon": lon},
attrs={"units": "ppt"},
),
},
coords={
Expand Down

0 comments on commit e0a3660

Please sign in to comment.