Unverified Commit cb293447 authored by Sander Roet's avatar Sander Roet Committed by GitHub
Browse files

resolve scipy 1.8.0 io.netcdf deprecation warning (#3451)

parent 129cece9
...@@ -790,7 +790,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No ...@@ -790,7 +790,7 @@ def readAmberSystem(topology, prmtop_filename=None, prmtop_loader=None, shake=No
for (iAtom, jAtom, k, rMin) in prmtop.getBondsNoH(): for (iAtom, jAtom, k, rMin) in prmtop.getBondsNoH():
force.addBond(iAtom, jAtom, rMin, 2*k) force.addBond(iAtom, jAtom, rMin, 2*k)
system.addForce(force) system.addForce(force)
# Add Urey-Bradley terms. # Add Urey-Bradley terms.
if len(prmtop.getUreyBradleys()) > 0: if len(prmtop.getUreyBradleys()) > 0:
if verbose: print("Adding Urey-Bradley terms...") if verbose: print("Adding Urey-Bradley terms...")
...@@ -1434,9 +1434,14 @@ class AmberNetcdfRestart(object): ...@@ -1434,9 +1434,14 @@ class AmberNetcdfRestart(object):
""" """
def __init__(self, filename, asNumpy=False): def __init__(self, filename, asNumpy=False):
try: try:
from scipy.io.netcdf import NetCDFFile from scipy.io import NetCDFFile
except ImportError: except ImportError:
raise ImportError('scipy is necessary to parse NetCDF restarts') # scipy < 1.8.0
try:
from scipy.io.netcdf import NetCDFFile
except ImportError:
raise ImportError('scipy is necessary to parse NetCDF '
'restarts')
self.filename = filename self.filename = filename
self.velocities = self.boxVectors = self.time = None self.velocities = self.boxVectors = self.time = None
......
...@@ -5,11 +5,15 @@ from openmm import * ...@@ -5,11 +5,15 @@ from openmm import *
from openmm.unit import * from openmm.unit import *
import openmm.app.element as elem import openmm.app.element as elem
try: try:
from scipy.io import netcdf from scipy.io import NetCDFFile
SCIPY_IMPORT_FAILED = False SCIPY_IMPORT_FAILED = False
except: except ImportError:
SCIPY_IMPORT_FAILED = True try:
# scipy < 1.8.0
from scipy.io import netcdf
SCIPY_IMPORT_FAILED = False
except:
SCIPY_IMPORT_FAILED = True
def compareByElement(array1, array2, cmp): def compareByElement(array1, array2, cmp):
for x, y in zip(array1, array2): for x, y in zip(array1, array2):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment