persist 3.2__tar.gz → 3.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {persist-3.2 → persist-3.3.0}/PKG-INFO +28 -28
- {persist-3.2 → persist-3.3.0}/README.md +5 -3
- {persist-3.2 → persist-3.3.0}/pyproject.toml +50 -28
- {persist-3.2 → persist-3.3.0}/src/persist/archive.py +55 -47
- {persist-3.2 → persist-3.3.0}/src/persist/interfaces.py +1 -0
- {persist-3.2 → persist-3.3.0}/src/persist/objects.py +1 -0
- {persist-3.2 → persist-3.3.0}/src/persist/__init__.py +0 -0
- {persist-3.2 → persist-3.3.0}/src/persist/_contrib/RADLogic/__init__.py +0 -0
- {persist-3.2 → persist-3.3.0}/src/persist/_contrib/RADLogic/topsort.py +0 -0
- {persist-3.2 → persist-3.3.0}/src/persist/_contrib/README +0 -0
- {persist-3.2 → persist-3.3.0}/src/persist/_contrib/__init__.py +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: persist
|
|
3
|
-
Version: 3.
|
|
3
|
+
Version: 3.3.0
|
|
4
4
|
Summary: Persistent archival of python objects in an importable format.
|
|
5
5
|
Author-email: Michael McNeil Forbes <michael.forbes+python@gmail.com>
|
|
6
|
-
Requires-Python: >=3.
|
|
6
|
+
Requires-Python: >=3.8.20
|
|
7
7
|
Description-Content-Type: text/markdown
|
|
8
8
|
Classifier: Development Status :: 4 - Beta
|
|
9
9
|
Classifier: Intended Audience :: Developers
|
|
@@ -12,34 +12,31 @@ Classifier: Topic :: Utilities
|
|
|
12
12
|
Classifier: Operating System :: OS Independent
|
|
13
13
|
Classifier: Programming Language :: Python
|
|
14
14
|
Classifier: Programming Language :: Python :: 3
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.6
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.7
|
|
17
15
|
Classifier: Programming Language :: Python :: 3.8
|
|
18
16
|
Classifier: Programming Language :: Python :: 3.9
|
|
19
17
|
Classifier: Programming Language :: Python :: 3.10
|
|
20
18
|
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
23
|
Classifier: License :: OSI Approved :: BSD License
|
|
22
|
-
Requires-Dist: six>=1.16.0
|
|
23
|
-
Requires-Dist: zope-interface>=5.5.2
|
|
24
|
-
Requires-Dist:
|
|
25
|
-
Requires-Dist:
|
|
26
|
-
Requires-Dist:
|
|
27
|
-
Requires-Dist:
|
|
28
|
-
Requires-Dist:
|
|
29
|
-
Requires-Dist:
|
|
30
|
-
Requires-Dist:
|
|
31
|
-
Requires-Dist:
|
|
32
|
-
Requires-Dist:
|
|
33
|
-
Requires-Dist: mmf-setup>=0.4.11 ; extra == "docs"
|
|
34
|
-
Requires-Dist: scipy >= 1.5.4 ; extra == "full" and ( python_version < "3.7")
|
|
35
|
-
Requires-Dist: scipy >= 1.7.3 ; extra == "full" and ( python_version < "3.10" and python_version >= "3.7")
|
|
24
|
+
Requires-Dist: six >= 1.16.0
|
|
25
|
+
Requires-Dist: zope-interface >= 5.5.2
|
|
26
|
+
Requires-Dist: persist[full, test, docs] ; extra == "all"
|
|
27
|
+
Requires-Dist: sphinx >= 5.3.0 ; extra == "docs"
|
|
28
|
+
Requires-Dist: nbsphinx >= 0.8.8 ; extra == "docs"
|
|
29
|
+
Requires-Dist: pycallgraph >= 1.0.1 ; extra == "docs"
|
|
30
|
+
Requires-Dist: sphinx-rtd-theme >= 1.2.0 ; extra == "docs"
|
|
31
|
+
Requires-Dist: sphinxcontrib-zopeext >= 0.3.3 ; extra == "docs"
|
|
32
|
+
Requires-Dist: ipython >= 7.23.1 ; extra == "docs"
|
|
33
|
+
Requires-Dist: mmf-setup >= 0.4.11 ; extra == "docs"
|
|
34
|
+
Requires-Dist: scipy >= 1.7.3 ; extra == "full" and ( python_version < "3.10")
|
|
36
35
|
Requires-Dist: scipy >= 1.10.1 ; extra == "full" and ( python_version >= "3.10")
|
|
37
|
-
Requires-Dist: numpy>=1.21.0 ; extra == "full"
|
|
38
|
-
Requires-Dist: h5py>=3.1
|
|
39
|
-
Requires-Dist:
|
|
40
|
-
Requires-Dist:
|
|
41
|
-
Requires-Dist: coverage[toml] ; extra == "test" and ( python_version < "3.7")
|
|
42
|
-
Requires-Dist: coverage[toml]>=7.2.2 ; extra == "test" and ( python_version >= "3.7")
|
|
36
|
+
Requires-Dist: numpy >= 1.21.0 ; extra == "full"
|
|
37
|
+
Requires-Dist: h5py >= 3.2.1 ; extra == "full" and ( python_version < "3.15")
|
|
38
|
+
Requires-Dist: pytest >= 7.0.1 ; extra == "test"
|
|
39
|
+
Requires-Dist: coverage[toml] >= 7.2.2 ; extra == "test"
|
|
43
40
|
Requires-Dist: persist[full] ; extra == "test"
|
|
44
41
|
Project-URL: Git Mirror, https://github.com/forbes-group/persist
|
|
45
42
|
Project-URL: Issues, https://alum.mit.edu/www/mforbes/hg/forbes-group/persist/issues
|
|
@@ -49,6 +46,7 @@ Provides-Extra: all
|
|
|
49
46
|
Provides-Extra: docs
|
|
50
47
|
Provides-Extra: full
|
|
51
48
|
Provides-Extra: test
|
|
49
|
+
Import-Name: persist
|
|
52
50
|
|
|
53
51
|
# Persistent Archival of Python Objects
|
|
54
52
|
|
|
@@ -71,10 +69,12 @@ This package provides a method for archiving python objects to disk for long-ter
|
|
|
71
69
|
http://persist.readthedocs.org
|
|
72
70
|
|
|
73
71
|
**Source:**
|
|
74
|
-
https://
|
|
72
|
+
https://gitlab.com/coldatoms/utilities/persist
|
|
73
|
+
<!-- https://alum.mit.edu/www/mforbes/hg/forbes-group/persist -->
|
|
75
74
|
|
|
76
75
|
**Issues:**
|
|
77
|
-
https://
|
|
76
|
+
https://gitlab.com/coldatoms/utilities/persist/-/work_items
|
|
77
|
+
<!-- https://alum.mit.edu/www/mforbes/hg/forbes-group/issues -->
|
|
78
78
|
|
|
79
79
|
## Installing
|
|
80
80
|
|
|
@@ -87,6 +87,6 @@ python3 -m pip install persist
|
|
|
87
87
|
or from source:
|
|
88
88
|
|
|
89
89
|
```bash
|
|
90
|
-
python3 -m pip install
|
|
90
|
+
python3 -m pip install git+https://gitlab.com/coldatoms/utilities/persist
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -19,10 +19,12 @@ This package provides a method for archiving python objects to disk for long-ter
|
|
|
19
19
|
http://persist.readthedocs.org
|
|
20
20
|
|
|
21
21
|
**Source:**
|
|
22
|
-
https://
|
|
22
|
+
https://gitlab.com/coldatoms/utilities/persist
|
|
23
|
+
<!-- https://alum.mit.edu/www/mforbes/hg/forbes-group/persist -->
|
|
23
24
|
|
|
24
25
|
**Issues:**
|
|
25
|
-
https://
|
|
26
|
+
https://gitlab.com/coldatoms/utilities/persist/-/work_items
|
|
27
|
+
<!-- https://alum.mit.edu/www/mforbes/hg/forbes-group/issues -->
|
|
26
28
|
|
|
27
29
|
## Installing
|
|
28
30
|
|
|
@@ -35,5 +37,5 @@ python3 -m pip install persist
|
|
|
35
37
|
or from source:
|
|
36
38
|
|
|
37
39
|
```bash
|
|
38
|
-
python3 -m pip install
|
|
40
|
+
python3 -m pip install git+https://gitlab.com/coldatoms/utilities/persist
|
|
39
41
|
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = 'persist'
|
|
3
|
-
version = '3.
|
|
3
|
+
version = '3.3.0'
|
|
4
4
|
description = 'Persistent archival of python objects in an importable format.'
|
|
5
5
|
readme = 'README.md'
|
|
6
6
|
authors = [
|
|
@@ -14,52 +14,50 @@ classifiers = [
|
|
|
14
14
|
"Operating System :: OS Independent",
|
|
15
15
|
"Programming Language :: Python",
|
|
16
16
|
"Programming Language :: Python :: 3",
|
|
17
|
-
"Programming Language :: Python :: 3.6",
|
|
18
|
-
"Programming Language :: Python :: 3.7",
|
|
19
17
|
"Programming Language :: Python :: 3.8",
|
|
20
18
|
"Programming Language :: Python :: 3.9",
|
|
21
19
|
"Programming Language :: Python :: 3.10",
|
|
22
20
|
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Programming Language :: Python :: 3.15",
|
|
23
25
|
"License :: OSI Approved :: BSD License",
|
|
24
26
|
]
|
|
25
27
|
license = {text = 'LGPL-2.1-or-later'}
|
|
26
28
|
|
|
27
29
|
######################################################################
|
|
28
30
|
# Dependencies
|
|
29
|
-
requires-python = '>=3.
|
|
31
|
+
requires-python = '>=3.8.20'
|
|
30
32
|
#requires-python = '~=3.10.0'
|
|
31
33
|
dependencies = [
|
|
32
|
-
"six>=1.16.0",
|
|
33
|
-
"zope-interface>=5.5.2",
|
|
34
|
-
'importlib-metadata>=4.8.3; python_version < "3.8"',
|
|
34
|
+
"six >= 1.16.0",
|
|
35
|
+
"zope-interface >= 5.5.2",
|
|
35
36
|
]
|
|
36
37
|
|
|
37
38
|
[project.optional-dependencies]
|
|
38
39
|
test = [
|
|
39
|
-
"pytest>=7.0.1",
|
|
40
|
-
#"pytest-cov>=4.0.0",
|
|
41
|
-
'coverage[toml]
|
|
42
|
-
'coverage[toml]>=7.2.2; python_version >= "3.7"',
|
|
40
|
+
"pytest >= 7.0.1",
|
|
41
|
+
#"pytest-cov >= 4.0.0",
|
|
42
|
+
'coverage[toml] >= 7.2.2',
|
|
43
43
|
'persist[full]',
|
|
44
44
|
]
|
|
45
45
|
docs = [
|
|
46
|
-
"sphinx>=5.3.0",
|
|
47
|
-
"nbsphinx>=0.8.8",
|
|
48
|
-
"pycallgraph>=1.0.1",
|
|
49
|
-
"sphinx-rtd-theme>=1.2.0",
|
|
50
|
-
"sphinxcontrib-zopeext>=0.3.3",
|
|
51
|
-
'ipython >= 7.
|
|
52
|
-
|
|
53
|
-
"mmf-setup>=0.4.11",
|
|
46
|
+
"sphinx >= 5.3.0",
|
|
47
|
+
"nbsphinx >= 0.8.8",
|
|
48
|
+
"pycallgraph >= 1.0.1",
|
|
49
|
+
"sphinx-rtd-theme >= 1.2.0",
|
|
50
|
+
"sphinxcontrib-zopeext >= 0.3.3",
|
|
51
|
+
'ipython >= 7.23.1',
|
|
52
|
+
"mmf-setup >= 0.4.11",
|
|
54
53
|
]
|
|
55
54
|
full = [
|
|
56
|
-
'scipy >= 1.
|
|
57
|
-
'scipy >= 1.7.3; python_version < "3.10" and python_version >= "3.7"',
|
|
55
|
+
'scipy >= 1.7.3; python_version < "3.10"',
|
|
58
56
|
'scipy >= 1.10.1; python_version >= "3.10"',
|
|
59
57
|
# This version of numpy has universal wheels
|
|
60
|
-
'numpy>=1.21.0
|
|
61
|
-
|
|
62
|
-
'h5py >= 3.2.1; python_version
|
|
58
|
+
'numpy >= 1.21.0',
|
|
59
|
+
# h5py does not yet support python 3.15
|
|
60
|
+
'h5py >= 3.2.1; python_version < "3.15"',
|
|
63
61
|
]
|
|
64
62
|
all = [
|
|
65
63
|
'persist[full,test,docs]',
|
|
@@ -75,9 +73,9 @@ documentation = 'http://persist.readthedocs.org'
|
|
|
75
73
|
[tool.pdm]
|
|
76
74
|
[tool.pdm.dev-dependencies]
|
|
77
75
|
dev = [
|
|
78
|
-
"flit-core>=3.8.0",
|
|
79
|
-
"pip>=21.3.1",
|
|
80
|
-
"ipython
|
|
76
|
+
"flit-core >= 3.8.0",
|
|
77
|
+
"pip >= 21.3.1",
|
|
78
|
+
"ipython >= 7.23.1"
|
|
81
79
|
]
|
|
82
80
|
|
|
83
81
|
[tool.pdm.build]
|
|
@@ -85,7 +83,7 @@ includes = []
|
|
|
85
83
|
[build-system]
|
|
86
84
|
#requires = ["pdm-backend"]
|
|
87
85
|
#build-backend = "pdm.backend"
|
|
88
|
-
requires = ["flit-core>=3.4"]
|
|
86
|
+
requires = ["flit-core >= 3.4"]
|
|
89
87
|
build-backend = "flit_core.buildapi"
|
|
90
88
|
|
|
91
89
|
######################################################################
|
|
@@ -135,6 +133,7 @@ fail_under = 96
|
|
|
135
133
|
######################################################################
|
|
136
134
|
# Black
|
|
137
135
|
[tool.black]
|
|
136
|
+
target-version = ["py311"]
|
|
138
137
|
exclude = '''
|
|
139
138
|
/(
|
|
140
139
|
\.git
|
|
@@ -146,3 +145,26 @@ exclude = '''
|
|
|
146
145
|
| dist
|
|
147
146
|
)/
|
|
148
147
|
'''
|
|
148
|
+
|
|
149
|
+
######################################################################
|
|
150
|
+
# Pixi
|
|
151
|
+
# Used to provision test environments.
|
|
152
|
+
[tool.pixi.workspace]
|
|
153
|
+
channels = ["conda-forge"]
|
|
154
|
+
platforms = ["osx-arm64", "linux-64"]
|
|
155
|
+
|
|
156
|
+
[tool.pixi.pypi-dependencies]
|
|
157
|
+
persist = { path = ".", editable = true }
|
|
158
|
+
|
|
159
|
+
[tool.pixi.environments]
|
|
160
|
+
default = { solve-group = "default" }
|
|
161
|
+
#all = { features = ["all"], solve-group = "default" }
|
|
162
|
+
#docs = { features = ["docs"], solve-group = "default" }
|
|
163
|
+
#full = { features = ["full"], solve-group = "default" }
|
|
164
|
+
test = { features = ["test"], solve-group = "default" }
|
|
165
|
+
|
|
166
|
+
[tool.pixi.tasks]
|
|
167
|
+
|
|
168
|
+
[tool.pixi.dependencies]
|
|
169
|
+
python = "3.15.*"
|
|
170
|
+
h5py = ">=3.16.0,<4"
|
|
@@ -206,32 +206,27 @@ unreliable::
|
|
|
206
206
|
except NameError: pass
|
|
207
207
|
|
|
208
208
|
"""
|
|
209
|
+
|
|
209
210
|
from __future__ import division, with_statement
|
|
210
211
|
|
|
211
212
|
from collections import OrderedDict
|
|
212
213
|
from contextlib import contextmanager
|
|
213
214
|
|
|
214
|
-
try: # Python 3 version
|
|
215
|
-
import builtins
|
|
216
|
-
import pickle
|
|
217
|
-
except ImportError: # pragma: no cover
|
|
218
|
-
# Python 2 version
|
|
219
|
-
import cPickle as pickle
|
|
220
|
-
import __builtin__ as builtins
|
|
221
215
|
import ast
|
|
216
|
+
import builtins
|
|
222
217
|
import copy
|
|
223
218
|
import inspect
|
|
224
219
|
import logging
|
|
225
220
|
import os
|
|
221
|
+
import pickle
|
|
226
222
|
import re
|
|
223
|
+
import six
|
|
227
224
|
import string
|
|
228
225
|
import sys
|
|
229
226
|
import time
|
|
230
227
|
import types
|
|
231
228
|
import warnings
|
|
232
229
|
|
|
233
|
-
import six
|
|
234
|
-
|
|
235
230
|
from ._contrib.RADLogic import topsort
|
|
236
231
|
|
|
237
232
|
try:
|
|
@@ -243,6 +238,10 @@ try:
|
|
|
243
238
|
import scipy.sparse
|
|
244
239
|
|
|
245
240
|
sp = scipy
|
|
241
|
+
|
|
242
|
+
if not hasattr(sp.sparse, "spmatrix"):
|
|
243
|
+
sp.sparse.spmatrix = sp.sparse.base.spmatrix
|
|
244
|
+
|
|
246
245
|
except ImportError: # pragma: no cover
|
|
247
246
|
sp = None
|
|
248
247
|
|
|
@@ -274,6 +273,7 @@ class ArchiveError(Exception):
|
|
|
274
273
|
|
|
275
274
|
class CycleError(ArchiveError):
|
|
276
275
|
r"""Cycle found in archive."""
|
|
276
|
+
|
|
277
277
|
message = "Archive contains cyclic dependencies."
|
|
278
278
|
|
|
279
279
|
def __init__(self, *v):
|
|
@@ -691,6 +691,7 @@ class Archive(object):
|
|
|
691
691
|
...
|
|
692
692
|
ValueError: Can't insert 'y' into single_item_mode=True archive with 'x'.
|
|
693
693
|
"""
|
|
694
|
+
|
|
694
695
|
data_name = "_arrays"
|
|
695
696
|
|
|
696
697
|
def __init__(
|
|
@@ -843,7 +844,8 @@ class Archive(object):
|
|
|
843
844
|
elif self.tostring and obj.__class__ is np.ndarray and not obj.dtype.hasobject:
|
|
844
845
|
|
|
845
846
|
rep = "numpy.frombuffer(%r, dtype=%r).reshape(%s)" % (
|
|
846
|
-
obj.tostring(),
|
|
847
|
+
# obj.tostring(),
|
|
848
|
+
obj.tobytes(),
|
|
847
849
|
obj.dtype.str,
|
|
848
850
|
str(obj.shape),
|
|
849
851
|
)
|
|
@@ -878,6 +880,12 @@ class Archive(object):
|
|
|
878
880
|
args = {}
|
|
879
881
|
return (rep, args, imports)
|
|
880
882
|
|
|
883
|
+
def _archive_ndtype(self, obj, env):
|
|
884
|
+
"""Archival of new numpy types like np.int64."""
|
|
885
|
+
env["np"] = np
|
|
886
|
+
rep = repr(obj)
|
|
887
|
+
return get_persistent_rep_repr(obj, env, rep=rep)
|
|
888
|
+
|
|
881
889
|
def _archive_spmatrix(self, obj, env):
|
|
882
890
|
if (
|
|
883
891
|
sp.sparse.isspmatrix_csc(obj)
|
|
@@ -933,10 +941,16 @@ class Archive(object):
|
|
|
933
941
|
_dispatch[types.ClassType] = _archive_type
|
|
934
942
|
|
|
935
943
|
if np:
|
|
936
|
-
_dispatch.update(
|
|
944
|
+
_dispatch.update(
|
|
945
|
+
{
|
|
946
|
+
np.ndarray: _archive_ndarray,
|
|
947
|
+
np.ufunc: _archive_func,
|
|
948
|
+
np.generic: _archive_ndtype,
|
|
949
|
+
}
|
|
950
|
+
)
|
|
937
951
|
|
|
938
952
|
if sp:
|
|
939
|
-
_dispatch.update({sp.sparse.
|
|
953
|
+
_dispatch.update({sp.sparse.spmatrix: _archive_spmatrix})
|
|
940
954
|
|
|
941
955
|
def unique_name(self, name):
|
|
942
956
|
r"""Return a unique name not contained in the archive."""
|
|
@@ -1102,7 +1116,7 @@ class Archive(object):
|
|
|
1102
1116
|
pass
|
|
1103
1117
|
else:
|
|
1104
1118
|
if self.check_on_insert:
|
|
1105
|
-
|
|
1119
|
+
rep, args, imports = self.get_persistent_rep(obj, env)
|
|
1106
1120
|
del rep, args, imports
|
|
1107
1121
|
|
|
1108
1122
|
self.arch.append((uname, obj, env))
|
|
@@ -1274,7 +1288,7 @@ class Archive(object):
|
|
|
1274
1288
|
"""
|
|
1275
1289
|
import_lines = []
|
|
1276
1290
|
del_lines = []
|
|
1277
|
-
for
|
|
1291
|
+
for module, iname, uiname in imports:
|
|
1278
1292
|
assert iname is not None or uiname is not None
|
|
1279
1293
|
if iname is None:
|
|
1280
1294
|
import_lines.append("import {} as {}".format(module, uiname))
|
|
@@ -1671,7 +1685,7 @@ def repr_(obj, robust=True):
|
|
|
1671
1685
|
>>> A(x=[1])
|
|
1672
1686
|
A(x=[1])
|
|
1673
1687
|
"""
|
|
1674
|
-
|
|
1688
|
+
rep, args, imports = obj.get_persistent_rep()
|
|
1675
1689
|
replacements = dict((k, repr(args[k])) for k in args)
|
|
1676
1690
|
rep = _replace_rep(rep, replacements=replacements, robust=robust)
|
|
1677
1691
|
return rep
|
|
@@ -1722,7 +1736,10 @@ def get_persistent_rep_repr(obj, env, rep=None):
|
|
|
1722
1736
|
for name in _ast.names:
|
|
1723
1737
|
obj = eval(name, scope)
|
|
1724
1738
|
module = get_module(obj)
|
|
1725
|
-
if module:
|
|
1739
|
+
if module is obj:
|
|
1740
|
+
# Don't try 'from numpy import np as np'.
|
|
1741
|
+
imports.append((module.__name__, None, name))
|
|
1742
|
+
elif module:
|
|
1726
1743
|
imports.append((module.__name__, name, name))
|
|
1727
1744
|
|
|
1728
1745
|
return (rep, args, imports)
|
|
@@ -1757,6 +1774,14 @@ def get_persistent_rep_type(obj, env):
|
|
|
1757
1774
|
return (rep, args, imports)
|
|
1758
1775
|
|
|
1759
1776
|
|
|
1777
|
+
def _get_numpy_import(name):
|
|
1778
|
+
"""Return the import tuple for the specified name in numpy."""
|
|
1779
|
+
if name == "np":
|
|
1780
|
+
return ("numpy", None, "np")
|
|
1781
|
+
assert hasattr(np, name)
|
|
1782
|
+
return ("numpy", name, name)
|
|
1783
|
+
|
|
1784
|
+
|
|
1760
1785
|
def get_persistent_rep_float(obj, env):
|
|
1761
1786
|
r"""Deal with float types, including `inf` or `nan`.
|
|
1762
1787
|
|
|
@@ -1769,7 +1794,7 @@ def get_persistent_rep_float(obj, env):
|
|
|
1769
1794
|
('inf', {}, [('numpy', 'inf', 'inf')])
|
|
1770
1795
|
"""
|
|
1771
1796
|
rep = repr(obj)
|
|
1772
|
-
imports =
|
|
1797
|
+
imports = list(map(_get_numpy_import, AST(rep)._get_names()))
|
|
1773
1798
|
args = {}
|
|
1774
1799
|
|
|
1775
1800
|
return (rep, args, imports)
|
|
@@ -1783,10 +1808,7 @@ def get_persistent_rep_obj(obj, env):
|
|
|
1783
1808
|
|
|
1784
1809
|
def get_persistent_rep_method(obj, env):
|
|
1785
1810
|
r"""Archive methods."""
|
|
1786
|
-
|
|
1787
|
-
instance = obj.im_self
|
|
1788
|
-
else:
|
|
1789
|
-
instance = obj.__self__
|
|
1811
|
+
instance = obj.__self__
|
|
1790
1812
|
cls = instance.__class__
|
|
1791
1813
|
name = obj.__name__
|
|
1792
1814
|
|
|
@@ -1882,8 +1904,6 @@ def is_simple(obj):
|
|
|
1882
1904
|
if hasattr(obj, "__class__"):
|
|
1883
1905
|
class_ = obj.__class__
|
|
1884
1906
|
classes = [bool, int, str, None.__class__]
|
|
1885
|
-
if sys.version_info < (3, 0): # pragma: no cover
|
|
1886
|
-
classes.extend([long, unicode])
|
|
1887
1907
|
result = (
|
|
1888
1908
|
class_ in classes
|
|
1889
1909
|
or (
|
|
@@ -2016,7 +2036,7 @@ class GraphMixin(object):
|
|
|
2016
2036
|
|
|
2017
2037
|
# Check for duplicate imports
|
|
2018
2038
|
replacements = {}
|
|
2019
|
-
for
|
|
2039
|
+
for module_, iname_, uiname_ in imports:
|
|
2020
2040
|
mod_inames = list(zip(*_unzip(self.imports)[:2]))
|
|
2021
2041
|
if (module_, iname_) in mod_inames:
|
|
2022
2042
|
# Import already specified. Just refer to it
|
|
@@ -2139,7 +2159,7 @@ class Graph(GraphMixin):
|
|
|
2139
2159
|
self.robust_replace = robust_replace
|
|
2140
2160
|
|
|
2141
2161
|
# First insert the root nodes
|
|
2142
|
-
for
|
|
2162
|
+
for name, obj, env in objects:
|
|
2143
2163
|
node = self._new_node(obj, env, name)
|
|
2144
2164
|
self.roots.add(node.id)
|
|
2145
2165
|
self.envs[node.id] = env
|
|
@@ -2422,7 +2442,7 @@ class _Graph(GraphMixin):
|
|
|
2422
2442
|
self.names = set()
|
|
2423
2443
|
|
|
2424
2444
|
# First insert the root nodes
|
|
2425
|
-
for
|
|
2445
|
+
for name, obj, env in objects:
|
|
2426
2446
|
node = self._new_node(obj, env, name)
|
|
2427
2447
|
self.roots.add(node.id)
|
|
2428
2448
|
self.envs[node.id] = env
|
|
@@ -2852,7 +2872,7 @@ class DataSet(object):
|
|
|
2852
2872
|
>>> import tempfile, shutil, os # Make a unique temporary module
|
|
2853
2873
|
>>> t = tempfile.mkdtemp(dir='.')
|
|
2854
2874
|
>>> os.rmdir(t)
|
|
2855
|
-
>>> modname = t
|
|
2875
|
+
>>> modname = t
|
|
2856
2876
|
>>> ds = DataSet(modname, 'w')
|
|
2857
2877
|
>>> ds.d = dict(a=1, b=2) # Will write to disk
|
|
2858
2878
|
>>> ds1 = DataSet(modname, 'r')
|
|
@@ -2884,7 +2904,7 @@ class DataSet(object):
|
|
|
2884
2904
|
>>> import tempfile, shutil # Make a unique temporary module
|
|
2885
2905
|
>>> t = tempfile.mkdtemp(dir='.')
|
|
2886
2906
|
>>> os.rmdir(t)
|
|
2887
|
-
>>> modname = t
|
|
2907
|
+
>>> modname = t
|
|
2888
2908
|
|
|
2889
2909
|
Now, make the data set.
|
|
2890
2910
|
|
|
@@ -2927,7 +2947,7 @@ class DataSet(object):
|
|
|
2927
2947
|
['x_3']
|
|
2928
2948
|
|
|
2929
2949
|
>>> print(ds)
|
|
2930
|
-
DataSet '
|
|
2950
|
+
DataSet '...' containing ['mus', 'nxs', 'x_0', 'x_1', 'x_2', 'x_3']
|
|
2931
2951
|
|
|
2932
2952
|
Here is the complete set of info:
|
|
2933
2953
|
|
|
@@ -2973,7 +2993,7 @@ class DataSet(object):
|
|
|
2973
2993
|
|
|
2974
2994
|
>>> ds1 = DataSet(modname, 'w')
|
|
2975
2995
|
>>> print(ds1)
|
|
2976
|
-
DataSet '
|
|
2996
|
+
DataSet '...' containing ['mus', 'nxs', 'x_0', 'x_1', 'x_2', 'x_3']
|
|
2977
2997
|
|
|
2978
2998
|
This may be modified, but see the warnings above.
|
|
2979
2999
|
|
|
@@ -2997,6 +3017,7 @@ class DataSet(object):
|
|
|
2997
3017
|
>>> shutil.rmtree(t)
|
|
2998
3018
|
|
|
2999
3019
|
"""
|
|
3020
|
+
|
|
3000
3021
|
_lock_file_name = "_locked"
|
|
3001
3022
|
|
|
3002
3023
|
def __init__(
|
|
@@ -3114,10 +3135,6 @@ class DataSet(object):
|
|
|
3114
3135
|
|
|
3115
3136
|
self._load()
|
|
3116
3137
|
|
|
3117
|
-
# Needed for pre 2.6 python version to support tab completion
|
|
3118
|
-
if sys.version_info < (2, 6): # pragma: no cover
|
|
3119
|
-
self.__members__ = sorted(self._info_dict)
|
|
3120
|
-
|
|
3121
3138
|
def _import(self, name="__init__"):
|
|
3122
3139
|
"""Return the attribute `name` from the dataset.
|
|
3123
3140
|
|
|
@@ -3141,16 +3158,11 @@ class DataSet(object):
|
|
|
3141
3158
|
_dont_write_bytecode = sys.dont_write_bytecode
|
|
3142
3159
|
sys.dont_write_bytecode = True
|
|
3143
3160
|
try:
|
|
3144
|
-
|
|
3145
|
-
import imp
|
|
3161
|
+
import importlib.util
|
|
3146
3162
|
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
spec = importlib.util.spec_from_file_location(_mod, archive_file)
|
|
3152
|
-
res = importlib.util.module_from_spec(spec)
|
|
3153
|
-
spec.loader.exec_module(res)
|
|
3163
|
+
spec = importlib.util.spec_from_file_location(_mod, archive_file)
|
|
3164
|
+
res = importlib.util.module_from_spec(spec)
|
|
3165
|
+
spec.loader.exec_module(res)
|
|
3154
3166
|
if name == "__init__":
|
|
3155
3167
|
res = res._info_dict
|
|
3156
3168
|
else:
|
|
@@ -3273,10 +3285,6 @@ class DataSet(object):
|
|
|
3273
3285
|
arrays_name="_data",
|
|
3274
3286
|
)
|
|
3275
3287
|
|
|
3276
|
-
# Needed for pre 2.6 python version to support tab completion
|
|
3277
|
-
if sys.version_info < (2, 6): # pragma: no cover
|
|
3278
|
-
self.__members__.append(name)
|
|
3279
|
-
|
|
3280
3288
|
if name not in self._info_dict:
|
|
3281
3289
|
# Set default info to None.
|
|
3282
3290
|
self[name] = None
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|