Skip to content

Commit

Permalink
Merge pull request #1099 from xcube-dev/konstntokas-xxx-adjust_xarray…
Browse files Browse the repository at this point in the history
…_dependency

xarray dependency adjusted in pyproject.toml
  • Loading branch information
konstntokas authored Jan 2, 2025
2 parents f3184e3 + 8ad5f0a commit 7cce4f3
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ dependencies:
- tabulate >=0.9
- tornado >=6.0
- urllib3 >=1.26
- xarray >=2022.6
- xarray >=2024.7
- zarr >=2.11
# Chartlets
- altair
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ dependencies = [
"tabulate>=0.9",
"tornado>=6.0",
"urllib3>=1.26",
"xarray>=2022.6,<=2024.6",
"xarray>=2024.7",
"zarr>=2.11"
]
classifiers = [
Expand Down
42 changes: 37 additions & 5 deletions test/core/resampling/test_temporal.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,44 @@ def test_resample_in_time_min_max(self):
self.assertEqual((1, 90, 180), schema.chunks)

def test_resample_in_time_p90_dask(self):
# "percentile_<p>" can currently only be used with numpy rather than chunked dask arrays:
resampled_cube = resample_in_time(self.input_cube, "2W", "percentile_90")
self.assertIsNot(resampled_cube, self.input_cube)
self.assertIn('time', resampled_cube)
self.assertIn('temperature_p90', resampled_cube)
self.assertIn('precipitation_p90', resampled_cube)
self.assertEqual(('time',), resampled_cube.time.dims)
self.assertEqual(('time', 'lat', 'lon'), resampled_cube.temperature_p90.dims)
self.assertEqual(('time', 'lat', 'lon'), resampled_cube.precipitation_p90.dims)
self.assertEqual((6,), resampled_cube.time.shape)
self.assertEqual((6, 180, 360), resampled_cube.temperature_p90.shape)
self.assertEqual((6, 180, 360), resampled_cube.precipitation_p90.shape)
np.testing.assert_equal(
resampled_cube.time.values,
np.array([
'2017-06-25T00:00:00Z',
'2017-07-09T00:00:00Z',
'2017-07-23T00:00:00Z',
'2017-08-06T00:00:00Z',
'2017-08-20T00:00:00Z',
'2017-09-03T00:00:00Z'
],
dtype=np.datetime64
)
)
np.testing.assert_allclose(
resampled_cube.temperature_p90.values[..., 0, 0],
np.array([272.27, 272.85, 273.63, 274.25, 274.76, 274.9])
)
np.testing.assert_allclose(
resampled_cube.precipitation_p90.values[..., 0, 0],
np.array([119.94, 119.1, 117.86, 116.3, 115.12, 114.2])
)
schema = CubeSchema.new(resampled_cube)
self.assertEqual(3, schema.ndim)
self.assertEqual(('time', 'lat', 'lon'), schema.dims)
self.assertEqual((6, 180, 360), schema.shape)
self.assertEqual((1, 90, 180), schema.chunks)

# TypeError raised on Windows, ValueError on Linux
with self.assertRaises(Exception):
# noinspection PyUnusedLocal
resampled_cube = resample_in_time(self.input_cube, "2W", "percentile_90")

# TODO (forman): the call to resample_in_time() takes forever,
# this is not xcube, but may be an issue in dask 0.14 or dask 2.8.
Expand Down

0 comments on commit 7cce4f3

Please sign in to comment.