Repository navigation
refactor(core): consistent names and public homes for hmf.core APIs - #422
steven-murray wants to merge 1 commit into
Conversation
- Transfer.power_kernel(species) -> Transfer.power_source(species): it returns a PowerSource. UnnormalisedPower.power_kernel(k) keeps its name. - hmf.core._species -> hmf.core.species, a public module with a numpydoc module docstring, listed with the conventions in docs/api_core.rst. It is the one home of the species constants: transfer_models and _boltzmann no longer list MATTER_SPECIES / Species in __all__. - Filter.window_derivatives -> Filter.window_derivatives_kernel (all filters). - The fits' private _parameters stay private (only their own _fsigma calls them); their docstrings no longer promise library use. - BBKS.shape_parameter returns a Quantity in h/Mpc through unit_boundary; solve() uses the plain-float _shape_parameter. - import hmf.core imports and lists every public module (cache, growth, growth_models, species, transfer, transfer_models added). hmf.core is bound on hmf before the submodules import, so growth's qualified annotations resolve during package import. import hmf still does not import hmf.core. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016tGMit4S1Xx7EoWNBYHZsF
|
Sorry @steven-murray, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 2 days and 17 hours by commenting |
Reviewer's GuideThis refactor standardizes v4 core API names, establishes Sequence diagram for unit-aware BBKS shape parametersequenceDiagram
participant Caller
participant BBKS
participant UnitBoundary
participant Solve
Caller->>BBKS: shape_parameter(cosmology)
BBKS->>BBKS: _shape_parameter(cosmology)
BBKS-->>UnitBoundary: return float Gamma
UnitBoundary-->>Caller: return Quantity in h_Mpc
Solve->>BBKS: _shape_parameter(cosmology)
BBKS-->>Solve: return plain float Gamma
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #422 +/- ##
=======================================
Coverage 99.57% 99.57%
=======================================
Files 59 59
Lines 7210 7215 +5
=======================================
+ Hits 7179 7184 +5
Misses 31 31 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary
Renames and visibility changes in
hmf.core(the experimental v4 preview). The maintainer approved them. There are no deprecation aliases, and numbers come out identical. This PR changes no v3 code.Renames (old → new)
Transfer.power_kernel(species)Transfer.power_source(species). It returns aPowerSource, not an array.UnnormalisedPower.power_kernel(k)keeps its name because it is a real plain-array kernel.hmf.core._specieshmf.core.speciesFilter.window_derivatives(andTopHat/SharpK/SmoothK)Filter.window_derivatives_kernelVisibility changes
hmf.core.speciesis public. It has a numpydoc module docstring with an example.docs/api_core.rstlists it under Conventions, the "Shared helpers (internal)" section is removed, anddocs/core.rstlinks to it.transfer_modelsand_boltzmannimport fromspeciesand no longer listMATTER_SPECIESorSpeciesin__all__. A test enforces this._parametersstay private. Nothing outsidefits.pycalls them; each fit's own_fsigmais the only caller. Their docstrings no longer say "for library code".BBKS.shape_parameterreturns a scalar Quantity inh_Mpcthroughunit_boundary(returns=h_Mpc).solve()uses the plain-float_shape_parameter.import hmf.coreimports every public module and lists it in__all__. The newly added ones arecache,growth,growth_models,species,transferandtransfer_models, soimport hmf.core; hmf.core.transfernow works.growth.pyannotates with qualified names (hmf.core.transfer.Transfer), which keeps the docs cross-reference unambiguous next to the v3Transfer. attrs resolves those annotations while the class is being created, which now happens during the package import. Sohmf/core/__init__.pybindshmf.coreonhmfbefore it imports the submodules.growth.pyitself is unchanged.import hmfstill doesn't importhmf.core.hmf.coreimports no CAMB or CLASS module at module level. Importing it takes about 0.25 s on top ofimport hmf. CAMB still shows up insys.modules, but v3'simport hmfloads it.Open point (not changed here)
Filter.window_derivatives_kernelnow follows the naming convention. It does not check its input againstvalid_domain;windowanddwindow_dlnxdo that check. Adding the check would change behaviour onMassVariance's hot path, which this PR avoids. It isn't flagged bytest_every_public_kernel_has_an_out_of_domain_caseeither, because that test doesn't scanfilters. I'd fix both in a follow-up if you want the convention enforced there.Type of change
Checklist
I have
shape_parametertest (Γ = Ω_m0·h with no baryons, the Sugiyama forms agree at h = 0.5, unit and scalar checks);__all__);Local checks:
prekon the changed files passes.uv run mypy(strict) passes.tests/core+tests/regression: 1791 passed, 13 skipped.benchmarks/test_gates.py: 18 passed.-Wpasses.🤖 Generated with Claude Code
https://claude.ai/code/session_016tGMit4S1Xx7EoWNBYHZsF
Generated by Claude Code
Summary by Sourcery
Align the experimental
hmf.coreAPI with consistent public naming, module visibility, and unit behavior.Enhancements:
hmf.coreand keep shared species constants in their single public home.Documentation:
Tests:
Chores: