-
Notifications
You must be signed in to change notification settings - Fork 136
Deprecate redundant utilities for extracting constants #1046
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
Changes from all commits
3b5b35c
b8e7783
21523e7
5b05713
7738267
0b795af
628c321
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1329,7 +1329,7 @@ def try_to_copy_if_needed(var): | |
f" {i}. Since this input is only connected " | ||
"to integer-valued outputs, it should " | ||
"evaluate to zeros, but it evaluates to" | ||
f"{pytensor.get_underlying_scalar_constant(term)}." | ||
f"{pytensor.get_underlying_scalar_constant_value(term)}." | ||
) | ||
raise ValueError(msg) | ||
|
||
|
@@ -2157,6 +2157,9 @@ def _is_zero(x): | |
'maybe' means that x is an expression that is complicated enough | ||
that we can't tell that it simplifies to 0. | ||
""" | ||
from pytensor.tensor import get_underlying_scalar_constant_value | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why does this need a local import here but not in the above function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the other is using it through tensor. This was not done on purpose but I prefer explicit imports and there is in fact a circular dependency here. |
||
from pytensor.tensor.exceptions import NotScalarConstantError | ||
|
||
if not hasattr(x, "type"): | ||
return np.all(x == 0.0) | ||
if isinstance(x.type, NullType): | ||
|
@@ -2166,9 +2169,9 @@ def _is_zero(x): | |
|
||
no_constant_value = True | ||
try: | ||
constant_value = pytensor.get_underlying_scalar_constant(x) | ||
constant_value = get_underlying_scalar_constant_value(x) | ||
no_constant_value = False | ||
except pytensor.tensor.exceptions.NotScalarConstantError: | ||
except NotScalarConstantError: | ||
pass | ||
|
||
if no_constant_value: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the logger instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wdym. Never saw deprecation warnings in logging.