Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with fgspectra when running example #100

Open
pengenix opened this issue Jan 23, 2025 · 2 comments
Open

Error with fgspectra when running example #100

pengenix opened this issue Jan 23, 2025 · 2 comments

Comments

@pengenix
Copy link

I have successfully installed mflike, however when I run the example - cobaya-run examples/mflike_example.yaml -p ../packages, I receive the following error:

Traceback (most recent call last):
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/bin/cobaya-run", line 8, in <module>
    sys.exit(run_script())
             ~~~~~~~~~~^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/run.py", line 198, in run_script
    run(info, **arguments.__dict__)
    ~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/run.py", line 132, in run
    sampler = sampler_class(updated_info["sampler"][sampler_name],
                            model, out, name=sampler_name,
                            packages_path=info.get("packages_path"))
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/sampler.py", line 279, in __init__
    self.initialize()
    ~~~~~~~~~~~~~~~^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/samplers/mcmc/mcmc.py", line 167, in initialize
    initial_point, results = self.model.get_valid_point(
                             ~~~~~~~~~~~~~~~~~~~~~~~~~~^
        max_tries=int(min(self.max_tries.value, 1e7)),
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        random_state=self._rng
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/model.py", line 616, in get_valid_point
    results = self.logposterior(initial_point)
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/model.py", line 558, in logposterior
    like = self._loglikes_input_params(input_params,
                                       return_derived=return_derived,
                                       cached=cached, make_finite=make_finite)
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/model.py", line 378, in _loglikes_input_params
    compute_success = component.check_cache_and_compute(
        params, want_derived=need_derived,
        dependency_params=depend_list, cached=cached)
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/cobaya/theory.py", line 253, in check_cache_and_compute
    if self.calculate(state, want_derived, **params_values_dict) is False:
       ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/mflike/foreground.py", line 432, in calculate
    state["fg_totals"] = self.get_foreground_model_totals(**params_values_dict)
                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/mflike/foreground.py", line 443, in get_foreground_model_totals
    model = self._get_foreground_model_arrays(params_values_dict)
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/mflike/foreground.py", line 556, in _get_foreground_model_arrays
    return super()._get_foreground_model_arrays(fg_params, ell=ell)
           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/mflike/foreground.py", line 270, in _get_foreground_model_arrays
    model["tt", "kSZ"] = fg_params["a_kSZ"] * self.ksz(
                                              ~~~~~~~~^
        {"nu": self.bandint_freqs_T}, {"ell": ell, "ell_0": ell_0}
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/fgspectra/model.py", line 111, in __call__
    return self.eval(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/fgspectra/cross.py", line 136, in eval
    f_nu = self._sed(**sed_kwargs)
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/fgspectra/model.py", line 111, in __call__
    return self.eval(*args, **kwargs)
           ~~~~~~~~~^^^^^^^^^^^^^^^^^
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/fgspectra/frequency.py", line 324, in eval
    return _bandpass_integration()
  File "/home/c.c24054153/.conda/envs/boltzmannbenchmarks/lib/python3.13/site-packages/fgspectra/frequency.py", line 84, in _bandpass_integration
    del kw["self"]  # self was in the locals but is not a keyword argument
        ~~^^^^^^^^
TypeError: cannot remove variables from FrameLocalsProxy

I think this is caused by different versions of fgspectra

@xgarrido
Copy link
Collaborator

I haven't be able to reproduce your error on a fresh install of mflike (see steps below). We need fgspectra version to be at least 1.3.0 so if you have an older version, I think when installing mflike, the system should upgrade fgspectra. In any case, you can try to upgrade it by doing python -m pip install -U fgspectra.

Here are the steps I did using a virtual env.

cd /tmp
python -m venv pyenv
source pyenv/bin/activate
python -m pip install mflike
wget https://raw.githubusercontent.com/simonsobs/LAT_MFLike/refs/heads/master/examples/mflike_example.yaml
# Source again to make sure we use the correct cobaya bins
source pyenv/bin/activate
cobaya-install -p packages mflike_example.yaml
cobaya-run -p packages mflike_example.yaml

@xgarrido
Copy link
Collaborator

xgarrido commented Feb 1, 2025

@pengenix Do you still have the issue ? Otherwise can you close this issue ?

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

No branches or pull requests

2 participants