-
Notifications
You must be signed in to change notification settings - Fork 106
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
Add dprint shortcut to FunctionGraph and Function #779
Conversation
---------- | ||
kwargs: | ||
Optional keyword arguments to pass to debugprint function. | ||
""" |
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 here
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 have seen and used copying things over and setting the .__doc__
attribute manually, I don't think there is anything wrong with it
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #779 +/- ##
=======================================
Coverage 80.85% 80.85%
=======================================
Files 162 162
Lines 47045 47051 +6
Branches 11514 11514
=======================================
+ Hits 38039 38045 +6
- Misses 6750 6753 +3
+ Partials 2256 2253 -3
|
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) | ||
|
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 have mixed feelings about this solution since this paradigm is quite rare, but perhaps it shouldn't be.
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) | |
from pytensor.printing import debugprint |
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 comment
The 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 comment
The 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Thats 🤯 haha
I'm going with the simpler approach here. If anybody wants to tweak docstrings or use @maresb trick feel free to open a new PR |
Description
Follow-up to #729