Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use FutureWarning instead of VisibleDeprecationWarning #193

Merged
merged 2 commits into from
May 14, 2024
Merged
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
5 changes: 1 addition & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,4 @@ addopts = "--doctest-modules --strict-config --strict-markers -q -ra --ff"
testpaths = ["src/resample", "tests"]
log_cli_level = "INFO"
xfail_strict = true
filterwarnings = [
"error::DeprecationWarning",
"error::numpy.VisibleDeprecationWarning",
]
filterwarnings = ["error::DeprecationWarning", "error::FutureWarning"]
8 changes: 2 additions & 6 deletions src/resample/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,10 @@ def resample(
if not isinstance(args[0], Collection):
import warnings

from numpy import VisibleDeprecationWarning

warnings.warn(
"Calling resample with positional instead of keyword parameters is "
"deprecated",
VisibleDeprecationWarning,
FutureWarning,
)
kwargs: Dict[str, Any] = {
"size": size,
Expand Down Expand Up @@ -434,12 +432,10 @@ def confidence_interval(
if args and not isinstance(args[0], Collection):
import warnings

from numpy import VisibleDeprecationWarning

warnings.warn(
"Calling confidence_interval with positional instead of keyword "
"arguments is deprecated",
VisibleDeprecationWarning,
FutureWarning,
)

if len(args) == 1:
Expand Down
4 changes: 1 addition & 3 deletions src/resample/jackknife.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,10 @@ def resample(
if not isinstance(args[0], Collection):
import warnings

from numpy import VisibleDeprecationWarning

warnings.warn(
"Calling resample with positional instead of keyword arguments is "
"deprecated",
VisibleDeprecationWarning,
FutureWarning,
)
if len(args) == 1:
(copy,) = args
Expand Down
3 changes: 1 addition & 2 deletions src/resample/permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,8 +150,7 @@ def usp(

if method == "shuffle":
warnings.warn(
"method 'shuffle' is deprecated, please use 'boyett'",
np.VisibleDeprecationWarning,
"method 'shuffle' is deprecated, please use 'boyett'", FutureWarning
)
method = "boyett"

Expand Down
27 changes: 12 additions & 15 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,57 +309,54 @@ def test_covariance(method, rng):

def test_resample_deprecation(rng):
data = [1, 2, 3]
from numpy import VisibleDeprecationWarning

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
r = list(resample(data, 10))
assert np.shape(r) == (10, 3)

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
resample(data, 10, "balanced")

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(ValueError):
resample(data, 10, "foo")

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
resample(data, 10, "balanced", [1, 1, 2])

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(ValueError):
resample(data, 10, "balanced", [1, 1])

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
resample(data, 10, "balanced", [1, 1, 2], rng)

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
resample(data, 10, "balanced", [1, 1, 2], 1)

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(TypeError):
resample(data, 10, "balanced", [1, 1, 2], 1.3)

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(ValueError): # too many arguments
resample(data, 10, "balanced", [1, 1, 2], 1, 2)


def test_confidence_interval_deprecation(rng):
from numpy import VisibleDeprecationWarning

d = [1, 2, 3]
with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
r = confidence_interval(np.mean, d, 0.6, random_state=1)
assert_equal(r, confidence_interval(np.mean, d, cl=0.6, random_state=1))

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
r = confidence_interval(np.mean, d, 0.6, "percentile", random_state=1)
assert_equal(
r,
confidence_interval(np.mean, d, cl=0.6, ci_method="percentile", random_state=1),
)

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(ValueError):
confidence_interval(np.mean, d, 0.6, "percentile", 1)

Expand Down
5 changes: 2 additions & 3 deletions tests/test_jackknife.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,13 @@ def test_resample_several_args_incompatible_keywords():

def test_resample_deprecation():
data = [1, 2, 3]
from numpy import VisibleDeprecationWarning

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
r = list(resample(data, False))

assert_equal(r, list(resample(data, copy=False)))

with pytest.warns(VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
with pytest.raises(ValueError): # too many arguments
resample(data, True, 1)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ def test_usp_bad_input():
def test_usp_deprecrated():
w = [[1, 2, 3], [4, 5, 6]]
r1 = perm.usp(w, method="boyett", size=100, random_state=1)
with pytest.warns(np.VisibleDeprecationWarning):
with pytest.warns(FutureWarning):
r2 = perm.usp(w, method="shuffle", size=100, random_state=1)
assert r1.statistic == r2.statistic

Expand Down
Loading