Skip to content

fix: best practices and cleanups from automated review#1118

Open
henryiii wants to merge 3 commits into
developfrom
henryiii/fix/best-practices-cleanups
Open

fix: best practices and cleanups from automated review#1118
henryiii wants to merge 3 commits into
developfrom
henryiii/fix/best-practices-cleanups

Conversation

@henryiii
Copy link
Copy Markdown
Member

🤖 Human triggerd, AI assisted PR. AI text below. 🤖

Addresses the Best Practices & Cleanups section of #1115.

Python fixes

  • numpy.py: Replaced mutable default storage=_storage.Double() with storage=None + lazy init in histogramdd() and histogram2d()
  • axis/init.py: Fixed AxesTuple.index return type from tuple[float, ...] to tuple[int, ...]
  • _compat/typing.py: Changed Self = object fallback to Self = typing.Any (more semantically correct)

C++ fixes

  • register_axis.hpp: Removed duplicate BHP_NOEXCEPT_17 macro definition (lines 43-47)
  • accumulators/mean.hpp: Added division-by-zero guard in variance() — returns NaN when count <= 1
  • accumulators/weighted_mean.hpp: Added division-by-zero guard in variance() — returns NaN when denominator <= 0

Test cleanups

  • Removed print() debug statements from test_histogram.py and test_histogram_indexing.py
  • Removed commented-out dead test_hist_division code (from 2020)
  • Made TestBoolean inherit from Axis ABC for structural test coverage
  • Added hypothesis.settings(deadline=None) to test_pbt.py and test_accumulators.py

Skipped

  • rebin.__init__ validation: Investigated but existing logic is correct — axis alongside groups/edges is a valid use case (confirmed by existing tests)
  • using namespace pybind11::literals in header: Too many usages across the C++ codebase to safely refactor in this PR

Closes #1115 (best practices portion)

Assisted-by: OpenCode:GLM-5

- Replace mutable default storage args in numpy.py with None + lazy init
- Fix AxesTuple.index return type from tuple[float,...] to tuple[int,...]
- Fix Self = object fallback to Self = typing.Any in _compat/typing.py
- Remove duplicate BHP_NOEXCEPT_17 macro in register_axis.hpp
- Guard division by zero in mean.hpp and weighted_mean.hpp variance()
- Remove leftover print() debug statements in test files
- Remove commented-out dead test_hist_division code
- Make TestBoolean inherit from Axis ABC for structural coverage
- Add hypothesis.settings(deadline=None) to property-based test files

Assisted-by: OpenCode:GLM-5
@github-actions github-actions Bot added the needs changelog Might need a changelog entry label May 13, 2026
henryiii and others added 2 commits May 18, 2026 20:41
Assisted-by: CopilotCLI:glm-5.1
Signed-off-by: Henry Schreiner <henryfs@princeton.edu>
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.

AI review (bugs, perf, simp, best practices)

1 participant