Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#191)
Browse files Browse the repository at this point in the history
* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/pre-commit/mirrors-prettier: v3.0.0-alpha.6 → v3.0.0-alpha.9-for-vscode](pre-commit/mirrors-prettier@v3.0.0-alpha.6...v3.0.0-alpha.9-for-vscode)
- [github.com/pre-commit/mirrors-mypy: v1.1.1 → v1.4.1](pre-commit/mirrors-mypy@v1.1.1...v1.4.1)

* Use np.prod instead of np.product

Remove usage of `np.product` that was deprecated in numpy 1.25.0, see numpy/numpy#23314.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
  • Loading branch information
pre-commit-ci[bot] and weiji14 committed Jul 4, 2023
1 parent 26b04fc commit ab5fa39
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ repos:
- id: isort

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.0-alpha.6
rev: v3.0.0-alpha.9-for-vscode
hooks:
- id: prettier

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.1.1
rev: v1.4.1
hooks:
- id: mypy
additional_dependencies: [
Expand Down
2 changes: 1 addition & 1 deletion xbatcher/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def _gen_empty_batch_selectors(self) -> BatchSelectorSet:
Create an empty batch selector set that can be populated by appending
patches to each batch.
"""
n_batches = np.product(list(self._n_batches_per_dim.values()))
n_batches = np.prod(list(self._n_batches_per_dim.values()))
return {k: [] for k in range(n_batches)}

def _gen_patch_numbers(self, ds: Union[xr.DataArray, xr.Dataset]):
Expand Down
14 changes: 7 additions & 7 deletions xbatcher/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def _get_sample_length(
else:
batch_concat_dims = []
return int(
np.product(list(non_specified_ds_dims.values()))
* np.product(list(non_input_batch_dims.values()))
* np.product(batch_concat_dims)
np.prod(list(non_specified_ds_dims.values()))
* np.prod(list(non_input_batch_dims.values()))
* np.prod(batch_concat_dims)
)


Expand Down Expand Up @@ -209,7 +209,7 @@ def _get_nbatches_from_input_dims(generator: BatchGenerator) -> int:
s : int
Number of batches expected given ``input_dims`` and ``input_overlap``.
"""
nbatches_from_input_dims = np.product(
nbatches_from_input_dims = np.prod(
[
generator.ds.sizes[dim] // length
for dim, length in generator.input_dims.items()
Expand All @@ -218,7 +218,7 @@ def _get_nbatches_from_input_dims(generator: BatchGenerator) -> int:
]
)
if generator.input_overlap:
nbatches_from_input_overlap = np.product(
nbatches_from_input_overlap = np.prod(
[
(generator.ds.sizes[dim] - overlap)
// (generator.input_dims[dim] - overlap)
Expand All @@ -242,13 +242,13 @@ def validate_generator_length(generator: BatchGenerator) -> None:
"""
non_input_batch_dims = _get_non_input_batch_dims(generator)
duplicate_batch_dims = _get_duplicate_batch_dims(generator)
nbatches_from_unique_batch_dims = np.product(
nbatches_from_unique_batch_dims = np.prod(
[
generator.ds.sizes[dim] // length
for dim, length in non_input_batch_dims.items()
]
)
nbatches_from_duplicate_batch_dims = np.product(
nbatches_from_duplicate_batch_dims = np.prod(
[
generator.ds.sizes[dim] // length
for dim, length in duplicate_batch_dims.items()
Expand Down

0 comments on commit ab5fa39

Please sign in to comment.