-
Notifications
You must be signed in to change notification settings - Fork 121
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
Deprecate ScalarSharedVariable #629
Deprecate ScalarSharedVariable #629
Conversation
91bfe7a
to
ae4fe70
Compare
pytensor/tensor/sharedvar.py
Outdated
def __getattr__(name): | ||
if name == "ScalarSharedVariable": | ||
warnings.warn( | ||
"The class `ScalarSharedVariable` has been deprecated. " | ||
"Use `TensorSharedVariable` instead and check for `ndim==0`.", | ||
FutureWarning, | ||
) | ||
return TensorSharedVariable | ||
|
||
|
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.
very clever!
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.
Oops not clever enough, have to fallback to AttributeError
ae4fe70
to
e82d86c
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #629 +/- ##
=======================================
Coverage 80.82% 80.83%
=======================================
Files 162 162
Lines 46744 46743 -1
Branches 11418 11417 -1
=======================================
+ Hits 37783 37786 +3
+ Misses 6716 6714 -2
+ Partials 2245 2243 -2
|
Description
As explained in the related issue this class is messy because it internally upcasts the values to 0d arrays, so that
shared(shared(5).get_value())
belongs to a different class thanshared(5)
but are exactly the same objects otherwise!This was a source of bugs in PyMC. The way you create an object shouldn't matter for type checks, only what you actually ended up creating!
There is a proper ScalarSharedVariable if someone really wants to work with scalar types
Related Issue
tensor.ScalarSharedVariable
#396Checklist
Type of change