bccp / nbodykit

Analysis kit for large-scale structure datasets, the massively parallel way
http://nbodykit.rtfd.io
GNU General Public License v3.0
111 stars 60 forks source link

Problem with cosmology/cosmology.py when creating a clone with ncdm #600

Closed adrianbayer closed 5 years ago

adrianbayer commented 5 years ago

The compile_args function in cosmology/cosmology.py converts m_ncdm to a list depending on the form of input. Often m_ncdm is of string type, e.g. '0.06,0.05,0.04'. When this is the case, this will incorrectly trigger the isscalar if statement and later lead to N_ncdm=1, which is wrong.

One fix would be to add an extra if to check if m_ncdm is a string and use split to convert to a list. I can implement this if you think it's sensible?

rainwoodman commented 5 years ago

Sure. A fix would be great.

If you are making a fix, I would suggest you first add a test case to tests/test_cosmology.py that exactly reproduces your issue (fails in clone). Then you can add the fix that's just enough to make the test case pass.

adrianbayer commented 5 years ago

I realised this actually isn't a bug, as long as you input m_ncdm as a list, not a string. I guess we could add the feature of allowing string input, but for now I'll leave it since list input seems to work fine.