diff --git a/zcollection/collection/__init__.py b/zcollection/collection/__init__.py index b7b2e93..26a4184 100644 --- a/zcollection/collection/__init__.py +++ b/zcollection/collection/__init__.py @@ -86,7 +86,7 @@ def _infer_callable( try: one_partition: str = next(collection.partitions(filters=filters)) except StopIteration: - return tuple() + return () with collection.synchronizer: zds: dataset.Dataset = storage.open_zarr_group( diff --git a/zcollection/collection/detail.py b/zcollection/collection/detail.py index c1669d1..d2cb9fe 100644 --- a/zcollection/collection/detail.py +++ b/zcollection/collection/detail.py @@ -472,5 +472,4 @@ def _load_and_apply_indexer( partition_handler.join(partition_scheme, fs.sep)) zds: dataset.Dataset = open_zarr_group( partition, fs, delayed=delayed, selected_variables=selected_variables) - return list( - zds.isel({partition_properties.dim: indexer}) for indexer in items) + return [zds.isel({partition_properties.dim: indexer}) for indexer in items] diff --git a/zcollection/collection/tests/test_collection.py b/zcollection/collection/tests/test_collection.py index d1c6401..6c8a640 100644 --- a/zcollection/collection/tests/test_collection.py +++ b/zcollection/collection/tests/test_collection.py @@ -561,7 +561,7 @@ def test_insert_with_missing_variable( created by an algorithm. """ tested_fs = request.getfixturevalue(arg) - zds = next(create_test_dataset_with_fillvalue()).to_xarray() + zds = next(create_test_dataset_with_fillvalue()) zcollection = convenience.create_collection( axis='time', ds=zds, diff --git a/zcollection/indexing/abc.py b/zcollection/indexing/abc.py index 29f029d..22ab1e1 100644 --- a/zcollection/indexing/abc.py +++ b/zcollection/indexing/abc.py @@ -396,13 +396,10 @@ def _table_2_indexer(self, table: pyarrow.Table, # Finally, we build the list of indexes of the different chunks found. chunks = numpy.unique(numpy.concatenate(chunks)) - return ( - tuple( # type:ignore - (tuple( - (name, data[name][ix0]) - for name in column_names), slice(start[ix0], - stop[ix1 - 1])), ) - for ix0, ix1 in tuple(zip(chunks[:-1], chunks[1:]))) + return ( # force yapf to respect the line break for flake8 + (tuple((name, data[name][ix0]) + for name in column_names), slice(start[ix0], stop[ix1 - 1])) + for ix0, ix1 in zip(chunks[:-1], chunks[1:])) def query( self, @@ -425,7 +422,7 @@ def query( Indexer. """ if len(self._partition_keys) == 0: - return tuple() + return () logical_op = logical_op or 'and' if logical_op not in ('and', 'and_not', 'invert', 'or', 'xor'): diff --git a/zcollection/indexing/tests/test_abc.py b/zcollection/indexing/tests/test_abc.py index 1f9b201..4254291 100644 --- a/zcollection/indexing/tests/test_abc.py +++ b/zcollection/indexing/tests/test_abc.py @@ -241,4 +241,4 @@ def test_indexer( ) indexer = HalfOrbitIndexer('', filesystem=fsspec.filesystem('memory')) - assert indexer.query({'cycle_number': [2, 4]}) == tuple() + assert indexer.query({'cycle_number': [2, 4]}) == () diff --git a/zcollection/meta.py b/zcollection/meta.py index 66befa7..9a0ac6b 100644 --- a/zcollection/meta.py +++ b/zcollection/meta.py @@ -137,7 +137,7 @@ def __init__(self, compressor: numcodecs.abc.Codec | None = None, fill_value: Any | None = None, filters: Sequence[numcodecs.abc.Codec] | None = None) -> None: - attrs = attrs or tuple() + attrs = attrs or () #: Attributes of the variable. self.attrs = tuple(attrs) diff --git a/zcollection/partitioning/date.py b/zcollection/partitioning/date.py index 0e12118..55ae877 100644 --- a/zcollection/partitioning/date.py +++ b/zcollection/partitioning/date.py @@ -193,7 +193,7 @@ def encode( >>> partitioning.encode(fields) (numpy.datetime64('2020-01-01'),) """ - return tuple((numpy.datetime64(self._stringify(partition)), )) + return (numpy.datetime64(self._stringify(partition)), ) def decode( self, diff --git a/zcollection/tests/test_compressed_array.py b/zcollection/tests/test_compressed_array.py index e43cba6..731ffce 100644 --- a/zcollection/tests/test_compressed_array.py +++ b/zcollection/tests/test_compressed_array.py @@ -25,7 +25,7 @@ #: Functions to test functions = [ lambda x: x, - lambda x: dask.array.ufunc.expm1(x), + dask.array.ufunc.expm1, lambda x: 2 * x, lambda x: x / 2, lambda x: x**2, @@ -36,17 +36,17 @@ lambda x: x[:1, :, 1:3], lambda x: x.T, lambda x: dask.array.routines.transpose(x, (1, 2, 0)), - lambda x: dask.array.reductions.nanmean(x), + dask.array.reductions.nanmean, lambda x: dask.array.reductions.nanmean(x, axis=1), - lambda x: dask.array.reductions.nanmax(x), - lambda x: dask.array.reductions.nanmin(x), - lambda x: dask.array.reductions.nanprod(x), - lambda x: dask.array.reductions.nanstd(x), - lambda x: dask.array.reductions.nanvar(x), - lambda x: dask.array.reductions.nansum(x), + dask.array.reductions.nanmax, + dask.array.reductions.nanmin, + dask.array.reductions.nanprod, + dask.array.reductions.nanstd, + dask.array.reductions.nanvar, + dask.array.reductions.nansum, lambda x: dask.array.reductions.median(x, axis=0), - lambda x: dask.array.reductions.nanargmax(x), - lambda x: dask.array.reductions.nanargmin(x), + dask.array.reductions.nanargmax, + dask.array.reductions.nanargmin, lambda x: dask.array.reductions.nancumprod(x, axis=0), lambda x: dask.array.reductions.nancumsum(x, axis=0), lambda x: x.sum(), @@ -74,12 +74,12 @@ lambda x: x * 2, depth=0, trim=False, boundary='none'), lambda x: x.round(1), lambda x: x.reshape((x.shape[0] * x.shape[1], x.shape[2])), - lambda x: abs(x), + abs, lambda x: x > 0.5, lambda x: x.rechunk((4, 4, 4)), lambda x: x.rechunk((2, 2, 1)), - lambda x: numpy.isneginf(x), - lambda x: numpy.isposinf(x), + numpy.isneginf, + numpy.isposinf, ] # pylint: enable=unnecessary-lambda diff --git a/zcollection/tests/test_dataset.py b/zcollection/tests/test_dataset.py index 5f5dbfa..e1f4a75 100644 --- a/zcollection/tests/test_dataset.py +++ b/zcollection/tests/test_dataset.py @@ -482,11 +482,11 @@ def test_dataset_select_variables_by_dims( assert list(selected.variables) == ['var1', 'var3', 'var4', 'var6'] assert selected.dimensions == {'x': 10, 'y': 10, 'a': 20, 'b': 20} - selected = zds.select_variables_by_dims(tuple()) + selected = zds.select_variables_by_dims(()) assert list(selected.variables) == ['var7'] assert selected.dimensions == {} - selected = zds.select_variables_by_dims(tuple(), predicate=False) + selected = zds.select_variables_by_dims((), predicate=False) assert list(selected.variables) == [ 'var1', 'var2', 'var3', 'var4', 'var5', 'var6' ] diff --git a/zcollection/variable/abc.py b/zcollection/variable/abc.py index e307a2f..01aa236 100644 --- a/zcollection/variable/abc.py +++ b/zcollection/variable/abc.py @@ -420,7 +420,7 @@ def set_for_insertion(self: T) -> T: name=self.name, array=self.array, dimensions=self.dimensions, - attrs=tuple(), + attrs=(), compressor=self.compressor, fill_value=self.fill_value, filters=self.filters)