pyGSTi icon indicating copy to clipboard operation
pyGSTi copied to clipboard

Latest numpy release breaks pygsti

Open eendebakpt opened this issue 2 years ago • 5 comments

Describe the bug

pygsti uses the deprecated and now removed method numpy.isscalar. numpy 1.23 has been released on pypi and pygsti stopped working.

pygsti only uses numpy.isscalar at two locations in the code. If external PRs are accepted, I can make a PR to address the issue.

@enielse

eendebakpt avatar Jun 23 '22 08:06 eendebakpt

@eendebakpt , we can accept external PRs only after the submitter completes a CLA. Please let us know if you'd like to us to send you the form. This is indeed an issue, as numpy.asscalar was deprecated in NumPy version 1.16. The issue is fixed in bd78cf388a3e052393b0adc31d5c192bfd2bf511, which will be incorporated into the next release, most likely either 0.9.10.2 or 0.9.11. Let's leave this issue open until the next release happens.

enielse avatar Aug 09 '22 16:08 enielse

Not sure if this is related. I am new to pyGSTi and, after successful installation, I tried to import pygsti in a jupyter notebook (for example one of the tutorial notebooks). This caused the error:

`File <PATH>/pyGSTi/pygsti/baseobjs/opcalc/fastopcalc.pyx:1, in init pygsti.baseobjs.opcalc.fastopcalc()

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject`

The error persists after updating numpy to version 1.20.1 and to version 1.21.5.

giangiac avatar Aug 19 '22 16:08 giangiac

Hi @giangiac, Usually your error message shows up when you update PyGSTi but not the Cython extensions. Perhaps Pygsti is installed with pip install -e and was updated via git, or something like that?

The typical solution is to try and rebuild the Cython extensions with something like

python setup.py build_ext --inplace

in the PyGSTi directory, i.e. where the -e install points to. If you didn't install with -e, then perhaps try to reinstall just pygsti again (with Cython already in the environment).

sserita avatar Aug 22 '22 15:08 sserita

Just chiming in to say that I have also encountered occasionally this when updating numpy via pip without rebuilding the cython extensions as @sserita mentioned.

coreyostrove avatar Aug 23 '22 04:08 coreyostrove

Thanks @sserita, your comment helped!

I wrote a python script to install the software (cloning the repo and installing with pip install -e .) I had updated Numpy and Cython (via conda) and still failed. Until I realized that python and pip referred to different python installations (my fault in setting the environment). I changed pip install -e . to python -m pip install -e . and now it works.

giangiac avatar Aug 24 '22 13:08 giangiac

Closed as this is now in 0.9.11 release

sserita avatar May 17 '23 06:05 sserita