Repository navigation
Clarify typed test fixtures - #698
Open
marcpaterno wants to merge 16 commits into
Open
marcpaterno wants to merge 16 commits into
marcpaterno wants to merge 16 commits into
Conversation
|
PR revision: No breaking API changes detected. PR public API verdictNo breaking API changes detected. Target: Static analysis only: no behavioral compatibility guarantee or external-dependency signature analysis. Public API changes: 15043d4 -> HEADExecutive summaryNo breaking API changes detected. Breaking changesNone. New public APINone. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #698 +/- ##
=======================================
Coverage 100.0% 100.0%
=======================================
Files 163 163
Lines 9979 9979
Branches 1199 1199
=======================================
Hits 9979 9979
🚀 New features to boost your workflow:
|
marcpaterno
marked this pull request as ready for review
October 25, 2026 03:16
Collaborator
|
Hello @marcpaterno , a few things:
|
marcpaterno
force-pushed
the
clarify-test-fixtures
branch
from
October 27, 2026 20:24
7aa3895 to
39c30ed
Compare
Replace the tuple[object, ...] annotation on the sacc_galaxy_xis_lens0_lens0_real consumer with the actual (Sacc, float64, float64) contract matching its producer.
Replace bare np.ndarray tuple annotations with npt.NDArray[np.float64] in the two-point SACC metadata fixtures and their consuming tests. Convert the three-tracer fixture return annotations from parenthesized single-line forms to multi-line tuple forms. Add docstrings describing the fixture and test contracts, replacing the copied "without window functions" fixture descriptions.
Replace the tuple-based sacc_galaxy_cells fixture return with SaccGalaxyHarmonicFixture, which holds sacc_data, distributions, and spectra as frozen dataclasses (SampledRedshiftDistribution and HarmonicAngularPowerSpectrum). Update consumers to read named fields instead of positional indices. Add docstrings to the affected tests. Extend test_extract_all_data_harmonic_no_cov to run against a copy and assert that the shared fixture's covariance is left unchanged.
Replace the tuple-based `sacc_galaxy_xis` and `sacc_galaxy_xis_inverted` fixtures with `SaccGalaxyRealFixture`, which exposes `sacc_data`, `distributions`, and `spectra`. Each measured spectrum is a `RealAngularCorrelation` with `thetas` and `xis` fields instead of a positional pair. Tests now access fields by name and their docstrings describe the expected inputs. test_extract_all_data_real_no_cov now copies the shared SACC object before clearing its covariance. It also asserts that the shared fixture's covariance is unchanged, so the module-scoped fixture is not mutated for later tests.
Replace the tuple-based `SaccGalaxyWindowedFixture` and `WindowedAngularPowerSpectrum` aliases in tests/_types.py with frozen, keyword-only dataclasses. The fixture now exposes `sacc_data`, `distributions`, and `spectra` fields, and each spectrum exposes `support_ells`, `bandpowers`, and `window` instead of positional unpacking. Update conftest.py to build the new records, and update the metadata, types, and Gaussian likelihood tests to read the named fields. Test docstrings now describe the fixture contract. Behavior of the tests is unchanged.
Replace the tuple returned by the window_1 fixture with a frozen, keyword-only HarmonicWindowFunction dataclass holding ell_grid, weights, and band_labels. The two_point_cwindow and optimized_two_point_cwindow fixtures now read named fields instead of positional tuple indices, so the mapping onto TwoPointHarmonic's ells, window, and window_ells arguments is explicit. The dataclass docstring notes that its dtype annotations do not check weight-matrix shape or physical units.
Replace the positional tuple returned by the window function fixture with a frozen ScaleCutWindowFunction dataclass. Fields are accessed by name instead of index, so the weights, support multipoles, and bin centers can no longer be swapped silently. Test behavior is unchanged.
Introduce ScaleCutBandpowerPrediction and ScaleCutSaccFixture so the minimal_3x2pt_sacc fixture returns named fields instead of positional tuples. The label and support tests now read spectrum.bandpowers and spectrum.window instead of unpacking four-element tuples. The window fields reference the shared window_function_data directly rather than copying its arrays. Add explicit type annotations to the fixture locals and update the test docstrings to document their parameters.
Replace the tuple-returning cross-bin SACC fixtures with a SaccHarmonicCrossBinFixture dataclass. It holds the SACC data and a distributions mapping keyed by tracer name, so tests look up src0, src1, lens0, and lens1 by name instead of unpacking positional values. The fixtures in conftest.py and the tests that consume them in test_metadata_two_point.py and test_metadata_two_point_sacc.py are updated to match, and the affected tests now assert per-tracer z and dndz by name.
Replace tuple-returning real-space SACC fixtures with a typed SaccRealCrossBinFixture that exposes sacc_data and named per-tracer distributions. Update the consuming tests to read these fields and drop the now-unused numpy.typing imports.
Replace the positional tuples returned by the real-space and harmonic three-tracer fixtures with frozen keyword-only dataclasses. Each fixture now exposes `sacc_data` and a `distributions` mapping keyed by tracer name (src0, lens0, lens1), built from SampledRedshiftDistribution. Update the two three-tracer rejection tests to read `sacc_data` from the named fixture. Add explicit numpy array type annotations to the redshift and dN/dz arrays in both fixtures.
Annotate BACKGROUND with CCLCalculatorArgs and the PK_LINEAR and PK_NONLIN fragments with dict[str, PowerSpec], importing PowerSpec. The partial fragments keep the open mapping because no existing schema covers a single calculator-argument key.
Replace np.double annotations and builtin float dtypes with np.float64. These are equivalent aliases, so behavior is unchanged.
Replace tuple-returning SACC test fixtures with named frozen dataclasses (SaccGalaxyHarmonicFixture, SaccGalaxyRealFixture, SaccGalaxyWindowedFixture, SaccGalaxyDistributionFixture, SaccInvalidDataTypeFixture). Tests access sacc_data, distributions, and spectra by name instead of unpacking tuples. Relabel fixture expectations as synthetic observations rather than measured values, and define "Independent SACC expectation" and "Synthetic SACC observation" in GLOSSARY.md. Behavior of the existing tests is unchanged.
marcpaterno
force-pushed
the
clarify-test-fixtures
branch
from
October 28, 2026 02:13
2fe237f to
0632c88
Compare
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.
Summary
Replace positional SACC and scale-cut fixture tuples with named, typed records. Update their consumers to access the intended fields directly, and use explicit
np.float64array types in the related Gaussian likelihood code.This PR builds on the strict test typing in #684.
Evidence
make lintpasses; the regular suite reports 4309 passed, 94 skipped, and 29 warnings.Merge Danger
Door: Two-way. The fixture refactor can be reverted without a data migration.
Blast Radius: Tests. The main risk is an incorrectly updated fixture consumer; the full test suite passed.