8000 Fixed compatibility with NumPy 2.0+ by vedranmiletic · Pull Request #1374 · ParmEd/ParmEd · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Fixed compatibility with NumPy 2.0+ #1374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parmed/amber/_amberparm.py
< 8000 td class="blob-code blob-code-context js-file-line"> """ Atomic velocities in units of angstroms/picoseconds """
Original file line number Diff line number Diff line change
Expand Up @@ -2147,7 +2147,7 @@ def box(self, value):
box[4] = box[4].value_in_unit(u.degrees)
if u.is_quantity(box[5]):
box[5] = box[5].value_in_unit(u.degrees)
box = np.array(box, dtype=np.float64, copy=False, subok=True).reshape((-1, 6))
box = np.asanyarray(box, dtype=np.float64).reshape((-1, 6))

# We are adding a box for the first time, so make sure we add some flags
if self._box is None:
Expand Down Expand Up @@ -2373,7 +2373,7 @@ def positions(self):
@property
def velocities(self):
return np.array(self.vels, copy=False).reshape(self.natom, 3)
return np.asarray(self.vels).reshape(self.natom, 3)

@property
def box_vectors(self):
Expand Down
8 changes: 4 additions & 4 deletions parmed/amber/asciicrd.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ def coordinates(self):
def coordinates(self, stuff):
if self._status == 'old':
raise RuntimeError('Cannot set coordinates on an old restart')
stuff = np.array(stuff, copy=False).ravel()
stuff = np.asarray(stuff).ravel()
if self.natom > 0 and len(stuff) != 3 * self.natom:
raise ValueError(f'Got {len(stuff)} coordinates for {self.natom} atoms')
if self._coords_written:
Expand Down Expand Up @@ -351,7 +351,7 @@ def velocities(self):
def velocities(self, stuff):
if self._status == 'old':
raise RuntimeError('Cannot set velocities on an old restart')
stuff = np.array(stuff, copy=False).ravel()
stuff = np.asarray(stuff).ravel()
if not self._coords_written:
raise RuntimeError('Coordinates must be set before velocities')
if self._cell_lengths_written or self._cell_angles_written:
Expand Down Expand Up @@ -413,7 +413,7 @@ def cell_lengths(self, stuff):
raise RuntimeError('Can only write cell lengths once')
if len(stuff) != 3:
raise ValueError('Expected 3 numbers for cell lengths')
self._cell_lengths = np.array(stuff, copy=False)
self._cell_lengths = np.asarray(stuff)
self._file.write('%12.7f%12.7f%12.7f' % (stuff[0], stuff[1], stuff[2]))
self._cell_lengths_written = True

Expand All @@ -429,7 +429,7 @@ def cell_angles(self, stuff):
raise RuntimeError('Can only write cell angles once')
if len(stuff) != 3:
raise ValueError('Expected 3 numbers for cell angles')
self._cell_angles = np.array(stuff, copy=False)
self._cell_angles = np.asarray(stuff)
self._file.write('%12.7f%12.7f%12.7f\n' % (stuff[0],stuff[1],stuff[2]))
self._cell_angles_written = True

Expand Down
2 changes: 1 addition & 1 deletion parmed/amber/netcdffiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def coordinates(self):

@coordinates.setter
def coordinates(self, stuff):
stuff = np.array(stuff, copy=False).reshape((self.atom, 3))
stuff = np.asarray(stuff).reshape((self.atom, 3))
self._ncfile.variables['coordinates'][:] = stuff
self.flush()

Expand Down
4 changes: 2 additions & 2 deletions parmed/formats/pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ def write(struct, dest, renumber=True, coordinates=None, altlocs='all',
symm_line = "REMARK 290 SMTRY" + fmt % tuple(arr_list)
dest.write(symm_line)
if coordinates is not None:
coords = np.array(coordinates, copy=False, subok=True)
coords = np.asanyarray(coordinates)
try:
coords = coords.reshape((-1, len(struct.atoms), 3))
except ValueError:
Expand Down Expand Up @@ -1646,7 +1646,7 @@ def write(struct, dest, renumber=True, coordinates=None,
sym.append([struct.space_group])
cont.append(sym)
if coordinates is not None:
coords = np.array(coordinates, copy=False, subok=True)
coords = np.asanyarray(coordinates)
try:
coords = coords.reshape((-1, len(struct.atoms), 3))
except ValueError:
Expand Down
2 changes: 1 addition & 1 deletion parmed/formats/pqr.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def write(struct, dest, renumber=True, coordinates=None,
struct.box[0], struct.box[1], struct.box[2], struct.box[3],
struct.box[4], struct.box[5]))
if coordinates is not None:
coords = np.array(coordinates, copy=False, subok=True)
coords = np.asanyarray(coordinates)
try:
coords = coords.reshape((-1, len(struct.atoms), 3))
except ValueError:
Expand Down
6 changes: 3 additions & 3 deletions parmed/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -1796,7 +1796,7 @@ def coordinates(self, value):
if u.is_quantity(value):
value = value.value_in_unit(u.angstroms)
value = list(value)
coords = np.array(value, dtype=np.float64, copy=False, subok=True)
coords = np.asanyarray(value, dtype=np.float64)
coords = coords.reshape((-1, len(self.atoms), 3))
if len(coords) > 0:
for a, xyz in zip(self.atoms, coords[0]):
Expand Down Expand Up @@ -1877,7 +1877,7 @@ def box(self, value):
box = value
else:
box = _strip_box_units(list(value))
box = np.array(box, dtype=np.float64, copy=False, subok=True)
box = np.asanyarray(box, dtype=np.float64)
if box.shape != (6,):
if len(box.shape) != 2 or box.shape[-1] != 6:
raise ValueError('Box information must be 6 floats')
Expand Down Expand Up @@ -1944,7 +1944,7 @@ def velocities(self, value):
except AttributeError:
pass
else:
value = np.array(value, copy=False).reshape(
value = np.asarray(value).reshape(
(-1, len(self.atoms), 3))
for atom, xyz in zip(self.atoms, value[0]):
atom.vx, atom.vy, atom.vz = xyz
Expand Down
0