LSSTDESC / CCL

DESC Core Cosmology Library: cosmology routines with validated numerical accuracy
BSD 3-Clause "New" or "Revised" License
145 stars 68 forks source link

Problem defining the CCL cosmology. Error: "Omeganuh2_vec() takes 6 positional arguments but 7 were given". #1084

Closed luigilcsilva closed 1 year ago

luigilcsilva commented 1 year ago

Dear colleagues, I am having a problem when I try to define the CCL cosmology. An error is arising. Could anyone help me to understand it, please? The complete notebook can be find here.

The error is the following:

ccl_cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff,
                          h=h, A_s = A_s, n_s=n_s, Omega_k=Omega_k,
                          w0=w0, wa=wa, transfer_function='eisenstein_hu')
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In [6], line 1
----> 1 ccl_cosmo = ccl.Cosmology(Omega_c=Omega_c, Omega_b=Omega_b, Neff=Neff,
      2                           h=h, A_s = A_s, n_s=n_s, Omega_k=Omega_k,
      3                           w0=w0, wa=wa, transfer_function='eisenstein_hu')

File ~/cosmology/CCL/pyccl/base/deprecations.py:198, in warn_api.<locals>.wrapper(*args, **kwargs)
    194 kwargs.update(pos)
    195 kwargs = {param: kwargs[param]
    196           for param in sorted(kwargs, key=list(params).index)}
--> 198 return func(**kwargs)

File ~/cosmology/CCL/pyccl/cosmology.py:343, in Cosmology.__init__(self, Omega_c, Omega_b, h, n_s, sigma8, A_s, Omega_k, Omega_g, Neff, m_nu, mass_split, w0, wa, T_CMB, bcm_log10Mc, bcm_etab, bcm_ks, mu_0, sigma_0, c1_mg, c2_mg, lambda_mg, z_mg, df_mg, transfer_function, matter_power_spectrum, baryons_power_spectrum, mass_function, halo_concentration, emulator_neutrinos, extra_parameters, T_ncdm)
    325 self._params_init_kwargs = dict(
    326     Omega_c=Omega_c, Omega_b=Omega_b, h=h, n_s=n_s, sigma8=sigma8,
    327     A_s=A_s, Omega_k=Omega_k, Omega_g=Omega_g, Neff=Neff, m_nu=m_nu,
   (...)
    332     z_mg=z_mg, df_mg=df_mg,
    333     extra_parameters=extra_parameters)
    335 self._config_init_kwargs = dict(
    336     transfer_function=transfer_function,
    337     matter_power_spectrum=matter_power_spectrum,
   (...)
    340     halo_concentration=halo_concentration,
    341     extra_parameters=extra_parameters)
--> 343 self._build_cosmo()
    345 self._pk_lin = {}
    346 self._pk_nl = {}

File ~/cosmology/CCL/pyccl/cosmology.py:352, in Cosmology._build_cosmo(self)
    349 """Assemble all of the input data into a valid ccl_cosmology object."""
    350 # We have to make all of the C stuff that goes into a cosmology
    351 # and then we make the cosmology.
--> 352 self._build_parameters(**self._params_init_kwargs)
    353 self._build_config(**self._config_init_kwargs)
    354 self.cosmo = lib.cosmology_create(self._params, self._config)

File ~/cosmology/CCL/pyccl/cosmology.py:506, in Cosmology._build_parameters(self, Omega_c, Omega_b, h, n_s, sigma8, A_s, Omega_k, Neff, m_nu, mass_split, w0, wa, T_CMB, T_ncdm, bcm_log10Mc, bcm_etab, bcm_ks, mu_0, sigma_0, c1_mg, c2_mg, lambda_mg, z_mg, df_mg, Omega_g, extra_parameters)
    504 rho_nu_rel = N_nu_rel * (7/8) * 4 * c.STBOLTZ / c.CLIGHT**3 * T_nu**4
    505 Omega_nu_rel = rho_nu_rel / rho_crit
--> 506 Omega_nu_mass = self._OmNuh2(nu_mass, N_nu_mass, T_CMB, T_ncdm) / h**2
    508 if N_nu_rel < 0:
    509     raise ValueError("Unphysical Neff and m_nu combination results to "
    510                      "negative number of relativistic neutrinos.")

File ~/cosmology/CCL/pyccl/cosmology.py:539, in Cosmology._OmNuh2(self, m_nu, N_nu_mass, T_CMB, T_ncdm)
    537 def _OmNuh2(self, m_nu, N_nu_mass, T_CMB, T_ncdm):
    538     # Compute OmNuh2 today.
--> 539     ret, st = lib.Omeganuh2_vec(N_nu_mass, T_CMB, T_ncdm, [1], m_nu, 1, 0)
    540     check(st)
    541     return ret[0]

TypeError: Omeganuh2_vec() takes 6 positional arguments but 7 were given

Thanks in advance!

nikfilippas commented 1 year ago

Reinstalling CCL should fix the issue. Looks like your _ccllib.so and ccllib.py files are outdated, or are lingering from a previous installation.

luigilcsilva commented 1 year ago

It worked perfectly. Thank you very much!