Skip to content

Commit

Permalink
Rudimentary deprecation notice for extra.numpy.basic_indices()
Browse files Browse the repository at this point in the history
  • Loading branch information
honno committed Sep 10, 2021
1 parent 85a061e commit 1fefd54
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions hypothesis-python/src/hypothesis/extra/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import numpy as np

from hypothesis import strategies as st
from hypothesis._settings import note_deprecation
from hypothesis.errors import InvalidArgument
from hypothesis.extra._array_helpers import (
NDIM_MAX,
Expand Down Expand Up @@ -822,8 +823,22 @@ def basic_indices(

if max_dims is None:
max_dims = min(max(len(shape), min_dims) + 2, NDIM_MAX)
deprecation_start = f"max_dims=None, which was defaulted to max_dims={max_dims},"
else:
deprecation_start = f"max_dims={max_dims}"
check_type(int, max_dims, "max_dims")
check_valid_dims(max_dims, "max_dims")
if max_dims > len(shape) and not allow_newaxis:
note_deprecation(
f"{deprecation_start} and allow_newaxis=False, so we cannot generate "
f"indices that would produce arrays with dimensions greater than "
f"len(shape)={len(shape)} i.e. the dimensions of the indexed array. "
f"In the next release, max_dims would default to the the dimensions "
f"of shape={shape!r} when allow_newaxis=False, and passing max_dims "
f"greater than len(shape) will raise an error.",
since="RELEASEDAY",
has_codemod=False,
)

order_check("dims", 0, min_dims, max_dims)

Expand Down

0 comments on commit 1fefd54

Please sign in to comment.