Skip to content

Comments

Improve error handling and messages in BaseArray#281

Open
ShivamRajSri wants to merge 2 commits intoarviz-devs:mainfrom
ShivamRajSri:refactor-array-axis-handling
Open

Improve error handling and messages in BaseArray#281
ShivamRajSri wants to merge 2 commits intoarviz-devs:mainfrom
ShivamRajSri:refactor-array-axis-handling

Conversation

@ShivamRajSri
Copy link

@ShivamRajSri ShivamRajSri commented Jan 9, 2026

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.

@read-the-docs-community
Copy link

Documentation build overview

📚 arviz-stats | 🛠️ Build #30943105 | 📁 Comparing 2aff446 against latest (4f478ea)


🔍 Preview build

Show files changed (10 files in total): 📝 10 modified | ➕ 0 added | ➖ 0 deleted
File Status
api/generated/arviz_stats.bayes_factor.html 📝 modified
api/generated/arviz_stats.eti.html 📝 modified
api/generated/arviz_stats.hdi.html 📝 modified
api/generated/arviz_stats.histogram.html 📝 modified
api/generated/arviz_stats.kde.html 📝 modified
api/generated/arviz_stats.loo_kfold.html 📝 modified
api/generated/arviz_stats.loo_pit.html 📝 modified
api/generated/arviz_stats.loo_score.html 📝 modified
api/generated/arviz_stats.mode.html 📝 modified
api/generated/arviz_stats.qds.html 📝 modified

Copy link
Member

@OriolAbril OriolAbril left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

if range.shape[:-1] != broadcased_shape:
raise ValueError(
"`range` has incompatible shape. "
f"Expected shape (*, 2) with leading dimensions {broadcased_shape}, "
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can build the whole expected shape here so it is clearer instead of the *, 2 then showing the leading dimensions

@ShivamRajSri ShivamRajSri changed the title Refactor: simplify axis handling in BaseArray array interface Improve error handling and messages in BaseArray Feb 15, 2026
@ShivamRajSri
Copy link
Author

Sorry for the delayed response @OriolAbril I completely missed your comment last week.
I’ve now updated the implementation by replacing the internal assert statements with explicit ValueError checks and clearer error messages, as suggested. This makes the validation more robust and avoids relying on assertions that could be skipped in optimized runs.
Please let me know if you’d like any further adjustments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants