Skip to content

Commit 2c72933

Browse files
orbeckstIAlibay
andauthored
adopt NEP 29 (#111)
- fix #102 - adopt NEP 29 - removed support for Python 2.7 and Python <3.7 - removed six as dependency (setup.py and CI) - removed all `from __future__ import ...` statements - removed special Python division handling (and tests) - update CHANGELOG - set pip metadata to MATURE Co-authored-by: Irfan Alibay <IAlibay@users.noreply.github.com>
1 parent 6fcf00e commit 2c72933

13 files changed

Lines changed: 22 additions & 104 deletions

File tree

.github/workflows/gh-ci.yaml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,12 @@ jobs:
2323
fail-fast: false
2424
matrix:
2525
os: [ubuntu-latest, ]
26-
python-version: [2.7, 3.5, 3.6, 3.7, 3.8, 3.9, "3.10"]
26+
python-version: ["3.8", "3.9", "3.10"]
2727
include:
2828
- os: windows-latest
29-
python-version: 2.7
30-
- os: windows-latest
31-
python-version: 3.9
32-
- os: macos-latest
33-
python-version: 2.7
29+
python-version: "3.9"
3430
- os: macos-latest
35-
python-version: 3.9
31+
python-version: "3.9"
3632

3733
steps:
3834
- uses: actions/checkout@v2
@@ -49,7 +45,7 @@ jobs:
4945

5046
- name: install package deps
5147
run: |
52-
mamba install numpy scipy mrcfile six pytest pytest-cov codecov
48+
mamba install numpy scipy mrcfile pytest pytest-cov codecov
5349
5450
- name: check install
5551
run: |

CHANGELOG

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ The rules for this file:
1313
* accompany each entry with github issue/PR number (Issue #xyz)
1414

1515
------------------------------------------------------------------------------
16+
04/30/2022 orbeckst, IAlibay
17+
18+
* 1.0.0
19+
20+
Changes
21+
22+
* gridDataFormats now follows NEP29 (#102)
23+
* removed support for Python 2.7 and Python <3.8 (#102)
24+
25+
1626
02/20/2022 orbeckst, tluchko, IAlibay
1727

1828
* 0.7.0

ci/requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
six
21
numpy
32
scipy
43
sphinx-sitemap

gridData/CCP4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,6 @@
132132
import warnings
133133
import struct
134134
import numpy as np
135-
from six.moves import range
136135

137136
from .gOpenMol import Record
138137

gridData/OpenDX.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,8 @@
164164
---------------------
165165
166166
"""
167-
from __future__ import absolute_import, division, with_statement
168-
169167
import numpy
170168
import re
171-
from six import next
172-
from six.moves import range
173169
import gzip
174170

175171
import warnings

gridData/core.py

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,9 @@
2323
---------------------
2424
2525
"""
26-
# Having consistent truedivision in this module is essential so that
27-
# its behavior is fully consistent in Python 2 and Python 3.
28-
from __future__ import absolute_import, division
29-
30-
import six
31-
from six.moves import cPickle, range, zip
32-
3326
import os
3427
import errno
28+
import pickle
3529

3630
import numpy
3731

@@ -226,7 +220,7 @@ def __init__(self, grid=None, edges=None, origin=None, delta=None,
226220
self.interpolation_cval = None # default to using min(grid)
227221

228222
if grid is not None:
229-
if isinstance(grid, six.string_types):
223+
if isinstance(grid, str):
230224
# can probably safely try to load() it...
231225
filename = grid
232226
else:
@@ -555,7 +549,7 @@ def load(self, filename, file_format=None):
555549

556550
def _load_python(self, filename):
557551
with open(filename, 'rb') as f:
558-
saved = cPickle.load(f)
552+
saved = pickle.load(f)
559553
self._load(grid=saved['grid'],
560554
edges=saved['edges'],
561555
metadata=saved['metadata'])
@@ -641,7 +635,7 @@ def _export_python(self, filename, **kwargs):
641635
"""
642636
data = dict(grid=self.grid, edges=self.edges, metadata=self.metadata)
643637
with open(filename, 'wb') as f:
644-
cPickle.dump(data, f, cPickle.HIGHEST_PROTOCOL)
638+
pickle.dump(data, f, pickle.HIGHEST_PROTOCOL)
645639

646640
def _export_dx(self, filename, type=None, typequote='"', **kwargs):
647641
"""Export the density grid to an OpenDX file.
@@ -835,23 +829,9 @@ def __mul__(self, other):
835829
return self.__class__(self.grid * _grid(other), edges=self.edges)
836830

837831
def __truediv__(self, other):
838-
# truediv will always do true division (in Python 2 and Python 3);
839-
# we use from __future__ include division everywhere
840832
self.check_compatible(other)
841833
return self.__class__(self.grid / _grid(other), edges=self.edges)
842834

843-
def __div__(self, other):
844-
# in Python 2 only (without __future__.division): will do "classic division"
845-
# https://docs.python.org/2/reference/datamodel.html#object.__div__
846-
if not six.PY2:
847-
raise NotImplementedError(
848-
"__div__ is only available in Python 2, use __truediv__")
849-
self.check_compatible(other)
850-
return self.__class__(
851-
self.grid.__div__(
852-
_grid(other)),
853-
edges=self.edges)
854-
855835
def __floordiv__(self, other):
856836
self.check_compatible(other)
857837
return self.__class__(self.grid // _grid(other), edges=self.edges)
@@ -880,18 +860,6 @@ def __rtruediv__(self, other):
880860
self.check_compatible(other)
881861
return self.__class__(_grid(other) / self.grid, edges=self.edges)
882862

883-
def __rdiv__(self, other):
884-
# in Python 2 only (without __future__.division): will do "classic division"
885-
# https://docs.python.org/2/reference/datamodel.html#object.__div__
886-
if not six.PY2:
887-
raise NotImplementedError(
888-
"__rdiv__ is only available in Python 2, use __rtruediv__")
889-
self.check_compatible(other)
890-
return self.__class__(
891-
self.grid.__rdiv__(
892-
_grid(other)),
893-
edges=self.edges)
894-
895863
def __rfloordiv__(self, other):
896864
self.check_compatible(other)
897865
return self.__class__(_grid(other) // self.grid, edges=self.edges)

gridData/gOpenMol.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,9 @@
127127
-------
128128
129129
"""
130-
131-
from __future__ import absolute_import, division, with_statement
132-
133130
import warnings
134131
import struct
135132
import numpy
136-
from six.moves import range
137133

138134
class Record(object):
139135
def __init__(self, key, bintype, values=None):

gridData/mrc.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@
3131
-------
3232
3333
"""
34-
from __future__ import absolute_import
35-
from six.moves import range
36-
3734
import numpy as np
3835
import mrcfile
3936

gridData/tests/test_dx.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, division
2-
31
import numpy as np
42
from numpy.testing import assert_equal, assert_almost_equal
53

gridData/tests/test_gOpenMol.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import absolute_import, division
2-
31
import numpy as np
42
from numpy.testing import (assert_almost_equal,
53
assert_equal)

0 commit comments

Comments
 (0)