-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
adding meaningful str representations to PyMC3 objects #4076
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4076 +/- ##
==========================================
+ Coverage 88.29% 88.64% +0.35%
==========================================
Files 88 88
Lines 13860 13881 +21
==========================================
+ Hits 12237 12305 +68
+ Misses 1623 1576 -47
|
Love the new print output! Why can't we overload |
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.
Looks good to me -- as you said, touches a lot of code, so it'll be good to have it on master and collect bug reports for a while.
@twiecki, I think the problem with just using str
everywhere is that this function also handles theano tensors (but I could be wrong)?
I think in principle it would be possible to keep using |
Co-authored-by: Marco Gorelli <m.e.gorelli@gmail.com>
Anyone interested in pulling the trigger here? ;) @twiecki @ColCarroll |
Thanks @Spaak! |
This is the second PR of three as discussed in #3956 (and likely the one that should get closest attention).
This PR adds semantically meaningful implementations of
__str__
to allDistribution
,Model
, andPyMC3Variable
instances, mirroring the already existing functionality for rendering such objects as LaTeX in the context of jupyter notebooks.Specifically:
etc.
Of special attention here is that in several places throughout the code
str(var)
was used to get the name of a variable, for use e.g. in adict
. I've replaced these uses with a newget_var_name
function that delegates toTensorVariable.__str__
. After merging this PR, future cases where a variable name is required should useget_var_name
instead ofstr
.@twiecki @ColCarroll