Skip to content

Commit

Permalink
Merge pull request #1655 from jamesmkrieger/remove_numpy_alias_types
Browse files Browse the repository at this point in the history
remove np alias types
  • Loading branch information
jamesmkrieger authored Mar 27, 2024
2 parents ef3d678 + afadd25 commit ade72dd
Show file tree
Hide file tree
Showing 26 changed files with 88 additions and 84 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["2.7", "3.8", "3.9", "3.10"]
python-version: ["2.7", "3.8", "3.9", "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
Expand All @@ -29,7 +29,7 @@ jobs:
if [[ ${{ matrix.python-version }} != "2.7" ]]; then conda config --add channels conda-forge; fi
conda create --yes -n test python=${{ matrix.python-version }}
source activate test
conda install --yes numpy scipy nose pyparsing requests
conda install --yes numpy scipy nose requests
if [[ ${{ matrix.python-version }} == "2.7" ]]; then conda install --yes unittest2; else conda install --yes pdbfixer; fi
pip install mmtf-python scikit-learn
pip install .
Expand Down
4 changes: 2 additions & 2 deletions PKG-INFO
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
Classifier: Topic :: Scientific/Engineering :: Chemistry
Requires: numpy (>=1.10)
Requires: pyparsing
Requires: pyparsing (<=3.1.1)
Requires: biopython
Requires: scipy
Provides: prody (2.1.2)
Provides: prody
6 changes: 3 additions & 3 deletions prody/compounds/pdbligands.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def fetchPDBLigand(cci, filename=None):
resnums = np.ones(n_atoms, dtype=ATOMIC_FIELDS['charge'].dtype)

alternate_atomnames = np.zeros(n_atoms, dtype=ATOMIC_FIELDS['name'].dtype)
leaving_atom_flags = np.zeros(n_atoms, np.bool)
aromatic_flags = np.zeros(n_atoms, np.bool)
stereo_configs = np.zeros(n_atoms, np.bool)
leaving_atom_flags = np.zeros(n_atoms, bool)
aromatic_flags = np.zeros(n_atoms, bool)
stereo_configs = np.zeros(n_atoms, bool)
ordinals = np.zeros(n_atoms, int)

name2index = {}
Expand Down
2 changes: 1 addition & 1 deletion prody/dynamics/signature.py
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,7 @@ def showSignatureDistribution(signature, **kwargs):
bins = kwargs.pop('bins', 'auto')
if bins == 'auto':
_, bins = np.histogram(W.flatten(), bins='auto')
elif np.isscalar(bins) and isinstance(bins, (int, np.integer)):
elif np.isscalar(bins) and isinstance(bins, int):
step = (W.max() - W.min())/bins
bins = np.arange(W.min(), W.max(), step)

Expand Down
6 changes: 3 additions & 3 deletions prody/sequence/msa.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __getitem__(self, index):
if isinstance(rows, list):
rows = self.getIndex(rows) or rows
elif isinstance(rows, int):
return Sequence(self._msa[rows, cols].tostring(),
return Sequence(self._msa[rows, cols].tobytes(),
self._labels[rows])
elif isinstance(rows, str):
try:
Expand All @@ -164,7 +164,7 @@ def __getitem__(self, index):
.format(index))
else:
if isinstance(rows, int):
return Sequence(self._msa[rows, cols].tostring(),
return Sequence(self._msa[rows, cols].tobytes(),
self._labels[rows])

if cols is None:
Expand Down Expand Up @@ -546,7 +546,7 @@ def refineMSA(msa, index=None, label=None, rowocc=None, seqid=None, colocc=None,
from prody.utilities import GAP_PENALTY, GAP_EXT_PENALTY, ALIGNMENT_METHOD

chseq = chain.getSequence()
algn = alignBioPairwise(pystr(arr[index].tostring().upper()), pystr(chseq),
algn = alignBioPairwise(pystr(arr[index].tobytes().upper()), pystr(chseq),
"local",
MATCH_SCORE, MISMATCH_SCORE,
GAP_PENALTY, GAP_EXT_PENALTY,
Expand Down
2 changes: 1 addition & 1 deletion prody/sequence/msafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def setSlice(self, slice):
else:
self._slice = slice
self._slicer = lambda seq, slc=slice: fromstring(seq,
'|S1')[slc].tostring()
'|S1')[slc].tobytes()
else:
self._slice = slice
self._slicer = lambda seq, slc=slice: seq[slc]
Expand Down
4 changes: 2 additions & 2 deletions prody/sequence/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ def _array(self):
def __str__(self):

if PY3K:
return self._array.tostring().decode()
return self._array.tobytes().decode()
else:
return self._array.tostring()
return self._array.tobytes()

def __len__(self):

Expand Down
6 changes: 2 additions & 4 deletions prody/tests/apps/test_prody_anm.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

from numpy.testing import *

try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec
from prody.utilities import importDec
dec = importDec()

from prody.tests.datafiles import TEMPDIR, pathDatafile

Expand Down
7 changes: 3 additions & 4 deletions prody/tests/apps/test_prody_catdcd.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from prody.tests import TestCase, skipIf, skipUnless

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import parsePDB, DCDFile, parseDCD

Expand Down
7 changes: 3 additions & 4 deletions prody/tests/apps/test_prody_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from subprocess import Popen, PIPE

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import LOGGER
LOGGER.verbosity = None
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/apps/test_prody_gnm.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from prody.tests import TestCase, skipIf, skipUnless

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody.tests.datafiles import TEMPDIR, pathDatafile

Expand Down
7 changes: 3 additions & 4 deletions prody/tests/apps/test_prody_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
from prody.tests import TestCase, skipIf, skipUnless

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody.tests.datafiles import TEMPDIR, pathDatafile

Expand Down
7 changes: 3 additions & 4 deletions prody/tests/atomic/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@
import inspect
import numpy as np
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody import *
from prody import LOGGER
from prody.tests import unittest
from prody.tests.datafiles import *
from prody.atomic.atommap import DUMMY

from prody.utilities import importDec
dec = importDec()

prody.atomic.select.DEBUG = False
LOGGER.verbosity = 'none'

Expand Down
2 changes: 1 addition & 1 deletion prody/tests/database/test_pfam.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def testUniprotAccMulti(self):
'searchPfam failed to return a dict instance')

self.assertEqual(sorted(list(a.keys()))[:2], ['PF00060', 'PF00497'],
'searchPfam failed to return the right domain family IDs')
'searchPfam failed to return the right domain family IDs')

def testPdbIdChMulti(self):
"""Test the outcome of a simple search scenario using a PDB ID
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/dynamics/test_enms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import numpy as np
from numpy import arange
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/dynamics/test_pca.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import numpy as np
from numpy import arange
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/proteins/test_ciffile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@

import numpy as np
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/proteins/test_dssp.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""This module contains unit tests for :mod:`~prody.proteins`."""

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
14 changes: 7 additions & 7 deletions prody/tests/proteins/test_insty.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,25 @@ def setUp(self):
np.save('test_2k39_all.npy', self.data_all, allow_pickle=True)

self.data_hbs = calcHydrogenBondsTrajectory(self.ATOMS)
np.save('test_2k39_hbs.npy', self.data_hbs, allow_pickle=True)
np.save('test_2k39_hbs.npy', np.array(self.data_hbs, dtype=object), allow_pickle=True)

self.data_sbs = calcSaltBridgesTrajectory(self.ATOMS)
np.save('test_2k39_sbs.npy', self.data_sbs, allow_pickle=True)
np.save('test_2k39_sbs.npy', np.array(self.data_sbs, dtype=object), allow_pickle=True)

self.data_rib = calcRepulsiveIonicBondingTrajectory(self.ATOMS)
np.save('test_2k39_rib.npy', self.data_rib, allow_pickle=True)
np.save('test_2k39_rib.npy', np.array(self.data_rib, dtype=object), allow_pickle=True)

self.data_PiStack = calcPiStackingTrajectory(self.ATOMS)
np.save('test_2k39_PiStack.npy', self.data_PiStack, allow_pickle=True)
np.save('test_2k39_PiStack.npy', np.array(self.data_PiStack, dtype=object), allow_pickle=True)

self.data_PiCat = calcPiCationTrajectory(self.ATOMS)
np.save('test_2k39_PiCat.npy', self.data_PiCat, allow_pickle=True)
np.save('test_2k39_PiCat.npy', np.array(self.data_PiCat, dtype=object), allow_pickle=True)

self.data_hph = calcHydrophobicTrajectory(self.ATOMS)
np.save('test_2k39_hph.npy', self.data_hph, allow_pickle=True)
np.save('test_2k39_hph.npy', np.array(self.data_hph, dtype=object), allow_pickle=True)

self.data_disu = calcDisulfideBondsTrajectory(self.ATOMS)
np.save('test_2k39_disu.npy', self.data_disu, allow_pickle=True)
np.save('test_2k39_disu.npy', np.array(self.data_disu, dtype=object), allow_pickle=True)

def testAllInsteractions(self):
"""Test for all types of interactions."""
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/proteins/test_localpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import numpy as np
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/proteins/test_pdbfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@

import numpy as np
from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
7 changes: 3 additions & 4 deletions prody/tests/proteins/test_wwpdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
import os

from numpy.testing import *
try:
import numpy.testing.decorators as dec
except ImportError:
from numpy.testing import dec

from prody.utilities import importDec
dec = importDec()

from prody import *
from prody import LOGGER
Expand Down
5 changes: 3 additions & 2 deletions prody/tests/sequence/test_msafile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
from os.path import join

from numpy import array, log, zeros, char
from numpy.testing import assert_array_equal, dec
from numpy.testing import assert_array_equal

from prody.tests.datafiles import *
from prody.tests import TEMPDIR
from prody import MSA, MSAFile, parseMSA, LOGGER, writeMSA
from prody.utilities import createStringIO
from prody.utilities import createStringIO, importDec
dec = importDec()

LOGGER.verbosity = None

Expand Down
20 changes: 19 additions & 1 deletion prody/utilities/misctools.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
'getDataPath', 'openData', 'chr2', 'toChararray', 'interpY', 'cmp', 'pystr',
'getValue', 'indentElement', 'isPDB', 'isURL', 'isListLike', 'isSymmetric', 'makeSymmetric',
'getDistance', 'fastin', 'createStringIO', 'div0', 'wmean', 'bin2dec', 'wrapModes',
'fixArraySize', 'decToHybrid36', 'hybrid36ToDec', 'DTYPE', 'checkIdentifiers', 'split', 'mad']
'fixArraySize', 'decToHybrid36', 'hybrid36ToDec', 'DTYPE', 'checkIdentifiers', 'split', 'mad',
'importDec']

DTYPE = array(['a']).dtype.char # 'S' for PY2K and 'U' for PY3K
CURSORS = []
Expand Down Expand Up @@ -784,3 +785,20 @@ def _mad(x):
return median(abs(x - med))

return _mad(x)


def importDec():
"""Returns one of :mod:`scipy.linalg` or :mod:`numpy.linalg`."""

try:
import numpy.testing.decorators as dec
except ImportError:
try:
from numpy.testing import dec
except ImportError:
try:
import numpy.testing._private.decorators as dec
except ImportError:
from pytest import mark as dec

return dec
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build-system]
requires = ["setuptools", "wheel", "numpy>=1.10,<1.24", "pyparsing", "scipy"]
requires = ["setuptools", "wheel", "numpy>=1.10,<1.25", "pyparsing<=3.1.1", "scipy"]
11 changes: 5 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
sys.exit()

if sys.version_info[:2] == (2, 7) or sys.version_info[:2] <= (3, 5):
INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython<=1.76', 'pyparsing', 'scipy']
INSTALL_REQUIRES=['numpy>=1.10,<1.25', 'biopython<=1.76', 'pyparsing', 'scipy']
else:
INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython', 'pyparsing', 'scipy', 'setuptools']
INSTALL_REQUIRES=['numpy>=1.10,<1.24', 'biopython', 'pyparsing<=3.1.1', 'scipy', 'setuptools']

if sys.version_info[0] == 3:
if sys.version_info[1] < 6:
sys.stderr.write('Python 3.5 and older is not supported\n')
sys.exit()
if sys.version_info[0] == 3 and sys.version_info[1] < 6:
sys.stderr.write('Python 3.5 and older is not supported\n')
sys.exit()

if os.name == 'java':
sys.stderr.write('JavaOS is not supported\n')
Expand Down

0 comments on commit ade72dd

Please sign in to comment.