Release v1 - #127
Conversation
Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/1d28fa57-8efb-4ffb-b427-4dcb340d2c40 Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
…ming Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/1d28fa57-8efb-4ffb-b427-4dcb340d2c40 Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/1d28fa57-8efb-4ffb-b427-4dcb340d2c40 Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
…avg/nsamples, direct unpacking Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/fcda9785-3c10-45f8-82b9-4e6616d49363 Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/5b6a258c-4231-4e94-ae8d-84052213d68a Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/15a8441c-0bcc-405e-bc99-006c3c75d658 Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
for more information, see https://pre-commit.ci
…power-special-class Add `PowerSpectrum` return type for `get_power`
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Reviewer's GuideIntroduce a structured PowerSpectrum result object for get_power, refactor get_power to return this dataclass with consistent bin metadata, improve numerical robustness of bin averaging, and update tests and docs to use the new API and behavior. Sequence diagram for get_power constructing PowerSpectrumsequenceDiagram
actor User
participant ToolsModule
participant AngularAverage
participant PowerSpectrum
User->>ToolsModule: get_power(field, boxlength, parameters)
ToolsModule->>ToolsModule: compute_freq_and_kmag(field, boxlength, dim)
ToolsModule->>ToolsModule: resolve_bins_upto_boxlen(bins, kmag)
ToolsModule->>ToolsModule: bin_edges = _getbins(bins, kmag, log_bins, bins_upto_boxlen)
ToolsModule->>ToolsModule: bin_centres = compute_bin_centres(bin_edges, log_bins)
ToolsModule->>AngularAverage: angular_average_nd(P, coords, bin_edges, bin_ave=True, get_variance, log_bins, weights, interpolation_method, interp_points_generator, bins_upto_boxlen)
AngularAverage-->>ToolsModule: power, bin_avg, variance, nsamples
ToolsModule->>ToolsModule: apply_shotnoise_correction_if_needed(power)
ToolsModule->>ToolsModule: collapse_partial_average_axes(bin_avg, nsamples, res_ndim, dim)
ToolsModule->>PowerSpectrum: __init__(power, bin_edges, bin_centres, bin_avg, nsamples, variance, k_unbinned)
PowerSpectrum->>PowerSpectrum: __post_init__() validate shapes
PowerSpectrum-->>ToolsModule: validated_instance
ToolsModule-->>User: PowerSpectrum instance
Class diagram for PowerSpectrum and get_power result structureclassDiagram
class PowerSpectrum {
+np.ndarray power
+np.ndarray bin_edges
+np.ndarray bin_centres
+np.ndarray bin_avg
+np.ndarray nsamples
+np.ndarray variance
+tuple k_unbinned
+__post_init__()
}
class ToolsModule {
+PowerSpectrum get_power(field, boxlength, N, bins, dim, res_ndim, log_bins, get_variance, remove_shotnoise, bins_upto_boxlen)
+tuple angular_average_nd(field, coords, bins, bin_ave, get_variance, log_bins, weights, interpolation_method, interp_points_generator, bins_upto_boxlen)
}
ToolsModule --> PowerSpectrum : returns
ToolsModule --> PowerSpectrum : validates via __post_init__
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
@copilot resolve the merge conflicts in this pull request |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #127 +/- ##
==========================================
+ Coverage 94.54% 95.02% +0.47%
==========================================
Files 5 12 +7
Lines 605 1206 +601
==========================================
+ Hits 572 1146 +574
- Misses 33 60 +27
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- The
get_powerAPI has changed quite significantly (removedbin_ave/return_sumweights, changed return type from tuple toPowerSpectrum), which is a breaking change; consider adding a backwards-compatible shim or deprecation period (e.g., optional flag returning the old tuple form) to avoid silently breaking existing users. - The
FutureWarningmessage inget_poweris built from adjacent string literals ("box." "Set bins_upto_boxlen..."), which currently concatenates as"box.Set ..."; add a trailing space to the first literal or a leading space to the second to fix the wording. - In
agents.md, the command hintuv sync"has a stray closing quote; remove the extra"so the instruction renders correctly.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `get_power` API has changed quite significantly (removed `bin_ave`/`return_sumweights`, changed return type from tuple to `PowerSpectrum`), which is a breaking change; consider adding a backwards-compatible shim or deprecation period (e.g., optional flag returning the old tuple form) to avoid silently breaking existing users.
- The `FutureWarning` message in `get_power` is built from adjacent string literals (`"box." "Set bins_upto_boxlen..."`), which currently concatenates as `"box.Set ..."`; add a trailing space to the first literal or a leading space to the second to fix the wording.
- In `agents.md`, the command hint `uv sync"` has a stray closing quote; remove the extra `"` so the instruction renders correctly.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
…rface Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… test helper Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/8fcd2de8-a582-4138-bd26-8e07cf793deb Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Agent-Logs-Url: https://github.com/steven-murray/powerbox/sessions/8fcd2de8-a582-4138-bd26-8e07cf793deb Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
…I conflict Co-authored-by: steven-murray <1272030+steven-murray@users.noreply.github.com>
Fix odd-grid inverse FFT phase handling
Allow PowerBox and LogNormalPowerBox to accept per-axis N and boxlength values while preserving existing scalar workflows. Add regression coverage for non-cubic power recovery and mixed odd/even Hermitian handling, and document cuboid usage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover the remaining cuboid PowerBox branches so the PR clears coverage gates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add cuboid PowerBox support
- add powerbox.jax API surface and JAX FFT backend wiring - migrate gaussian/lognormal field generation to reduced-spectrum paths - expand regression coverage for tuple/reduced-spectrum behavior and JAX lognormal identities - update backend benchmarks/docs and regenerate benchmark artifacts - enable pyFFTW interface cache and benchmark with single-thread FFTW Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- fix default Lk initialization in dft.ifft and dft.irfft when no box lengths are passed - add focused JAX tests for dft wrappers, validation branches, and tool edge cases to raise patch coverage Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- exercise default/scalar length branches in dft fft/ifft/irfft wrappers - add focused JAX tooling validation tests for PowerSpectrum and helper branch paths - keep warning-producing branches explicit under pytest warning assertions Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add JAX backend + reduced-spectrum refactor and benchmarks
Release v1 collection branch.
Summary by Sourcery
Introduce a structured PowerSpectrum result type for get_power and update callers and docs to use it.
New Features:
Enhancements:
Build:
Documentation:
Tests:
Chores: