datastock 0.0.41__tar.gz → 0.0.43__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.
- {datastock-0.0.41/datastock.egg-info → datastock-0.0.43}/PKG-INFO +1 -1
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class0.py +6 -2
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_check.py +9 -2
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_saveload.py +116 -27
- {datastock-0.0.41 → datastock-0.0.43}/datastock/tests/test_01_DataStock.py +6 -1
- {datastock-0.0.41 → datastock-0.0.43}/datastock/version.py +1 -1
- {datastock-0.0.41 → datastock-0.0.43/datastock.egg-info}/PKG-INFO +1 -1
- {datastock-0.0.41 → datastock-0.0.43}/LICENSE +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/MANIFEST.in +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/README.md +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/_updateversion.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_DataCollection_utils.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/__init__.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_binning.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_compute.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_domain.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_interpolate.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_show.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class1_uniformize.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class2.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class2_interactivity.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_class3.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_direct_calls.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_export_dataframe.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_find_plateau.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_generic_check.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_generic_utils.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_generic_utils_plot.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_BvsA_as_distribution.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_BvsA_as_distribution_check.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_as_array.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_as_array_1d.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_as_array_234d.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_as_mobile_lines.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_as_profile1d.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_correlations.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_old_backup.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/_plot_text.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/tests/__init__.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock/tests/output/__init__.py +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock.egg-info/SOURCES.txt +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock.egg-info/dependency_links.txt +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock.egg-info/requires.txt +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/datastock.egg-info/top_level.txt +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/pyproject.toml +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/setup.cfg +0 -0
- {datastock-0.0.41 → datastock-0.0.43}/setup.py +0 -0
@@ -161,14 +161,16 @@ class DataStock0(object):
|
|
161
161
|
|
162
162
|
def save(
|
163
163
|
self,
|
164
|
+
pfe=None,
|
164
165
|
path=None,
|
165
166
|
name=None,
|
166
167
|
sep=None,
|
167
|
-
|
168
|
+
overwrite=None,
|
168
169
|
return_pfe=False,
|
170
|
+
verb=True,
|
169
171
|
):
|
170
172
|
|
171
|
-
lsep = ['
|
173
|
+
lsep = [';', '&', '?', '#', ',', '~', '.', '-', '_']
|
172
174
|
if sep is None:
|
173
175
|
for ss in lsep:
|
174
176
|
c0 = (
|
@@ -191,9 +193,11 @@ class DataStock0(object):
|
|
191
193
|
asarray=True,
|
192
194
|
returnas='blended',
|
193
195
|
),
|
196
|
+
pfe=pfe,
|
194
197
|
sep=sep,
|
195
198
|
path=path,
|
196
199
|
name=name,
|
200
|
+
overwrite=overwrite,
|
197
201
|
clsname=self.__class__.__name__,
|
198
202
|
return_pfe=return_pfe,
|
199
203
|
verb=verb,
|
@@ -147,7 +147,14 @@ def _check_conflicts(dd=None, dd0=None, dd_name=None, returnas=None):
|
|
147
147
|
or (
|
148
148
|
not isinstance(v0[kk], np.ndarray)
|
149
149
|
and not scpsp.issparse(v0[kk])
|
150
|
-
and
|
150
|
+
and (
|
151
|
+
v0[kk] == dd0[k0][kk]
|
152
|
+
or (
|
153
|
+
# asunit.Unit vs str should be the same
|
154
|
+
kk == 'units'
|
155
|
+
and str(v0[kk]) == str(dd0[k0][kk])
|
156
|
+
)
|
157
|
+
)
|
151
158
|
)
|
152
159
|
)
|
153
160
|
)
|
@@ -1925,4 +1932,4 @@ def _select(dd=None, dd_name=None, log=None, returnas=None, **kwdargs):
|
|
1925
1932
|
[k0 for jj, k0 in enumerate(dd.keys()) if ind[jj]],
|
1926
1933
|
dtype=str,
|
1927
1934
|
)
|
1928
|
-
return ind
|
1935
|
+
return ind
|
@@ -26,10 +26,12 @@ _KEY_SEP = '--sep--'
|
|
26
26
|
|
27
27
|
def save(
|
28
28
|
dflat=None,
|
29
|
+
pfe=None,
|
29
30
|
sep=None,
|
30
31
|
name=None,
|
31
32
|
path=None,
|
32
33
|
clsname=None,
|
34
|
+
overwrite=None,
|
33
35
|
return_pfe=None,
|
34
36
|
verb=None,
|
35
37
|
):
|
@@ -37,30 +39,97 @@ def save(
|
|
37
39
|
|
38
40
|
# ------------
|
39
41
|
# check inputs
|
42
|
+
# ------------
|
40
43
|
|
41
|
-
#
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
44
|
+
# ------------------
|
45
|
+
# pfe vs path/name
|
46
|
+
|
47
|
+
lc = [
|
48
|
+
pfe is not None,
|
49
|
+
path is not None or name is not None,
|
50
|
+
]
|
51
|
+
|
52
|
+
if np.sum(lc) > 1:
|
53
|
+
msg = (
|
54
|
+
"Saving, please provide {pfe} xor {path and/or name}!\n"
|
55
|
+
f"\t- path: {path}\n"
|
56
|
+
f"\t- name: {name}\n"
|
57
|
+
f"\t- pfe: {pfe}\n"
|
58
|
+
)
|
50
59
|
raise Exception(msg)
|
51
60
|
|
52
|
-
#
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
61
|
+
# ------------------
|
62
|
+
# pfe vs path/name
|
63
|
+
|
64
|
+
if lc[0]:
|
65
|
+
if not isinstance(pfe, str):
|
66
|
+
msg = (
|
67
|
+
"Arg pfe must be a str ponting to a file!\n"
|
68
|
+
f"Provided: {pfe}\n"
|
69
|
+
)
|
70
|
+
raise Exception(msg)
|
58
71
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
72
|
+
sdir, sfile = os.path.split(pfe)
|
73
|
+
if sdir == '':
|
74
|
+
sdir = os.path.asbpath('.')
|
75
|
+
|
76
|
+
# check path
|
77
|
+
if not os.path.isdir(sdir):
|
78
|
+
msg = (
|
79
|
+
"Arg pfe seems to have a non-valid path!\n"
|
80
|
+
"Provided: {sdir}\n"
|
81
|
+
)
|
82
|
+
raise Exception(msg)
|
83
|
+
|
84
|
+
# check file name
|
85
|
+
if not sfile.endswith('.npz'):
|
86
|
+
sfile = f"{sfile}.npz"
|
87
|
+
|
88
|
+
# re-assemble
|
89
|
+
pfe = os.path.join(sdir, sfile)
|
90
|
+
|
91
|
+
else:
|
92
|
+
# path
|
93
|
+
path = _generic_check._check_var(
|
94
|
+
path, 'path',
|
95
|
+
default=os.path.abspath('./'),
|
96
|
+
types=str,
|
97
|
+
)
|
98
|
+
path = os.path.abspath(path)
|
99
|
+
if not os.path.isdir(path):
|
100
|
+
msg = f"Arg path must be a valid path!\nProvided: {path}"
|
101
|
+
raise Exception(msg)
|
102
|
+
|
103
|
+
# clsname
|
104
|
+
clsname = _generic_check._check_var(
|
105
|
+
clsname, 'clsname',
|
106
|
+
default='DataCollection',
|
107
|
+
types=str,
|
108
|
+
)
|
109
|
+
|
110
|
+
# name
|
111
|
+
name = _generic_check._check_var(
|
112
|
+
name, 'name',
|
113
|
+
default='name',
|
114
|
+
types=str,
|
115
|
+
)
|
116
|
+
|
117
|
+
# set automatic name
|
118
|
+
user = getpass.getuser()
|
119
|
+
dt = dtm.datetime.now().strftime("%Y%m%d-%H%M%S")
|
120
|
+
name = f'{clsname}_{name}_{user}_{dt}.npz'
|
121
|
+
|
122
|
+
# pfe
|
123
|
+
pfe = os.path.join(path, name)
|
124
|
+
|
125
|
+
# ------------------
|
126
|
+
# options
|
127
|
+
|
128
|
+
# overwrite
|
129
|
+
overwrite = _generic_check._check_var(
|
130
|
+
overwrite, 'overwrite',
|
131
|
+
default=False,
|
132
|
+
types=bool,
|
64
133
|
)
|
65
134
|
|
66
135
|
# verb
|
@@ -79,24 +148,44 @@ def save(
|
|
79
148
|
|
80
149
|
# ----------------------
|
81
150
|
# save / print / return
|
82
|
-
|
83
|
-
user = getpass.getuser()
|
84
|
-
dt = dtm.datetime.now().strftime("%Y%m%d-%H%M%S")
|
85
|
-
name = f'{clsname}_{name}_{user}_{dt}.npz'
|
151
|
+
# ----------------------
|
86
152
|
|
87
153
|
# add sep
|
88
154
|
dflat[_KEY_SEP] = sep
|
89
155
|
|
156
|
+
# -----------------
|
157
|
+
# check vs existing
|
158
|
+
|
159
|
+
if os.path.isfile(pfe):
|
160
|
+
if overwrite is True:
|
161
|
+
msg = (
|
162
|
+
"Overwriting existing file:\n"
|
163
|
+
f"\t{pfe}"
|
164
|
+
)
|
165
|
+
warnings.warn(msg)
|
166
|
+
else:
|
167
|
+
msg = (
|
168
|
+
"File already existing!\n"
|
169
|
+
"\t=> use overwrite = True to overwrite\n"
|
170
|
+
f"\t{pfe}"
|
171
|
+
)
|
172
|
+
raise Exception(msg)
|
173
|
+
|
174
|
+
# --------
|
90
175
|
# save
|
91
|
-
pfe = os.path.join(path, name)
|
92
|
-
np.savez(pfe, **dflat)
|
93
176
|
|
177
|
+
np.savez(pfe, **dflat)
|
178
|
+
|
179
|
+
# -------
|
94
180
|
# print
|
181
|
+
|
95
182
|
if verb:
|
96
|
-
msg = f"
|
183
|
+
msg = f"\nSaved in:\n\t{pfe}\n"
|
97
184
|
print(msg)
|
98
185
|
|
186
|
+
# -------
|
99
187
|
# return
|
188
|
+
|
100
189
|
if return_pfe is True:
|
101
190
|
return pfe
|
102
191
|
|
@@ -602,7 +602,12 @@ class Test02_Manipulate():
|
|
602
602
|
def test22_get_nbytes(self):
|
603
603
|
nb, dnb = self.st.get_nbytes()
|
604
604
|
|
605
|
-
def
|
605
|
+
def test23_save_pfe(self, verb=False):
|
606
|
+
pfe = os.path.join(_PATH_OUTPUT, 'testsave.npz')
|
607
|
+
self.st.save(pfe=pfe, return_pfe=False)
|
608
|
+
os.remove(pfe)
|
609
|
+
|
610
|
+
def test24_saveload(self, verb=False):
|
606
611
|
pfe = self.st.save(path=_PATH_OUTPUT, verb=verb, return_pfe=True)
|
607
612
|
st2 = load(pfe, verb=verb)
|
608
613
|
# Just to check the loaded version works fine
|
@@ -1,2 +1,2 @@
|
|
1
1
|
# Do not edit, pipeline versioning governed by git tags!
|
2
|
-
__version__ = '0.0.
|
2
|
+
__version__ = '0.0.43'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|