Open deyanmihaylov opened 3 months ago
Here is the entire traceback which could not be pasted in the issue: https://pastebin.com/ZFJmv4H7
Cobaya tests fail due to the same issue when compiling with py12 and numpy 2. I think numpy 2 removed "int_t". Log: https://app.travis-ci.com/github/CobayaSampler/cobaya/builds/271808045
Is there any plan to provide a fix? I don't know if you can do it on your end, or cobaya maintainers have to issue a new release.
This is a CLASS problem, nothing to do with Cobaya. For local builds you can try changing the int_t declarations yourself or you can install an earlier numpy version.
I am having the same issue with installing classy. My Python version is 3.10.11.
Since numpy2, the way to specify the type of np.int_t seems to have become strict. Until it is fixed on the CLASS side, you can install it by downloading and editing the file as follows.
pip cache purge
pip download --no-deps classy
tar -zxvf classy-3.2.3.2.tar.gz
cd classy-3.2.3.2/
sed -i 's/np\.int_t/np.int64_t/g' class_public/python/classy.pyx
pip install .
It can install and import, but I don't know if numpy2 will cause any problems. As long as I am using it, there is no problem.
Hi! I believe that this was fixed by the release of CLASS v3.2.4 on the 30.09.2024 (and it should still be OK with the current v3.2.5). If you still have similar problems with recent versions, you can open an issue on https://github.com/lesgourg/class_public
Since numpy2, the way to specify the type of np.int_t seems to have become strict. Until it is fixed on the CLASS side, you can install it by downloading and editing the file as follows.
pip cache purge pip download --no-deps classy tar -zxvf classy-3.2.3.2.tar.gz cd classy-3.2.3.2/ sed -i 's/np\.int_t/np.int64_t/g' class_public/python/classy.pyx pip install .
It can install and import, but I don't know if numpy2 will cause any problems. As long as I am using it, there is no problem.
Hi all
I think it would be a good idea to add this to the package page as a temporary solution as more of us are facing the same issue.
many thanks!
Since numpy2, the way to specify the type of np.int_t seems to have become strict. Until it is fixed on the CLASS side, you can install it by downloading and editing the file as follows.
pip cache purge pip download --no-deps classy tar -zxvf classy-3.2.3.2.tar.gz cd classy-3.2.3.2/ sed -i 's/np\.int_t/np.int64_t/g' class_public/python/classy.pyx pip install .
It can install and import, but I don't know if numpy2 will cause any problems. As long as I am using it, there is no problem.
Hi all
I think it would be a good idea to add this to the package page as a temporary solution as more of us are facing the same issue.
many thanks!
also, this is the macOS version of the solution
pip cache purge
pip download --no-deps classy
tar -zxvf classy-3.2.3.2.tar.gz
cd classy-3.2.3.2/
sed -i '' 's/np\.int_t/np.int64_t/g' class_public/python/classy.pyx
pip install .
forgot to add in case you need this info:
(ccl3) niko @ MacBook-Pro-83.local : ~/Documents/Research/forecasting_validation% python3 check_version.py
Python version: 3.12.7
NumPy version: 1.26.4
Operating System: macOS 15.1.1
Processor: i386
Memory: 8.00 GB
So, to conclude, I had the Error Installing CLASSy Due to Cython Compilation Issue on this setup.
Dear @nikosarcevic , in your example I see that you are using class v3.2.3. I would have thought that this problem was fixed already in v3.2.4 on the 30.09.2024 (and we are now at v3.2.5 since the 4.10.2024). Can you check whether you meet this kind of numpy issues with v3.2.4 or 3.2.5? If yes we should really do something more. You can either clone the new versions, or just merge them in your class if you have done your own modifications.
Hi, @lesgourg hope you are doign well!
Let me see if I can do this quickly as I have telecons soon. I believe I am calling class via ccl but need to check what is actually going on. Will report back!
Hi again, @lesgourg
It seems that, if my understanding is correct, the issue was resolved in CLASS version 3.2.5, as pulling this version from GitHub, building it manually, and installing the Python wrapper (classy) worked for me. The NumPy compatibility issue (np.int_t) no longer occurs with this version.
however, I noticed that classy version 3.2.5 is not available on PyPI. Users relying on pip install classy might still face the same problem unless they manually pull and build from GitHub. Perhaps publishing the latest version to PyPI could help prevent this confusion for others. (or adding the solutions above as a temporary fix until 3.2.5 is avail)
Many thanks @nikosarcevic , I had not realised that 3.2.5 was not available on PyPI, we will fix this!
@lesgourg Brilliant! Many, many thanks!
When I try to install
classy
usingpip install classy
I get the following error