Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Implements issue #216 by shifting additive bias handling from field-map creation to angular power spectrum computation, using bias “ingredients” stored in dtype metadata to compute (and optionally subtract) the bias at spectrum time.
Changes:
- Compute and attach
biasmetadata insideangular_power_spectra()for auto-spectra usingfsky,musq, anddens. - Stop writing precomputed
biasinto mapped field metadata; retain only the ingredients needed for later bias computation. - Update/extend tests to reflect the new bias flow and expected metadata.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
heracles/twopoint.py |
Computes auto-spectrum bias from stored ingredients and debiases spectra when requested. |
heracles/fields.py |
Removes precomputed bias from field metadata; stores bias ingredients only. |
tests/test_twopoint.py |
Adds coverage for bias metadata behavior in angular_power_spectra(). |
tests/test_fields.py |
Updates expected mapped-field metadata to no longer include bias. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+259
to
+267
| # compute bias for auto-spectra from ingredients stored during field mapping | ||
| bias = None | ||
| if k1 == k2 and i1 == i2: | ||
| _fsky = md1.get("fsky") | ||
| _musq = md1.get("musq") | ||
| _dens = md1.get("dens") | ||
| if _fsky is not None and _musq is not None and _dens is not None: | ||
| factor = 0.5 if s1 == s2 == 2 else 1.0 | ||
| bias = factor * _fsky * _musq / _dens |
Comment on lines
+166
to
+181
| alms = {("F", 0): a} | ||
| cls = angular_power_spectra(alms, debias=False) | ||
| assert cls["F", "F", 0, 0].dtype.metadata["bias"] == pytest.approx( | ||
| fsky * musq / dens | ||
| ) | ||
|
|
||
| # spin-2 auto: bias = 0.5 * fsky * musq / dens | ||
| b = np.zeros((2, size), dtype=complex) | ||
| b.dtype = np.dtype( | ||
| b.dtype, metadata={"spin": 2, "fsky": fsky, "musq": musq, "dens": dens} | ||
| ) | ||
| alms2 = {("G", 0): b} | ||
| cls2 = angular_power_spectra(alms2, debias=False) | ||
| assert cls2["G", "G", 0, 0].dtype.metadata["bias"] == pytest.approx( | ||
| 0.5 * fsky * musq / dens | ||
| ) |
This was referenced Jul 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes: #216