Skip to content

[hist] Check arguments in axis constructors #19483

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hahnjo
Copy link
Member

@hahnjo hahnjo commented Jul 31, 2025

Also test ComputeLinearizedIndex exactly on the edges (this already worked since #19334).

@hahnjo hahnjo requested review from jblomer and siliataider July 31, 2025 08:53
@hahnjo hahnjo self-assigned this Jul 31, 2025
@hahnjo hahnjo added the in:Hist label Jul 31, 2025
Copy link

github-actions bot commented Jul 31, 2025

Test Results

    21 files      21 suites   3d 9h 15m 16s ⏱️
 3 223 tests  3 215 ✅   0 💤 8 ❌
65 960 runs  65 808 ✅ 144 💤 8 ❌

For more details on these failures, see this check.

Results for commit f3796f3.

♻️ This comment has been updated with latest results.

Copy link
Contributor

@siliataider siliataider left a comment

Choose a reason for hiding this comment

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

Looks much better!

/// \param[in] enableFlowBins whether to enable underflow and overflow bins
RVariableBinAxis(std::vector<double> binEdges, bool enableFlowBins = true)
: fBinEdges(std::move(binEdges)), fEnableFlowBins(enableFlowBins)
{
// FIXME: should validate that fBinEdges is sorted
if (fBinEdges.size() < 2) {
throw std::invalid_argument("must have >= 2 edges");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
throw std::invalid_argument("must have >= 2 edges");
throw std::invalid_argument("must have >= 2 edges, but has " + std::to_string(fBinEdges.size()));

/// \param[in] enableFlowBins whether to enable underflow and overflow bins
RRegularAxis(std::size_t numNormalBins, double low, double high, bool enableFlowBins = true)
: fNumNormalBins(numNormalBins), fLow(low), fHigh(high), fEnableFlowBins(enableFlowBins)
{
// FIXME: should validate numNormalBins > 0 and low < high
if (numNormalBins == 0) {
throw std::invalid_argument("numNormalBins must be > 0");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
throw std::invalid_argument("numNormalBins must be > 0");
throw std::invalid_argument("numNormalBins=" + std::to_string(numNormalBins) + " must be > 0");

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't think we need this: numNormalBins is unsigned, so the only value that triggers this exception is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants