Skip to content

Do not require explicit RNG in verify_grad #1093

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

Merged
merged 1 commit into from
Nov 18, 2024
Merged
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
9 changes: 2 additions & 7 deletions pytensor/gradient.py
Original file line number Diff line number Diff line change
Expand Up @@ -1770,14 +1770,9 @@
if rel_tol is None:
rel_tol = max(_type_tol[str(p.dtype)] for p in pt)

# Initialize RNG if not provided
if rng is None:
raise TypeError(
"rng should be a valid instance of "
"numpy.random.RandomState. You may "
"want to use tests.unittest"
"_tools.verify_grad instead of "
"pytensor.gradient.verify_grad."
)
rng = np.random.default_rng()

Check warning on line 1775 in pytensor/gradient.py

View check run for this annotation

Codecov / codecov/patch

pytensor/gradient.py#L1775

Added line #L1775 was not covered by tests

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