Skip to content

Commit b8e3776

Browse files
committed
fix: use np.exceptions.VisibleDeprecationWarning
Signed-off-by: Henry Schreiner <[email protected]>
1 parent b998ff5 commit b8e3776

File tree

8 files changed

+24
-24
lines changed

8 files changed

+24
-24
lines changed

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ log_cli_level = "INFO"
8787
testpaths = ["tests"]
8888
xfail_strict = true
8989
filterwarnings = [
90-
"error::numpy.VisibleDeprecationWarning",
90+
"error::numpy.exceptions.VisibleDeprecationWarning",
9191
"error::PendingDeprecationWarning",
9292
"error::DeprecationWarning",
9393
"error::FutureWarning",

src/iminuit/_deprecated.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import warnings
2-
from numpy import VisibleDeprecationWarning
2+
from numpy.exceptions import VisibleDeprecationWarning
33

44

55
class deprecated:

src/iminuit/cost.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,7 +1754,7 @@ def __init__(
17541754
if method == "hpd":
17551755
warnings.warn(
17561756
"key 'hpd' is deprecated, please use 'da' instead",
1757-
category=np.VisibleDeprecationWarning,
1757+
category=np.exceptions.VisibleDeprecationWarning,
17581758
stacklevel=2,
17591759
)
17601760

@@ -2504,7 +2504,7 @@ def __getattr__(name: str) -> Any:
25042504
new_name, obj = _deprecated_content[name]
25052505
warnings.warn(
25062506
f"{name} was renamed to {new_name}, please import {new_name} instead",
2507-
np.VisibleDeprecationWarning,
2507+
np.exceptions.VisibleDeprecationWarning,
25082508
stacklevel=2,
25092509
)
25102510
return obj

tests/test_cost.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ def test_UnbinnedNLL_visualize(log):
321321
c.visualize((1, 2), model_points=np.linspace(1, 1000))
322322

323323
with pytest.warns(
324-
np.VisibleDeprecationWarning, match="keyword 'nbins' is deprecated"
324+
np.exceptions.VisibleDeprecationWarning, match="keyword 'nbins' is deprecated"
325325
):
326326
c.visualize((1, 2), nbins=20)
327327

@@ -1909,23 +1909,23 @@ def test_Template_pulls():
19091909
def test_deprecated():
19101910
from iminuit import cost
19111911

1912-
with pytest.warns(np.VisibleDeprecationWarning):
1912+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
19131913
from iminuit.cost import BarlowBeestonLite
19141914
assert BarlowBeestonLite is cost.Template
19151915

1916-
with pytest.warns(np.VisibleDeprecationWarning):
1916+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
19171917
from iminuit.cost import barlow_beeston_lite_chi2_jsc
19181918
assert barlow_beeston_lite_chi2_jsc is cost.template_chi2_jsc
19191919

1920-
with pytest.warns(np.VisibleDeprecationWarning):
1920+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
19211921
from iminuit.cost import barlow_beeston_lite_chi2_hpd
19221922
assert barlow_beeston_lite_chi2_hpd is cost.template_chi2_da
19231923

19241924

19251925
def test_deprecated_Template_method():
19261926
from iminuit import cost
19271927

1928-
with pytest.warns(np.VisibleDeprecationWarning):
1928+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
19291929
t = Template([1], [2, 3], [[1], [2]], method="hpd")
19301930
t._impl is cost.template_chi2_da
19311931

@@ -1967,7 +1967,7 @@ def cdf(xye, a):
19671967
def test_BohmZechTransform():
19681968
from iminuit.cost import BohmZechTransform
19691969

1970-
with pytest.warns(np.VisibleDeprecationWarning):
1970+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
19711971
val = np.array([1.0, 2.0])
19721972
var = np.array([3.0, 4.0])
19731973
tr = BohmZechTransform(val, var)

tests/test_deprecated.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def test_deprecated_func():
88
def func(x):
99
pass
1010

11-
with pytest.warns(np.VisibleDeprecationWarning, match="func is deprecated: bla"):
11+
with pytest.warns(np.exceptions.VisibleDeprecationWarning, match="func is deprecated: bla"):
1212
func(1)
1313

1414

@@ -20,7 +20,7 @@ def some_function(x, y, foo):
2020
some_function(1, 2, foo=3)
2121

2222
with pytest.warns(
23-
np.VisibleDeprecationWarning,
23+
np.exceptions.VisibleDeprecationWarning,
2424
match="keyword 'bar' is deprecated, please use 'foo'",
2525
):
2626
some_function(1, 2, bar=3)

tests/test_describe.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def __init__(self):
9494
def __call__(self, *args):
9595
pass
9696

97-
with pytest.warns(np.VisibleDeprecationWarning):
97+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
9898
assert describe(A()) == ["x", "y"]
9999

100100

tests/test_minuit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ def test_Func1():
193193

194194

195195
def test_Func2():
196-
with pytest.warns(np.VisibleDeprecationWarning):
196+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
197197
func_test_helper(Func2())
198198

199199

tests/test_util.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -450,12 +450,12 @@ def fcn(y, x):
450450

451451

452452
def test_make_func_code():
453-
with pytest.warns(np.VisibleDeprecationWarning):
453+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
454454
fc = util.make_func_code(["a", "b"])
455455
assert fc.co_varnames == ("a", "b")
456456
assert fc.co_argcount == 2
457457

458-
with pytest.warns(np.VisibleDeprecationWarning):
458+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
459459
fc = util.make_func_code(("x",))
460460
assert fc.co_varnames == ("x",)
461461
assert fc.co_argcount == 1
@@ -530,14 +530,14 @@ def test_propagate_1():
530530
def fn(x):
531531
return 2 * x + 1
532532

533-
with pytest.warns(np.VisibleDeprecationWarning):
533+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
534534
y, ycov = util.propagate(fn, x, cov)
535535
np.testing.assert_allclose(y, [3, 5, 7])
536536
np.testing.assert_allclose(
537537
ycov, [[4, 0.4, 0.8], [0.4, 8, 1.2], [0.8, 1.2, 12]], rtol=1e-3
538538
)
539539

540-
with pytest.warns(np.VisibleDeprecationWarning):
540+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
541541
y, ycov = util.propagate(fn, [1], [[2]])
542542
np.testing.assert_allclose(y, 3)
543543
np.testing.assert_allclose(ycov, 8, rtol=1e-3)
@@ -557,15 +557,15 @@ def test_propagate_2():
557557
def fn(x):
558558
return np.dot(a, x)
559559

560-
with pytest.warns(np.VisibleDeprecationWarning):
560+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
561561
y, ycov = util.propagate(fn, x, cov)
562562
np.testing.assert_equal(y, fn(x))
563563
np.testing.assert_allclose(ycov, np.einsum("ij,kl,jl", a, a, cov), rtol=1e-3)
564564

565565
def fn(x):
566566
return np.linalg.multi_dot([x.T, cov, x])
567567

568-
with pytest.warns(np.VisibleDeprecationWarning):
568+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
569569
y, ycov = util.propagate(fn, x, cov)
570570
np.testing.assert_equal(y, fn(np.array(x)))
571571
jac = 2 * np.dot(cov, x)
@@ -585,7 +585,7 @@ def test_propagate_3():
585585
def fn(x):
586586
return 2 * x + 1
587587

588-
with pytest.warns(np.VisibleDeprecationWarning):
588+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
589589
y, ycov = util.propagate(fn, x, cov)
590590
np.testing.assert_allclose(y, [3, 5, 7])
591591
np.testing.assert_allclose(ycov, [[4, 0.0, 0.8], [0.0, 0.0, 0.0], [0.8, 0.0, 12]])
@@ -599,16 +599,16 @@ def test_propagate_on_bad_input():
599599
def fn(x):
600600
return 2 * x + 1
601601

602-
with pytest.warns(np.VisibleDeprecationWarning):
602+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
603603
with pytest.raises(ValueError):
604604
util.propagate(fn, x, cov)
605605

606-
with pytest.warns(np.VisibleDeprecationWarning):
606+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
607607
with pytest.raises(ValueError):
608608
util.propagate(fn, x, 1)
609609

610610
cov = [[1.0], [1.0]]
611-
with pytest.warns(np.VisibleDeprecationWarning):
611+
with pytest.warns(np.exceptions.VisibleDeprecationWarning):
612612
with pytest.raises(ValueError):
613613
util.propagate(fn, x, cov)
614614

0 commit comments

Comments
 (0)