|
23 | 23 | --------------------- |
24 | 24 |
|
25 | 25 | """ |
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 | | - |
33 | 26 | import os |
34 | 27 | import errno |
| 28 | +import pickle |
35 | 29 |
|
36 | 30 | import numpy |
37 | 31 |
|
@@ -226,7 +220,7 @@ def __init__(self, grid=None, edges=None, origin=None, delta=None, |
226 | 220 | self.interpolation_cval = None # default to using min(grid) |
227 | 221 |
|
228 | 222 | if grid is not None: |
229 | | - if isinstance(grid, six.string_types): |
| 223 | + if isinstance(grid, str): |
230 | 224 | # can probably safely try to load() it... |
231 | 225 | filename = grid |
232 | 226 | else: |
@@ -555,7 +549,7 @@ def load(self, filename, file_format=None): |
555 | 549 |
|
556 | 550 | def _load_python(self, filename): |
557 | 551 | with open(filename, 'rb') as f: |
558 | | - saved = cPickle.load(f) |
| 552 | + saved = pickle.load(f) |
559 | 553 | self._load(grid=saved['grid'], |
560 | 554 | edges=saved['edges'], |
561 | 555 | metadata=saved['metadata']) |
@@ -641,7 +635,7 @@ def _export_python(self, filename, **kwargs): |
641 | 635 | """ |
642 | 636 | data = dict(grid=self.grid, edges=self.edges, metadata=self.metadata) |
643 | 637 | with open(filename, 'wb') as f: |
644 | | - cPickle.dump(data, f, cPickle.HIGHEST_PROTOCOL) |
| 638 | + pickle.dump(data, f, pickle.HIGHEST_PROTOCOL) |
645 | 639 |
|
646 | 640 | def _export_dx(self, filename, type=None, typequote='"', **kwargs): |
647 | 641 | """Export the density grid to an OpenDX file. |
@@ -835,23 +829,9 @@ def __mul__(self, other): |
835 | 829 | return self.__class__(self.grid * _grid(other), edges=self.edges) |
836 | 830 |
|
837 | 831 | 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 |
840 | 832 | self.check_compatible(other) |
841 | 833 | return self.__class__(self.grid / _grid(other), edges=self.edges) |
842 | 834 |
|
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 | | - |
855 | 835 | def __floordiv__(self, other): |
856 | 836 | self.check_compatible(other) |
857 | 837 | return self.__class__(self.grid // _grid(other), edges=self.edges) |
@@ -880,18 +860,6 @@ def __rtruediv__(self, other): |
880 | 860 | self.check_compatible(other) |
881 | 861 | return self.__class__(_grid(other) / self.grid, edges=self.edges) |
882 | 862 |
|
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 | | - |
895 | 863 | def __rfloordiv__(self, other): |
896 | 864 | self.check_compatible(other) |
897 | 865 | return self.__class__(_grid(other) // self.grid, edges=self.edges) |
|
0 commit comments