-
-
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
Bugfixes to increase robustness against unnamed dims
#6339
Conversation
# TODO: Evaluate all RV shapes and dim_length at once. | ||
# This should help to find discrepancies, and | ||
# avoids unncessary function compiles for deetermining labels. | ||
|
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.
This is not needed for the bugfix, but I commented it here for the next person touching this code.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #6339 +/- ##
=======================================
Coverage 94.14% 94.15%
=======================================
Files 132 132
Lines 26714 26726 +12
=======================================
+ Hits 25150 25163 +13
+ Misses 1564 1563 -1
|
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.
LGTM except one line.
pymc/model.py
Outdated
@@ -1507,7 +1509,7 @@ def add_named_variable(self, var, dims: Optional[Tuple[Union[str, None], ...]] = | |||
for dim in dims: | |||
if dim not in self.coords and dim is not None: | |||
raise ValueError(f"Dimension {dim} is not specified in `coords`.") | |||
if any(var.name == dim for dim in dims): | |||
if any(var.name == dim != None for dim in dims): |
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.
if any(var.name == dim != None for dim in dims): | |
if any(var.name == dim for dim in dims if dim is not None): |
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.
My code worked too, but OK let's have it your way ;)
62906bf
to
01fb0a8
Compare
* Extract `ModelGraph._eval` to a function * More robustness against unlabeled `dims` entries Closes pymc-devs#6335
* Extract `ModelGraph._eval` to a function * More robustness against unlabeled `dims` entries Closes pymc-devs#6335
* Extract `ModelGraph._eval` to a function * More robustness against unlabeled `dims` entries Closes pymc-devs#6335
This fixes the two bugs I described in #6335.
Essentially two
Model.get_plates
andModel.add_named_variable
methods did not anticipate that elements of adims
tuple can beNone
.I added some comments to the refactored code and tests.
Checklist
Major / Breaking Changes
Bugfixes / New features
pm.model_to_graphviz
andModel.add_named_variable
that were triggered byNone
elements indims
tuples.Docs / Maintenance