Skip to content

Commit

Permalink
Fixed some deprecation warnings from numpy 1.20
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentRDC committed Feb 6, 2021
1 parent c25b8c9 commit 0fa3eb0
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions crystals/affine.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ def change_basis_mesh(xx, yy, zz, basis1, basis2):
XX, YY, ZZ : `~numpy.ndarray`
"""
# Build coordinate array row-wise
changed = np.empty(shape=(3, xx.size), dtype=np.float)
linearized = np.empty(shape=(3, xx.size), dtype=np.float)
changed = np.empty(shape=(3, xx.size), dtype=np.float64)
linearized = np.empty(shape=(3, xx.size), dtype=np.float64)
linearized[0, :] = xx.ravel()
linearized[1, :] = yy.ravel()
linearized[2, :] = zz.ravel()
Expand Down Expand Up @@ -295,7 +295,7 @@ def minimum_image_distance(xx, yy, zz, lattice):
Minimum image distance over the lattice
"""
COB = change_of_basis(np.eye(3), lattice)
linearized = np.empty(shape=(3, xx.size), dtype=np.float) # In the standard basis
linearized = np.empty(shape=(3, xx.size), dtype=np.float64) # In the standard basis
ulinearized = np.empty_like(linearized) # In the unitcell basis

linearized[0, :] = xx.ravel()
Expand Down
2 changes: 1 addition & 1 deletion crystals/indexing/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def ratio_indexed(lattice, reflections):
ratio : float
Ratio of reflections that are indexed correctly, in the [0, 1] range.
"""
reflections = np.asarray(reflections, dtype=np.float)
reflections = np.asarray(reflections, dtype=np.float64)

hkl = lattice.miller_indices(reflections)
return (
Expand Down
2 changes: 1 addition & 1 deletion crystals/indexing/dirax.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ def _find_basis(vectors, reflections):
# The best way to find the last vector is to iterate through the remaining
# vectors, from shortest to longest, until a matrix with the candidate
# basis as rows has rank 3
m = np.empty(shape=(3, 3), dtype=np.float)
m = np.empty(shape=(3, 3), dtype=np.float64)
m[0, :] = a1
m[1, :] = a2
for v in vectors:
Expand Down
6 changes: 3 additions & 3 deletions crystals/lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ class Lattice:

def __init__(self, lattice_vectors, **kwargs):
a1, a2, a3 = lattice_vectors
self.a1 = np.asarray(a1, dtype=np.float)
self.a2 = np.asarray(a2, dtype=np.float)
self.a3 = np.asarray(a3, dtype=np.float)
self.a1 = np.asarray(a1, dtype=np.float64)
self.a2 = np.asarray(a2, dtype=np.float64)
self.a3 = np.asarray(a3, dtype=np.float64)
super().__init__(**kwargs)

def __repr__(self):
Expand Down
6 changes: 3 additions & 3 deletions crystals/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def symmetry_operators(self):
if op_num not in sym_ops:
sym_ops[op_num] = {"rotation": list(), "translation": list()}

r1, r2, r3, t = np.fromstring(line[23:], dtype=np.float, count=4, sep=" ")
r1, r2, r3, t = np.fromstring(line[23:], dtype=np.float64, count=4, sep=" ")
sym_ops[op_num]["rotation"].append([r1, r2, r3])
sym_ops[op_num]["translation"].append(t)

Expand All @@ -429,7 +429,7 @@ def symmetry_operators(self):

operators = list()
for op in sym_ops.values():
mat = np.eye(4, dtype=np.float)
mat = np.eye(4, dtype=np.float64)
mat[:3, :3] = np.array(op["rotation"])
mat[:3, 3] = np.array(op["translation"])
operators.append(mat)
Expand Down Expand Up @@ -1051,7 +1051,7 @@ def lattice_vectors_alat(self):

def reciprocal_vectors_alat(self):
"""
Returns the reciprocal lattice vectors associated to a structure, in units of :math:`2 \pi / alat`.
Returns the reciprocal lattice vectors associated to a structure, in units of :math:`2 \\pi / alat`.
Returns
-------
Expand Down
2 changes: 1 addition & 1 deletion crystals/tests/test_lattice.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def test_lattice_array_dtype():
""" Test that the data-type of array(Lattice(...)) is respected """
arr = np.random.random(size=(3, 3))
lattice = Lattice(arr)
assert np.array(lattice, dtype=np.int).dtype, np.int
assert np.array(lattice, dtype=np.int32).dtype, np.int32


def test_lattice_frac_mesh():
Expand Down
1 change: 1 addition & 0 deletions pinkindexer
Submodule pinkindexer added at d00697

0 comments on commit 0fa3eb0

Please sign in to comment.