Skip to content

Commit d12bd2b

Browse files
committed
Adjust changes for v2 only
1 parent 480cf49 commit d12bd2b

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

MIGRATION_V1_V2.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ should be used as a checklist when converting a piece of code using PyLops from
88
- XX
99
- XX
1010
- XX
11+
12+
- `utils.dottest`: The relative tolerance is new set via `rtol` (before `tol`), and absolute tolerance is new supported via the keyword `atol`. When calling it with purely positional arguments, note that after `rtol` comes now first `atol` before `complexflag`. When using `raiseerror=True` it now emits an `AttributeError` instead of a `ValueError`.

pylops/utils/dottest.py

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import warnings
21
import numpy as np
32

43
from pylops.utils.backend import get_module, to_numpy
@@ -14,7 +13,6 @@ def dottest(
1413
raiseerror=True,
1514
verb=False,
1615
backend="numpy",
17-
tol=None, # deprecated, use rtol
1816
):
1917
r"""Dot test.
2018
@@ -53,15 +51,11 @@ def dottest(
5351
backend : :obj:`str`, optional
5452
Backend used for dot test computations (``numpy`` or ``cupy``). This
5553
parameter will be used to choose how to create the random vectors.
56-
tol : :obj:`float`, optional
57-
Dottest tolerance
58-
.. deprecated:: 2.0.0
59-
Use ``rtol`` instead.
6054
6155
Raises
6256
------
63-
ValueError
64-
If dot-test is not verified within chosen tolerance.
57+
AssertionError
58+
If dot-test is not verified within chosen tolerances.
6559
6660
Notes
6761
-----
@@ -77,14 +71,6 @@ def dottest(
7771
\mathbf{u}^H(\mathbf{Op}^H\mathbf{v})
7872
7973
"""
80-
if tol is not None:
81-
warnings.warn(
82-
"tol will be deprecated in version 2.0.0, use rtol instead.",
83-
category=DeprecationWarning,
84-
stacklevel=2,
85-
)
86-
rtol = tol
87-
8874
ncp = get_module(backend)
8975

9076
if nr is None:
@@ -125,10 +111,13 @@ def dottest(
125111
# evaluate if dot test passed
126112
passed = np.isclose(xx, yy, rtol, atol)
127113

128-
if not passed and raiseerror:
129-
raise ValueError(f"Dot test failed, v^H(Opu)={yy} - u^H(Op^Hv)={xx}")
130-
elif verb:
114+
# verbosity or error raising
115+
if (not passed and raiseerror) or verb:
131116
passed_status = "passed" if passed else "failed"
132-
print(f"Dot test {passed_status}, v^H(Opu)={yy} - u^H(Op^Hv)={xx}")
117+
msg = f"Dot test {passed_status}, v^H(Opu)={yy} - u^H(Op^Hv)={xx}"
118+
if not passed and raiseerror:
119+
raise AssertionError(msg)
120+
else:
121+
print(msg)
133122

134123
return passed

0 commit comments

Comments
 (0)