Skip to content

Commit

Permalink
Merge pull request #287 from pyGSTio/bugfix-more-numpy124-stuff
Browse files Browse the repository at this point in the history
Bugfix more numpy124 stuff
  • Loading branch information
sserita committed Jan 5, 2023
2 parents 6d40b45 + f888ebb commit 4098dea
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 7 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/extras.yml
Expand Up @@ -17,7 +17,7 @@ env:
NOSE_WITH_TIMER: 1
NOSE_WITH_ID: 1
NOSE_REDNOSE: 1
NOSE_WITH_COVERAGE: 1
NOSE_WITH_COVERAGE: 0
NOSE_COVER_PACKAGE: "pygsti"
#NOSE_PROCESSES: -1
NOSE_NOPATH: ""
Expand All @@ -38,7 +38,6 @@ jobs:
- "algorithmsb"
- "report"
- "reportb"
- "report"
- "objects"
- "tools"
- "iotest"
Expand Down
4 changes: 2 additions & 2 deletions pygsti/tools/matrixtools.py
Expand Up @@ -1136,10 +1136,10 @@ def metricfn(x, y): return abs(x - y)

if pass_indices_to_metricfn:
for i, x in enumerate(a):
weightMx[i, :] = [metricfn(i, j) for j, y in enumerate(b)]
weightMx[i, :] = _np.ravel(_np.array([metricfn(i, j) for j, y in enumerate(b)]))
else:
for i, x in enumerate(a):
weightMx[i, :] = [metricfn(x, y) for j, y in enumerate(b)]
weightMx[i, :] = _np.ravel(_np.array([metricfn(x, y) for j, y in enumerate(b)]))

a_inds, b_inds = _spo.linear_sum_assignment(weightMx)
assert(_np.allclose(a_inds, range(D))), "linear_sum_assignment returned unexpected row indices!"
Expand Down
3 changes: 3 additions & 0 deletions pygsti/tools/optools.py
Expand Up @@ -49,6 +49,9 @@ def _hack_sqrtm(a):
if _np.any(_np.isnan(sqrt)): # this is sometimes a good fallback when sqrtm doesn't work.
ev, U = _np.linalg.eig(a)
sqrt = _np.dot(U, _np.dot(_np.diag(_np.sqrt(ev)), _np.linalg.inv(U)))
# Scipy 1.10 fix for PR 16294 (which doubles precision of complex to complex)
if _np.iscomplexobj(a):
sqrt = sqrt.astype(a.dtype, copy=False)

return sqrt

Expand Down
4 changes: 2 additions & 2 deletions test/test_packages/objects/testHessian.py
Expand Up @@ -319,10 +319,10 @@ def fnOfSpam_0D(rhoVecs, povms):
return np.array( float( np.dot( rhoVecs[0].T, povms[0][lbls[0]] ) ) )
def fnOfSpam_1D(rhoVecs, povms):
lbls = list(povms[0].keys())
return np.array( [ np.dot( rhoVecs[0].T, povms[0][lbls[0]] ), 0] )
return np.array( [ float(np.dot( rhoVecs[0].T, povms[0][lbls[0]]) ), 0] )
def fnOfSpam_2D(rhoVecs, povms):
lbls = list(povms[0].keys())
return np.array( [[ np.dot( rhoVecs[0].T, povms[0][lbls[0]] ), 0],[0,0]] )
return np.array( [[ float(np.dot( rhoVecs[0].T, povms[0][lbls[0]] )), 0],[0,0]] )
def fnOfSpam_3D(rhoVecs, povms):
return np.zeros( (2,2,2), 'd') #just to test for error

Expand Down
8 changes: 7 additions & 1 deletion test/test_packages/objects/testQiboGST.py
Expand Up @@ -3,9 +3,15 @@

import pygsti
from pygsti.modelpacks import smq1Q_XYI as std
from pygsti.evotypes import qibo as evo_qibo # don't clobber qibo!

#qibo is also currently suffering from numpy 1.24.0 related deprecation problems
#that result in this dying on this import.
try:
from pygsti.evotypes import qibo as evo_qibo # don't clobber qibo!
except (ImportError, AttributeError):
pass

@unittest.skip("Qibo import is currently broken because of numpy 1.24, re-enable once the devs fix it.")
class TestQiboGSTCase(BaseTestCase):
def setUp(self):
evo_qibo.densitymx_mode = True
Expand Down

0 comments on commit 4098dea

Please sign in to comment.