Improve error handling and messages in BaseArray#281
Improve error handling and messages in BaseArray#281ShivamRajSri wants to merge 2 commits intoarviz-devs:mainfrom
Conversation
Documentation build overview
Show files changed (10 files in total): 📝 10 modified | ➕ 0 added | ➖ 0 deleted
|
OriolAbril
left a comment
There was a problem hiding this comment.
The PR title is extremely scary, luckily the actual changes have nothing to do with it or with the PR description. Please update it.
Clearer error messages is usually a good idea
src/arviz_stats/base/array.py
Outdated
| if range.shape[:-1] != broadcased_shape: | ||
| raise ValueError( | ||
| "`range` has incompatible shape. " | ||
| f"Expected shape (*, 2) with leading dimensions {broadcased_shape}, " |
There was a problem hiding this comment.
we can build the whole expected shape here so it is clearer instead of the *, 2 then showing the leading dimensions
|
Sorry for the delayed response @OriolAbril I completely missed your comment last week. |
This PR replaces a couple of internal assert statements in BaseArray with explicit ValueError checks and clearer error messages.
The goal is to make the validation more robust (since assert can be disabled in optimized runs) and to provide more informative errors to users when inputs have incompatible shapes or axes.
There are no functional changes — just safer validation and clearer error handling.