Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/era5_climatology_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def test(self):
input_path = self.create_tempdir('source').full_path
output_path = self.create_tempdir('destination').full_path

input_ds = test_util.dummy_era5_surface_dataset(times=90 * 24, freq='1H')
input_ds = test_util.dummy_era5_surface_dataset(times=90 * 24, freq='1h')
input_ds.chunk({'time': 31}).to_zarr(input_path)

expected = input_ds.groupby('time.month').apply(
Expand Down
11 changes: 6 additions & 5 deletions xarray_beam/_src/combiners.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import dataclasses
import logging
import math
from typing import Literal
from typing import TypeVar

import apache_beam as beam
import numpy.typing as npt
Expand All @@ -32,6 +32,7 @@


DimLike = str | Sequence[str] | None
_T = TypeVar('_T')


@dataclasses.dataclass
Expand Down Expand Up @@ -350,8 +351,8 @@ def _finalize_no_combiner(
return key, chunk

def _prepare_key(
self, key: core.Key, chunk: xarray.Dataset
) -> tuple[tuple[tuple[int, ...], core.Key], xarray.Dataset]:
self, key: core.Key, chunk: _T
) -> tuple[tuple[tuple[int, ...], core.Key], _T]:
assert self.bins_per_stage # not empty
index = _get_chunk_index(key, self.dims, self.chunks, self.sizes)
# strip the final bin because it isn't needed for the combiner
Expand All @@ -360,8 +361,8 @@ def _prepare_key(
return ((bin_ids, key), chunk)

def _strip_leading_fanout_bin(
self, bin_key: tuple[tuple[int, ...], core.Key], value: xarray.Dataset
) -> tuple[tuple[tuple[int, ...], core.Key], xarray.Dataset]:
self, bin_key: tuple[tuple[int, ...], core.Key], value: _T
) -> tuple[tuple[tuple[int, ...], core.Key], _T]:
bin_ids, key = bin_key
return (bin_ids[1:], key), value

Expand Down
10 changes: 5 additions & 5 deletions xarray_beam/_src/dataset_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -1262,7 +1262,7 @@ class EndToEndTest(test_util.TestCase):

def test_bytes_per_chunk_and_chunk_count(self):
source_ds = test_util.dummy_era5_surface_dataset(
variables=2, latitudes=73, longitudes=144, times=365, freq='24H'
variables=2, latitudes=73, longitudes=144, times=365, freq='24h'
)

xbeam_ds = xbeam.Dataset.from_xarray(
Expand All @@ -1288,7 +1288,7 @@ def test_docstring_example(self):
output_path = self.create_tempdir('output').full_path

source_ds = test_util.dummy_era5_surface_dataset(
variables=2, latitudes=73, longitudes=144, times=365, freq='24H'
variables=2, latitudes=73, longitudes=144, times=365, freq='24h'
)
source_ds.chunk({'time': 90}).to_zarr(input_path)

Expand All @@ -1309,7 +1309,7 @@ def test_climatology(self):
input_path = self.create_tempdir('source').full_path
output_path = self.create_tempdir('output').full_path

source_ds = test_util.dummy_era5_surface_dataset(times=365, freq='24H')
source_ds = test_util.dummy_era5_surface_dataset(times=365, freq='24h')
source_ds.chunk({'time': 90}).to_zarr(input_path)

transform = (
Expand All @@ -1330,7 +1330,7 @@ def test_resample(self):
output_path = self.create_tempdir('output').full_path

source_ds = test_util.dummy_era5_surface_dataset(
latitudes=73, longitudes=144, times=365, freq='24H'
latitudes=73, longitudes=144, times=365, freq='24h'
)
source_ds.chunk({'time': 90}).to_zarr(input_path)

Expand Down Expand Up @@ -1359,7 +1359,7 @@ def test_multiple_analysis_ready_outputs(self):
climatology_path = self.create_tempdir('climatology').full_path

source_ds = test_util.dummy_era5_surface_dataset(
latitudes=73, longitudes=144, times=365, freq='24H'
latitudes=73, longitudes=144, times=365, freq='24h'
)
source_ds.chunk({'time': 30}).to_zarr(input_path)

Expand Down
2 changes: 1 addition & 1 deletion xarray_beam/_src/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def dummy_era5_surface_dataset(
latitudes=73,
longitudes=144,
times=365 * 4,
freq='6H',
freq='6h',
):
"""A mock version of the Pangeo ERA5 surface reanalysis dataset."""
# based on: gs://pangeo-era5/reanalysis/spatial-analysis
Expand Down
Loading