Skip to content

Commit 00c99f3

Browse files
Mohit Kumart3chw
Mohit Kumar
authored andcommitted
Add test for 'verify_grad' without explicit RNG
1 parent 33a4d48 commit 00c99f3

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

pytensor/gradient.py

+2-7
Original file line numberDiff line numberDiff line change
@@ -1770,14 +1770,9 @@ def verify_grad(
17701770
if rel_tol is None:
17711771
rel_tol = max(_type_tol[str(p.dtype)] for p in pt)
17721772

1773+
# Initialize RNG if not provided
17731774
if rng is None:
1774-
raise TypeError(
1775-
"rng should be a valid instance of "
1776-
"numpy.random.RandomState. You may "
1777-
"want to use tests.unittest"
1778-
"_tools.verify_grad instead of "
1779-
"pytensor.gradient.verify_grad."
1780-
)
1775+
rng = np.random.default_rng()
17811776

17821777
# We allow input downcast in `function`, because `numeric_grad` works in
17831778
# the most precise dtype used among the inputs, so we may need to cast

0 commit comments

Comments
 (0)