Skip to content

Fixed negative concentration [version:1.0.3]#70

Open
eduardojsbarroso wants to merge 2 commits intomainfrom
negative_concentration
Open

Fixed negative concentration [version:1.0.3]#70
eduardojsbarroso wants to merge 2 commits intomainfrom
negative_concentration

Conversation

@eduardojsbarroso
Copy link
Collaborator

With the negative concentration case we had before, if we start the code with negative values, or if we set cluster_theory.cluster_concentration = -1., the property function is called and concentration is set to none.

However, if we change directly the parameter dictionary, this does not work. And in Firecrown this is exactly how we set our parameters so the code is breaking because we set a concentration to negative values. To reproduce the error without the fix here, here is the code:

import crow
from crow import ClusterShearProfile
import pyccl as ccl
hmf = ccl.halos.MassFuncTinker08(mass_def="200c")
cosmo = ccl.Cosmology(
    Omega_c=0.2607,      # Cold dark matter density
    Omega_b=0.04897,     # Baryon density
    h=0.6766,            # Hubble parameter
    sigma8=0.8102,       # Matter fluctuation amplitude
    n_s=0.9665,          # Spectral index
)
mass = np.array([13])
z= np.array([1.0])
rad= 4.
cl_delta_sigma = ClusterShearProfile(cosmo, hmf, None, True)
### Working version
cl_delta_sigma .cluster_concentration = -1.
print(cl_delta_sigma.cluster_concentration)
print(cl_delta_sigma.compute_shear_profile(mass, z, rad))

### Broken case
cl_delta_sigma.parameters["cluster_concentration"] = -1.
print(cl_delta_sigma.cluster_concentration)
print(cl_delta_sigma.compute_shear_profile(mass, z, rad))

@github-actions github-actions bot changed the title Fixed negative concentration Fixed negative concentration [version:1.0.3] Jan 23, 2026
@codecov
Copy link

codecov bot commented Jan 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 98.36%. Comparing base (24a97ce) to head (487e82f).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #70   +/-   ##
=======================================
  Coverage   98.36%   98.36%           
=======================================
  Files          28       28           
  Lines        1772     1772           
  Branches       58       58           
=======================================
  Hits         1743     1743           
  Misses         29       29           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

Comments