Fix unit tests for PR #41: adapt to Correlations refactor, fix numpy 2.0 compatibility#42
Closed
Fix unit tests for PR #41: adapt to Correlations refactor, fix numpy 2.0 compatibility#42
Conversation
…s in UVLFs.py Agent-Logs-Url: https://github.com/ZeusCosmo/Zeus21/sessions/90d4b6aa-333e-4ae4-ae6a-8fcd7b51aa7e Co-authored-by: JulianBMunoz <22434409+JulianBMunoz@users.noreply.github.com>
added tqdm
Removed debugging step for SFR_III function from CI workflow.
Added @EmilieThelie 's fixes for LW calls
…it-tests-zooc21 Co-authored-by: JulianBMunoz <22434409+JulianBMunoz@users.noreply.github.com>
…lumping issues Agent-Logs-Url: https://github.com/ZeusCosmo/Zeus21/sessions/398e6899-c0e5-43b6-a9b1-5d57b57f83d5 Co-authored-by: JulianBMunoz <22434409+JulianBMunoz@users.noreply.github.com>
By @slibanore and Alessandra Venditti, now LFs for UVLF and HaLF separately and in a LF.py file
Copilot
AI
changed the title
[WIP] Fix unit tests after Correlations class refactor
Fix unit tests for PR #41: adapt to Correlations refactor, fix numpy 2.0 compatibility
May 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.
PR #41 (
zeus21_hack) removed the standaloneCorrelationsclass and folded correlation computation intoCosmo_Parameters.run_correlations()(called automatically in__post_init__), and changedPower_Spectrato pull arrays fromCosmoParamsdirectly. Tests were still using the old API, causing collection failures.Test API updates
test_correlations.py: Replacezeus21.Correlations(UserParams, CosmoParams)with assertions on correlation arrays now living onCosmoParams(_klistCF,_PklinCF,xi_RR_CF,xiEta_RR_CF,rlist_CF). Window function tests moved toz21_utilities._WinTH/G/TH1D.test_astrophysics.py: RemoveCorrFClass; updatePower_Spectracall andrlist_CF/_klistCFrefs.test_maps.py: Same, across all three test functions.test_sfrd.py: Remove stale_ = zeus21.Correlations(...).Pre-existing bugs exposed by collection succeeding
zeus21/inputs.py:np.trapz→np.trapezoid(removed in NumPy 2.0;requirements.txtpinsnumpy>=2.0). Affects theUSE_RELATIVE_VELOCITIEScode path inrunclass().test_inputs.py,test_cosmology.py,test_UVLFs.py:kmax_CLASS=10.is now too small —run_correlations()runs atCosmo_Parametersinit time and the computed_klistCFvalues exceed the CLASS k-grid at that setting. Raised to100..test_inputs.py:AstroParams._clumping→AstroParams.clumping(attribute was renamed in the refactor).Original prompt
Fix unit tests in ZeusCosmo/Zeus21 for PR #41 after refactor that removed standalone
Correlationsclass and moved correlation computation/storage intoCosmo_Parameters.Context:
Cosmo_Parameters.run_correlations()(inzeus21/inputs.py), and arrays are stored on theCosmo_Parametersinstance.Power_Spectrano longer takes aCorrFClassargument; it pulls needed correlation arrays fromCosmo_Parameters.zeus21.Correlationsand callPower_Spectrawith the old signature.Tasks:
from zeus21.correlations import *or directCorrelations(...)usage.CorrFClassin tests.Power_Spectrainstantiation to new signature (expected:Power_Spectra(UserParams, CosmoParams, AstroParams, Coeffs); verify in code).tests/test_correlations.pyto validate correlations viaCosmo_Parametersinstead of a removed class:CosmoParamshas correlation-related attributes after initialization (e.g._klistCF,_PklinCF,xi_RR_CF, and any other correlation arrays in use).Acceptance criteria:
pytestsuite passes.PR target:
The following is the prior conversation context from the user's chat exploration (may be truncated):
User: Please find a solution for failing job 73948760349. Use the logs, job definition, and any referenced files where the failure occurred. Keep your response focused on the solution and include code suggestions when appropriate.
User: we need to update tests so they follow the latest file changes (eg correlations doesnt exist separately anymore, its in cosmo parameters)
Assistant: To align the tests with the latest code changes in PR #41 (where correlations are no longer a standalone object/file-path dependency and are now carried via
Cosmo_Parameters), you should update any tests that still:zeus21.correlationsdirectly, orCorrelations(UserParams, CosmoParams, ClassyCosmo), orPower_Spectra(..., ClassyCosmo, CorrFClass, Coeffs)(old signature), orClassyCosmo.pars[...]for correlation-related data.What changed (relevant to the tests)
From the PR diffs:
Correlationsclass was removed fromzeus21/correlations.py; now the correlations machinery lives insideCosmo_Parameters.run_correlations()(inzeus21/inputs.py), and the resulting arrays are stored on theCosmo_Parametersinstance (e.g._klistCF,_PklinCF,xi_RR_CF, etc.).Power_Spectramoved tozeus21/correlations.pybut now expects no external Correlations instance; it pulls correlation arrays fromCosmo_Parameters.Concrete test updates you should make
1)
tests/test_astrophysics.py— remove stale import + stop creating Correlations the old wayRight now this file still has:
from zeus21.correlations import *(stale)CorrFClass = zeus21.Correlations(UserParams, CosmoParams)(this will fail, becauseCorrelationsisn’t a thing anymore)PS21 = zeus21.Power_Spectra(UserParams, CosmoParams, AstroParams, CorrFClass, Coeffs)(wrong signature per PR diff)Fix:
from zeus21.correlations import *CorrFClass = ...Power_Spectrausing the new signature shown in the PR diff ofzeus21/correlations.py:PS21 = zeus21.Power_Spectra(UserParams, CosmoParams, AstroParams, Coeffs)Also: anywhere the test used correlation-derived fields via the old
PS21.Deltasq_dxaetc may need to be adjusted (you already replaced the “correlation coefficient inequality” assertions with a simpler positive-definite check, which is consistent with the “correlations not separate anymore” change).2)
tests/test_correlations.py— this test’s purpose needs redefiningThis file currently does:
CorrFClass = zeus21.Correlations(UserParams, CosmoParams)then tests correlation functions.But there is no
zeus21.Correlationsanymore. The replacement is: correlations are computed as a side effect of constructingCosmo_Parameters(it callsrun_correlations()in__post_init__).Fix direction:
CosmoParams, e.g.:hasattr(CosmoParams, "xi_RR_CF")CosmoParams.xi_RR_CF,CosmoParams._klistCF, etc are sensible / non-emptyThis pull request was created from Copilot chat.