From 202aeb6451979323353147a0b91b42d202110a3e Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Mon, 18 Jul 2022 22:45:05 +0200 Subject: [PATCH 1/5] Update DeepSource configuration (#1078) The default Python version has become 3.x.x: https://deepsource.io/docs/analyzer/python/ --- .deepsource.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.deepsource.toml b/.deepsource.toml index 5143b2739..e68653328 100644 --- a/.deepsource.toml +++ b/.deepsource.toml @@ -5,6 +5,3 @@ test_patterns = ["zarr/tests/test_*.py"] [[analyzers]] name = "python" enabled = true - - [analyzers.meta] - runtime_version = "3.x.x" From 7212d263f51196f21f2c9cb7bb4fc080d4399e06 Mon Sep 17 00:00:00 2001 From: Pavithra Eswaramoorthy Date: Tue, 19 Jul 2022 04:21:20 +0530 Subject: [PATCH 2/5] Close quote typo fix (#1083) * close quote typo fixes * add to release notes --- docs/release.rst | 12 +++++++++--- docs/tutorial.rst | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index d16f14fb4..706859a55 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -6,10 +6,16 @@ Release notes # to document your changes. On releases it will be # re-indented so that it does not show up in the notes. - .. _unreleased: +.. _unreleased: + +Unreleased +---------- + +Documentation +~~~~~~~~~~~~~ + +* Typo fixes to close quotes. By :user:`Pavithra Eswaramoorthy ` - Unreleased - ---------- .. _release_2.12.0: diff --git a/docs/tutorial.rst b/docs/tutorial.rst index 1cd0387a7..fcee87c88 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -1404,7 +1404,7 @@ access patterns and incur a substantial performance hit when using file based stores. One of the most pathological examples is switching from column-based chunking to row-based chunking e.g. :: - >>> a = zarr.zeros((10000,10000), chunks=(10000, 1), dtype='uint16, store='a.zarr') + >>> a = zarr.zeros((10000,10000), chunks=(10000, 1), dtype='uint16', store='a.zarr') >>> b = zarr.array(a, chunks=(1,10000), store='b.zarr') which will require every chunk in the input data set to be repeatedly read when creating @@ -1412,7 +1412,7 @@ each output chunk. If the entire array will fit within memory, this is simply re by forcing the entire input array into memory as a numpy array before converting back to zarr with the desired chunking. :: - >>> a = zarr.zeros((10000,10000), chunks=(10000, 1), dtype='uint16, store='a.zarr') + >>> a = zarr.zeros((10000,10000), chunks=(10000, 1), dtype='uint16', store='a.zarr') >>> b = a[...] >>> c = zarr.array(b, chunks=(1,10000), store='c.zarr') From 5c602cb47b305468b31f6126460362ae7af2303b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Jul 2022 08:21:52 -0500 Subject: [PATCH 3/5] Bump setuptools-scm from 7.0.4 to 7.0.5 (#1072) Bumps [setuptools-scm](https://github.com/pypa/setuptools_scm) from 7.0.4 to 7.0.5. - [Release notes](https://github.com/pypa/setuptools_scm/releases) - [Changelog](https://github.com/pypa/setuptools_scm/blob/main/CHANGELOG.rst) - [Commits](https://github.com/pypa/setuptools_scm/compare/v7.0.4...v7.0.5) --- updated-dependencies: - dependency-name: setuptools-scm dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- requirements_dev_minimal.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements_dev_minimal.txt b/requirements_dev_minimal.txt index 5dcdab16b..40098a315 100644 --- a/requirements_dev_minimal.txt +++ b/requirements_dev_minimal.txt @@ -3,6 +3,6 @@ asciitree==0.3.3 fasteners==0.17.3 numcodecs==0.10.0 msgpack-python==0.5.6 -setuptools-scm==7.0.4 +setuptools-scm==7.0.5 # test requirements pytest==7.1.2 From 4b833028ed8821ce80126e5156b6b0b3b2b0d0bc Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 19 Jul 2022 20:07:09 +0200 Subject: [PATCH 4/5] More typos found by codespell (#1073) --- docs/release.rst | 6 ++++++ docs/tutorial.rst | 2 +- zarr/core.py | 2 +- zarr/meta.py | 4 ++-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index 706859a55..0b9a208b2 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -16,6 +16,12 @@ Documentation * Typo fixes to close quotes. By :user:`Pavithra Eswaramoorthy ` +Maintenance +~~~~~~~~~~~ + +* Fix spelling. + By :user:`Dimitri Papadopoulos Orfanos `, :issue:`1073`. + .. _release_2.12.0: diff --git a/docs/tutorial.rst b/docs/tutorial.rst index fcee87c88..37073fcb3 100644 --- a/docs/tutorial.rst +++ b/docs/tutorial.rst @@ -897,7 +897,7 @@ The second invocation here will be much faster. Note that the ``storage_options` have become more complex here, to account for the two parts of the supplied URL. -It is also possible to initialize the filesytem outside of Zarr and then pass +It is also possible to initialize the filesystem outside of Zarr and then pass it through. This requires creating an :class:`zarr.storage.FSStore` object explicitly. For example:: diff --git a/zarr/core.py b/zarr/core.py index 6ce2fa880..bd61639ef 100644 --- a/zarr/core.py +++ b/zarr/core.py @@ -153,7 +153,7 @@ class Array: def __init__( self, - store: Any, # BaseStore not stricly required due to normalize_store_arg + store: Any, # BaseStore not strictly required due to normalize_store_arg path=None, read_only=False, chunk_store=None, diff --git a/zarr/meta.py b/zarr/meta.py index a0f2e80f8..c290e9016 100644 --- a/zarr/meta.py +++ b/zarr/meta.py @@ -81,7 +81,7 @@ def get_extended_dtype_info(dtype) -> dict: fallback=None, ) else: - raise ValueError(f"Unsupport dtype: {dtype}") + raise ValueError(f"Unsupported dtype: {dtype}") class Metadata2: @@ -399,7 +399,7 @@ def decode_hierarchy_metadata( "metadata_key_suffix", "extensions", }: - raise ValueError(f"Unexpected keys in metdata. meta={meta}") + raise ValueError(f"Unexpected keys in metadata. meta={meta}") return meta @classmethod From ece1810e88cb5e921da669a554ad272d6061c996 Mon Sep 17 00:00:00 2001 From: Dimitri Papadopoulos Orfanos <3234522+DimitriPapadopoulos@users.noreply.github.com> Date: Tue, 19 Jul 2022 20:38:26 +0200 Subject: [PATCH 5/5] Fix deepsource.io issues (#1080) * Use a ternary if/else instead of and/or An instance of the pre-Python 2.5 ternary syntax is being used. Using [condition] and [on_true] or [on_false] may give wrong results when on_true has a false boolean value. * Remove unneeded `not` * Use `is` when comparing `type` of two objects * Unnecessary use of a comprehension * Unnecessary `None` provided as default Unlike pop() which raises a KeyError by default, get() returns None by default. Co-authored-by: Josh Moore --- docs/release.rst | 4 +++- zarr/convenience.py | 2 +- zarr/hierarchy.py | 2 +- zarr/storage.py | 2 +- zarr/tests/test_convenience.py | 2 +- zarr/tests/test_creation.py | 12 ++++++------ zarr/tests/test_hierarchy.py | 2 +- zarr/tests/test_storage.py | 2 +- 8 files changed, 15 insertions(+), 13 deletions(-) diff --git a/docs/release.rst b/docs/release.rst index 0b9a208b2..b729f20ee 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -19,10 +19,12 @@ Documentation Maintenance ~~~~~~~~~~~ +* Fix a few DeepSource.io alerts + By :user:`Dimitri Papadopoulos Orfanos ` :issue:`1080`. + * Fix spelling. By :user:`Dimitri Papadopoulos Orfanos `, :issue:`1073`. - .. _release_2.12.0: 2.12.0 diff --git a/zarr/convenience.py b/zarr/convenience.py index 93dc86047..be8b609a4 100644 --- a/zarr/convenience.py +++ b/zarr/convenience.py @@ -1279,7 +1279,7 @@ def open_consolidated(store: StoreLike, metadata_key=".zmetadata", mode="r+", ** """ # normalize parameters - zarr_version = kwargs.get('zarr_version', None) + zarr_version = kwargs.get('zarr_version') store = normalize_store_arg(store, storage_options=kwargs.get("storage_options"), mode=mode, zarr_version=zarr_version) if mode not in {'r', 'r+'}: diff --git a/zarr/hierarchy.py b/zarr/hierarchy.py index b9052408b..80da3ddbc 100644 --- a/zarr/hierarchy.py +++ b/zarr/hierarchy.py @@ -1327,7 +1327,7 @@ def open_group(store=None, mode='a', cache_attrs=True, synchronizer=None, path=N storage_options=storage_options, mode=mode, zarr_version=zarr_version) - if not getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION) == zarr_version: + if getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION) != zarr_version: raise ValueError( "zarr_version of store and chunk_store must match" ) diff --git a/zarr/storage.py b/zarr/storage.py index 48b6f049d..440b41ea0 100644 --- a/zarr/storage.py +++ b/zarr/storage.py @@ -1413,7 +1413,7 @@ def __contains__(self, key): return key in self.map def __eq__(self, other): - return (type(self) == type(other) and self.map == other.map + return (type(self) is type(other) and self.map == other.map and self.mode == other.mode) def keys(self): diff --git a/zarr/tests/test_convenience.py b/zarr/tests/test_convenience.py index d0d293a69..59bb3aa7d 100644 --- a/zarr/tests/test_convenience.py +++ b/zarr/tests/test_convenience.py @@ -45,7 +45,7 @@ ) from zarr.tests.util import have_fsspec -_VERSIONS = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((2, 3) if v3_api_available else (2, )) def _init_creation_kwargs(zarr_version): diff --git a/zarr/tests/test_creation.py b/zarr/tests/test_creation.py index 48d6aee4f..b8ab11832 100644 --- a/zarr/tests/test_creation.py +++ b/zarr/tests/test_creation.py @@ -21,8 +21,8 @@ from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3 from zarr.sync import ThreadSynchronizer -_VERSIONS = v3_api_available and (None, 2, 3) or (None, 2) -_VERSIONS2 = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((None, 2, 3) if v3_api_available else (None, 2)) +_VERSIONS2 = ((2, 3) if v3_api_available else (2, )) # something bcolz-like @@ -430,7 +430,7 @@ def test_empty_like(zarr_version): z = empty(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) # zarr_version will be inferred from z, but have to specify a path in v3 - z2 = empty_like(z, path=kwargs.get('path', None)) + z2 = empty_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -479,7 +479,7 @@ def test_zeros_like(zarr_version): # zarr array z = zeros(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) - z2 = zeros_like(z, path=kwargs.get('path', None)) + z2 = zeros_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -506,7 +506,7 @@ def test_ones_like(zarr_version): # zarr array z = ones(100, chunks=10, dtype='f4', compressor=Zlib(5), order='F', **kwargs) - z2 = ones_like(z, path=kwargs.get('path', None)) + z2 = ones_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype @@ -533,7 +533,7 @@ def test_full_like(zarr_version): z = full(100, chunks=10, dtype='f4', compressor=Zlib(5), fill_value=42, order='F', **kwargs) - z2 = full_like(z, path=kwargs.get('path', None)) + z2 = full_like(z, path=kwargs.get('path')) assert z.shape == z2.shape assert z.chunks == z2.chunks assert z.dtype == z2.dtype diff --git a/zarr/tests/test_hierarchy.py b/zarr/tests/test_hierarchy.py index 7c2eaa3f7..61c40e9f7 100644 --- a/zarr/tests/test_hierarchy.py +++ b/zarr/tests/test_hierarchy.py @@ -35,7 +35,7 @@ from zarr.tests.util import skip_test_env_var, have_fsspec, abs_container -_VERSIONS = v3_api_available and (2, 3) or (2,) +_VERSIONS = ((2, 3) if v3_api_available else (2, )) # noinspection PyStatementEffect diff --git a/zarr/tests/test_storage.py b/zarr/tests/test_storage.py index a3e227ec8..b938115e3 100644 --- a/zarr/tests/test_storage.py +++ b/zarr/tests/test_storage.py @@ -2400,7 +2400,7 @@ def test_iterators_with_prefix(self): assert 4 == len(store) keys = [prefix + 'a', prefix + 'b', prefix + 'c/d', prefix + 'c/e/f'] values = [b'aaa', b'bbb', b'ddd', b'fff'] - items = [(k, v) for k, v in zip(keys, values)] + items = list(zip(keys, values)) assert set(keys) == set(store) assert set(keys) == set(store.keys()) assert set(values) == set(store.values())