-
Notifications
You must be signed in to change notification settings - Fork 139
Add dprint shortcut to FunctionGraph and Function #779
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
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 | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -1106,6 +1106,18 @@ def sync_shared(self): | |||||||||||||||||||||||||
# NOTE: sync was needed on old gpu backend | ||||||||||||||||||||||||||
pass | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
def dprint(self, **kwargs): | ||||||||||||||||||||||||||
"""Debug print itself | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Parameters | ||||||||||||||||||||||||||
---------- | ||||||||||||||||||||||||||
kwargs: | ||||||||||||||||||||||||||
Optional keyword arguments to pass to debugprint function. | ||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||
from pytensor.printing import debugprint | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
return debugprint(self, **kwargs) | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
Comment on lines
+1109
to
+1120
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. I have mixed feelings about this solution since this paradigm is quite rare, but perhaps it shouldn't be.
Suggested change
I think this does everything cleanly, but I haven't tested it. 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. Does this call the function with self as the first argument? 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. On class instances, yes. 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. Thats 🤯 haha |
||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
# pickling/deepcopy support for Function | ||||||||||||||||||||||||||
def _pickle_Function(f): | ||||||||||||||||||||||||||
|
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.
In general do you know of an elegant way to copy over docstrings? It'd be nice if we could see the full dprint docstring, but only if we don't have to re-copy it in every helper method.
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.
I don't know a way but I suspect there might be one.
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.
Internet shows stuff with assigning
.__doc__
variables. Feels a bit hacky to me but maybe it's conventional. Checking if @OriolAbril has any input hereThere 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.
I have seen and used copying things over and setting the
.__doc__
attribute manually, I don't think there is anything wrong with it