Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Marco Mancini committed Jan 31, 2024
1 parent 19104bd commit 02c10b1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
26 changes: 12 additions & 14 deletions tests/core/test_domain.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def test_latest_points(points1):


def test_to_netcdf_points(points1):
path = "data/test_points.nc"
path = "tests/data/test_points.nc"
points1.to_netcdf(path)
dset = xr.load_dataset(path, decode_coords="all")
pts_dset = points1._dset.rename(**{
Expand Down Expand Up @@ -280,18 +280,16 @@ def test_latest_profiles(profiles):


def test_to_netcdf_profiles(profiles):
# FIXME: This giver a permission denied error.
# path = 'data/test_profiles.nc'
# profiles.to_netcdf(path)
# dset = xr.load_dataset(path, decode_coords='all')
# prof_dset = profiles._dset.rename(
# **{
# axis_: coord.attrs.get('standard_name', str(axis_))
# for axis_, coord in profiles._dset.coords.items()
# }
# )
# assert prof_dset.equals(dset)
pass
path = 'tests/data/test_profiles.nc'
profiles.to_netcdf(path)
dset = xr.load_dataset(path, decode_coords='all')
prof_dset = profiles._dset.rename(
**{
axis_: coord.attrs.get('standard_name', str(axis_))
for axis_, coord in profiles._dset.coords.items()
}
)
assert prof_dset.equals(dset)


#
Expand Down Expand Up @@ -343,4 +341,4 @@ def test_latest_grid(grid):


def test_to_netcdf_grid(grid):
grid.to_netcdf("test_grid.nc")
grid.to_netcdf("tests/data/test_grid.nc")
Empty file added tests/data/__init__.py
Empty file.
8 changes: 4 additions & 4 deletions tests/fixtures/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def points1(geodetic_cs):
pts = Points(
coords=[
("2001-01-01", 10.5, 42.2, -12.2),
("2001-01-05", 11.2, 56.2, 10.2),
("2001-01-02", 11.2, 56.2, 10.2),
],
coord_system=geodetic_cs,
)
Expand All @@ -86,7 +86,7 @@ def points2(geodetic_cs):
axis.latitude: [42.2, 56.2],
axis.longitude: [-12.2, 10.2],
axis.vertical: [10.5, 11.2],
axis.time: ["2001-01-01", "2001-01-05"],
axis.time: ["2001-01-01", "2001-01-02"],
},
coord_system=geodetic_cs,
)
Expand All @@ -100,7 +100,7 @@ def profiles(geodetic_cs):
axis.latitude: [42.2, 56.2],
axis.longitude: [-12.2, 10.2],
axis.vertical: [[10.5, 11.2, 12.3], [10.7, 11.5, 12.5, 13.5]],
axis.time: ["2001-01-01", "2001-01-05"],
axis.time: ["2001-01-01", "2001-01-02"],
},
coord_system=geodetic_cs,
)
Expand All @@ -114,7 +114,7 @@ def grid(geodetic_cs):
axis.latitude: [42.2, 56.2],
axis.longitude: [-12.2, 10.2],
axis.vertical: [10.5, 11.2, 12.3],
axis.time: ["2001-01-01", "2001-01-05"],
axis.time: ["2001-01-01", "2001-01-02"],
},
coord_system=geodetic_cs,
)
Expand Down

0 comments on commit 02c10b1

Please sign in to comment.