Clarify dimensions issues in generate_dims_coords
See original GitHub issueIn data/base.py
in generate_dims_coords()
this warning may be emitted:
if len([dim for dim in dims if dim not in default_dims]) > len(shape):
warnings.warn(
"More dims ({dims_len}) given than exists ({shape_len}). "
"Passed array should have shape (chains, draws, *shape)".format(
dims_len=len(dims), shape_len=len(shape)
),
SyntaxWarning,
)
This is problematic because
- It’s only a warning, so we can’t get into the debugger to see what’s wrong
- The warning information is insufficient. At the very least, the
var_name
argument should be added to the warning string, but I think thedims
should be supplied as well.
One more thing if you are looking at this function.
The docstring says
default_dims : list[str]
Dimensions that do not apply to the variable's shape
In what way are dimensions relevant if they don’t apply to the variable’s shape?
Later it says:
-------
list[str]
Default dims
dict[str] -> list[str]
Default coords
This seems to contradict the above definition of “default,” since surely this function isn’t going to return the irrelevant dimensions!
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
The behavior of excluded dimensions needs clarified. #2478
The behavior of excluded dimensions needs clarified. #2478. Open. drcrallen opened this issue on Feb 16, 2016 · 1 comment.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Yes, that is correct. But, again, shouldn’t this be an error, instead of a warning? Maybe a
ValueError
? I guess since we can muscle our way through, but give uglier output, a warning is OK?Yes, confirmed.
I agree that the function argument names are not very intuitive and the docstring is not 100% clear, we can discuss here on different names and explanation and then modify the docstring and or arguments.
I have pushed #793 for this that we can discuss. It includes a fix to the warning message (maybe we could work out together a test case to make sure I’m handing
None
properly, etc?).I think we can call it fixed in the warning above. We can potentially return to it later.