Skip to content

Commit

Permalink
Fix new numpy and scipy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
dean0x7d committed Aug 29, 2020
1 parent a30ed7c commit 53b5544
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions pybinding/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ def sweep(factory, plot=lambda r: r.plot(), labels=None, tags=None, silent=False
zero = np.zeros_like(energy, np.float32)

def make_result(data):
sweep_data = np.vstack(v.squeeze() if v is not None else zero for v in data)
sweep_data = np.vstack([v.squeeze() if v is not None else zero for v in data])
return Sweep(x, energy, sweep_data, labels, tags)

if silent:
Expand Down Expand Up @@ -416,7 +416,7 @@ def ndsweep(factory, plot=None, labels=None, tags=None, silent=False):
zero = np.zeros_like(energy, np.float32)

def make_result(data):
sweep_data = np.vstack(v.squeeze() if v is not None else zero for v in data)
sweep_data = np.vstack([v.squeeze() if v is not None else zero for v in data])
return NDSweep(variables, sweep_data, labels, tags)

if silent:
Expand Down
12 changes: 6 additions & 6 deletions tests/test_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ def lattice():
return lat

model = pb.Model(lattice(), pb.primitive(3))
h = model.hamiltonian.todense()
h = model.hamiltonian.toarray()

assert model.system.num_sites == 3
assert h.shape[0] == 6
assert pytest.fuzzy_equal(h, h.H)
assert pytest.fuzzy_equal(h, h.T.conjugate())
assert pytest.fuzzy_equal(h[:2, :2], h[-2:, -2:])
assert pytest.fuzzy_equal(h[:2, :2], [[ 1, 3j],
[-3j, 2]])
Expand All @@ -96,11 +96,11 @@ def hopping(energy):
return 2 * energy

model = pb.Model(lattice(), pb.primitive(3), onsite, hopping)
h = model.hamiltonian.todense()
h = model.hamiltonian.toarray()

assert model.system.num_sites == 3
assert h.shape[0] == 6
assert pytest.fuzzy_equal(h, h.H)
assert pytest.fuzzy_equal(h, h.T.conjugate())
assert pytest.fuzzy_equal(h[:2, :2], h[-2:, -2:])
assert pytest.fuzzy_equal(h[:2, :2], [[ 3, 9j],
[-9j, 6]])
Expand All @@ -116,11 +116,11 @@ def lattice_with_zero_diagonal():
return lat

model = pb.Model(lattice_with_zero_diagonal(), pb.primitive(3))
h = model.hamiltonian.todense()
h = model.hamiltonian.toarray()

assert model.system.num_sites == 3
assert h.shape[0] == 6
assert pytest.fuzzy_equal(h, h.H)
assert pytest.fuzzy_equal(h, h.T.conjugate())
assert pytest.fuzzy_equal(h[:2, :2], h[-2:, -2:])
assert pytest.fuzzy_equal(h[:2, :2], [[0, 3j],
[-3j, 0]])

0 comments on commit 53b5544

Please sign in to comment.