datastock 0.0.44__tar.gz → 0.0.45__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.44/datastock.egg-info → datastock-0.0.45}/PKG-INFO +1 -1
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_domain.py +43 -17
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_interpolate.py +47 -37
- {datastock-0.0.44 → datastock-0.0.45}/datastock/version.py +1 -1
- {datastock-0.0.44 → datastock-0.0.45/datastock.egg-info}/PKG-INFO +1 -1
- {datastock-0.0.44 → datastock-0.0.45}/LICENSE +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/MANIFEST.in +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/README.md +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/_updateversion.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_DataCollection_utils.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/__init__.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class0.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_binning.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_check.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_compute.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_show.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class1_uniformize.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class2.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class2_interactivity.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_class3.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_direct_calls.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_export_dataframe.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_find_plateau.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_generic_check.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_generic_utils.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_generic_utils_plot.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_BvsA_as_distribution.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_BvsA_as_distribution_check.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_as_array.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_as_array_1d.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_as_array_234d.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_as_mobile_lines.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_as_profile1d.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_correlations.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_old_backup.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_plot_text.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/_saveload.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/tests/__init__.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/tests/output/__init__.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock/tests/test_01_DataStock.py +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock.egg-info/SOURCES.txt +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock.egg-info/dependency_links.txt +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock.egg-info/requires.txt +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/datastock.egg-info/top_level.txt +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/pyproject.toml +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/setup.cfg +0 -0
- {datastock-0.0.44 → datastock-0.0.45}/setup.py +0 -0
@@ -30,11 +30,14 @@ def domain_ref(
|
|
30
30
|
# -----------
|
31
31
|
# get indices
|
32
32
|
|
33
|
-
lvectu = sorted({
|
33
|
+
lvectu = sorted({
|
34
|
+
v0['vect'] for v0 in domain.values()
|
35
|
+
if v0.get('vect') is not None
|
36
|
+
})
|
34
37
|
|
35
38
|
for vv in lvectu:
|
36
39
|
|
37
|
-
lk0 = [k0 for k0, v0 in domain.items() if v0
|
40
|
+
lk0 = [k0 for k0, v0 in domain.items() if v0.get('vect') == vv]
|
38
41
|
for k0 in lk0:
|
39
42
|
|
40
43
|
if domain[k0].get('domain') is None:
|
@@ -61,12 +64,14 @@ def _check(
|
|
61
64
|
|
62
65
|
# ---------
|
63
66
|
# prepare
|
67
|
+
# ---------
|
64
68
|
|
65
69
|
ldata = list(coll.ddata.keys())
|
66
70
|
lref = list(coll.dref.keys())
|
67
71
|
|
68
72
|
# ------------
|
69
73
|
# domain
|
74
|
+
# ------------
|
70
75
|
|
71
76
|
c0 = (
|
72
77
|
isinstance(domain, dict)
|
@@ -80,24 +85,17 @@ def _check(
|
|
80
85
|
)
|
81
86
|
raise Exception(msg)
|
82
87
|
|
83
|
-
#
|
88
|
+
# --------------
|
84
89
|
# check each key
|
90
|
+
# --------------
|
85
91
|
|
86
92
|
dfail = {}
|
87
93
|
domain = copy.deepcopy(domain)
|
88
94
|
for k0, v0 in domain.items():
|
89
95
|
|
90
|
-
#
|
91
|
-
kwd = {'ref': k0} if k0 in lref else {'key0': k0}
|
92
|
-
hasref, hasvect, ref, vect = coll.get_ref_vector(**kwd)[:4]
|
93
|
-
if not (hasref and ref is not None):
|
94
|
-
dfail[k0] = "No associated ref identified!"
|
95
|
-
continue
|
96
|
-
if not (hasvect and vect is not None):
|
97
|
-
dfail[k0] = "No associated ref vector identified!"
|
98
|
-
continue
|
99
|
-
|
96
|
+
# -----------
|
100
97
|
# v0 is dict
|
98
|
+
|
101
99
|
ltyp = (list, tuple, np.ndarray)
|
102
100
|
if isinstance(v0, ltyp):
|
103
101
|
domain[k0] = {'domain': v0}
|
@@ -106,21 +104,42 @@ def _check(
|
|
106
104
|
|
107
105
|
c0 = (
|
108
106
|
isinstance(domain[k0], dict)
|
109
|
-
and any(ss in ['ind', 'domain'] for ss in domain[k0].keys())
|
107
|
+
and any([ss in ['ind', 'domain'] for ss in domain[k0].keys()])
|
110
108
|
and (
|
111
109
|
isinstance(domain[k0].get('domain'), ltyp)
|
112
110
|
or np.isscalar(domain[k0].get('domain', 0))
|
113
111
|
)
|
114
|
-
and isinstance(domain[k0].get('ind', np.r_[0]), np.ndarray)
|
112
|
+
and isinstance(domain[k0].get('ind', np.r_[0]), (np.ndarray, int))
|
115
113
|
)
|
114
|
+
|
116
115
|
if not c0:
|
117
116
|
dfail[k0] = "must be a dict with keys ['ind', 'domain']"
|
118
117
|
continue
|
119
118
|
|
119
|
+
# ----------------
|
120
|
+
# check ref vector
|
121
|
+
|
122
|
+
kwd = {'ref': k0} if k0 in lref else {'key0': k0}
|
123
|
+
hasref, hasvect, ref, vect = coll.get_ref_vector(**kwd)[:4]
|
124
|
+
|
125
|
+
if not (hasref and ref is not None):
|
126
|
+
dfail[k0] = "No associated ref identified!"
|
127
|
+
continue
|
128
|
+
|
120
129
|
# vect
|
121
|
-
domain[k0]['
|
130
|
+
domain[k0]['ref'] = ref
|
122
131
|
|
132
|
+
if domain[k0].get('domain') is not None:
|
133
|
+
if not (hasvect and vect is not None):
|
134
|
+
dfail[k0] = "No associated ref vector identified!"
|
135
|
+
continue
|
136
|
+
|
137
|
+
# vect
|
138
|
+
domain[k0]['vect'] = vect
|
139
|
+
|
140
|
+
# -------
|
123
141
|
# domain
|
142
|
+
|
124
143
|
dom = domain[k0].get('domain')
|
125
144
|
if dom is not None:
|
126
145
|
dom, err = _check_domain(dom)
|
@@ -129,10 +148,15 @@ def _check(
|
|
129
148
|
continue
|
130
149
|
domain[k0]['domain'] = dom
|
131
150
|
|
151
|
+
# -----
|
132
152
|
# ind
|
153
|
+
|
133
154
|
ind = domain[k0].get('ind')
|
134
155
|
if ind is not None:
|
135
|
-
|
156
|
+
if np.isscalar(ind):
|
157
|
+
ind = np.array([ind], dtype=int)
|
158
|
+
|
159
|
+
vsize = coll.dref[ref]['size']
|
136
160
|
if ind.dtype == bool:
|
137
161
|
pass
|
138
162
|
elif 'int' in ind.dtype.name:
|
@@ -151,12 +175,14 @@ def _check(
|
|
151
175
|
|
152
176
|
# -----------
|
153
177
|
# errors
|
178
|
+
# -----------
|
154
179
|
|
155
180
|
if len(dfail) > 0:
|
156
181
|
lstr = [f"\t- '{k0}': {v0}" for k0, v0 in dfail.items()]
|
157
182
|
msg = (
|
158
183
|
"The following domain keys / values are not conform:\n"
|
159
184
|
+ "\n".join(lstr)
|
185
|
+
+ f"\nProvided:\n{domain}"
|
160
186
|
)
|
161
187
|
raise Exception(msg)
|
162
188
|
|
@@ -88,6 +88,7 @@ def interpolate(
|
|
88
88
|
ddata, dout, dsh_other, sli_c, sli_x, sli_v,
|
89
89
|
log_log, nan0, grid, ndim, xunique,
|
90
90
|
returnas, return_params, store, inplace,
|
91
|
+
domain,
|
91
92
|
) = _check(
|
92
93
|
coll=coll,
|
93
94
|
# interpolation base
|
@@ -143,7 +144,7 @@ def interpolate(
|
|
143
144
|
# adjust data and ref if xunique
|
144
145
|
|
145
146
|
if xunique:
|
146
|
-
_xunique(dout)
|
147
|
+
_xunique(dout, domain=domain)
|
147
148
|
|
148
149
|
# --------
|
149
150
|
# store
|
@@ -392,9 +393,9 @@ def _check(
|
|
392
393
|
)
|
393
394
|
|
394
395
|
# ---------------------
|
395
|
-
# get
|
396
|
+
# get dref_dom from domain
|
396
397
|
|
397
|
-
domain,
|
398
|
+
domain, dref_dom = _get_drefdom(
|
398
399
|
coll=coll,
|
399
400
|
domain=domain,
|
400
401
|
ref_key=ref_key,
|
@@ -407,7 +408,7 @@ def _check(
|
|
407
408
|
coll=coll,
|
408
409
|
keys=keys,
|
409
410
|
ref_key=ref_key,
|
410
|
-
|
411
|
+
dref_dom=dref_dom,
|
411
412
|
)
|
412
413
|
|
413
414
|
# --------
|
@@ -422,7 +423,7 @@ def _check(
|
|
422
423
|
)
|
423
424
|
|
424
425
|
if ref_com is not None and domain is not None:
|
425
|
-
if ref_com in
|
426
|
+
if ref_com in list(dref_dom.keys()):
|
426
427
|
msg = (
|
427
428
|
"Arg ref_com and domain cannot be applied to the same ref!\n"
|
428
429
|
f"\t- ref_com: {ref_com}\n"
|
@@ -440,8 +441,10 @@ def _check(
|
|
440
441
|
x0=x0,
|
441
442
|
daxis=daxis,
|
442
443
|
dunits=dunits,
|
444
|
+
# ref com
|
443
445
|
dref_com=dref_com,
|
444
|
-
|
446
|
+
# domain
|
447
|
+
dref_dom=dref_dom,
|
445
448
|
)
|
446
449
|
|
447
450
|
# --------------
|
@@ -488,6 +491,7 @@ def _check(
|
|
488
491
|
ddata, dout, dsh_other, sli_c, sli_x, sli_v,
|
489
492
|
log_log, nan0, grid, ndim, xunique,
|
490
493
|
returnas, return_params, store, inplace,
|
494
|
+
domain,
|
491
495
|
)
|
492
496
|
|
493
497
|
|
@@ -963,56 +967,59 @@ def _x01_grid(
|
|
963
967
|
return x0, x1, refx, ix, xunique
|
964
968
|
|
965
969
|
|
966
|
-
def
|
970
|
+
def _get_drefdom(
|
967
971
|
coll=None,
|
968
972
|
domain=None,
|
969
973
|
ref_key=None,
|
970
974
|
):
|
971
975
|
# ----------------
|
972
|
-
# domain =>
|
976
|
+
# domain => dref_dom
|
977
|
+
|
978
|
+
lr_ref_key = [coll.ddata[kk]['ref'][0] for kk in ref_key]
|
973
979
|
|
974
980
|
if domain is not None:
|
975
981
|
|
976
982
|
# get domain
|
977
983
|
domain = coll.get_domain_ref(domain)
|
978
984
|
|
979
|
-
# derive
|
980
|
-
|
981
|
-
v0['
|
985
|
+
# derive lrefu
|
986
|
+
lrefu = sorted({
|
987
|
+
v0['ref'] for v0 in domain.values() if v0['ref'] not in lr_ref_key
|
982
988
|
})
|
983
989
|
|
984
|
-
|
985
|
-
|
986
|
-
for
|
990
|
+
# derive dref_dom
|
991
|
+
dref_dom = {
|
992
|
+
rr: [k1 for k1, v1 in domain.items() if v1['ref'] == rr]
|
993
|
+
for rr in lrefu
|
987
994
|
}
|
988
995
|
|
989
996
|
# check unicity of vect
|
990
|
-
dfail = {k0: v0 for k0, v0 in
|
997
|
+
dfail = {k0: v0 for k0, v0 in dref_dom.items() if len(v0) > 1}
|
991
998
|
if len(dfail) > 0:
|
992
999
|
lstr = [f"\t- '{k0}': {v0}" for k0, v0 in dfail.items()]
|
993
1000
|
msg = (
|
994
|
-
"Some ref
|
1001
|
+
"Some ref have been specified with multiple domains!\n"
|
995
1002
|
+ "\n".join(lstr)
|
996
1003
|
)
|
997
1004
|
raise Exception(msg)
|
998
1005
|
|
999
|
-
# build final
|
1000
|
-
|
1006
|
+
# build final dref_dom
|
1007
|
+
dref_dom = {
|
1001
1008
|
k0: domain[v0[0]]['ind']
|
1002
|
-
for k0, v0 in
|
1009
|
+
for k0, v0 in dref_dom.items()
|
1003
1010
|
}
|
1004
1011
|
|
1005
1012
|
else:
|
1006
|
-
|
1013
|
+
dref_dom = None
|
1007
1014
|
|
1008
|
-
return domain,
|
1015
|
+
return domain, dref_dom
|
1009
1016
|
|
1010
1017
|
|
1011
1018
|
def _get_ddata(
|
1012
1019
|
coll=None,
|
1013
1020
|
keys=None,
|
1014
1021
|
ref_key=None,
|
1015
|
-
|
1022
|
+
dref_dom=None,
|
1016
1023
|
):
|
1017
1024
|
|
1018
1025
|
# --------
|
@@ -1024,13 +1031,12 @@ def _get_ddata(
|
|
1024
1031
|
data = coll.ddata[k0]['data']
|
1025
1032
|
|
1026
1033
|
# apply domain
|
1027
|
-
if
|
1028
|
-
for
|
1029
|
-
|
1030
|
-
|
1031
|
-
ax = coll.ddata[k0]['ref'].index(ref)
|
1034
|
+
if dref_dom is not None:
|
1035
|
+
for rr, vr in dref_dom.items():
|
1036
|
+
if rr in coll.ddata[k0]['ref']:
|
1037
|
+
ax = coll.ddata[k0]['ref'].index(rr)
|
1032
1038
|
sli = tuple([
|
1033
|
-
|
1039
|
+
vr if ii == ax else slice(None)
|
1034
1040
|
for ii in range(data.ndim)
|
1035
1041
|
])
|
1036
1042
|
data = data[sli]
|
@@ -1050,7 +1056,7 @@ def _get_dout(
|
|
1050
1056
|
# common refs
|
1051
1057
|
dref_com=None,
|
1052
1058
|
# domain
|
1053
|
-
|
1059
|
+
dref_dom=None,
|
1054
1060
|
):
|
1055
1061
|
|
1056
1062
|
# -------------
|
@@ -1069,11 +1075,11 @@ def _get_dout(
|
|
1069
1075
|
rd = list(coll.ddata[k0]['ref'])
|
1070
1076
|
|
1071
1077
|
# apply domain
|
1072
|
-
if
|
1073
|
-
for
|
1074
|
-
if
|
1075
|
-
ax = rd.index(
|
1076
|
-
sh[ax] = len(
|
1078
|
+
if dref_dom is not None:
|
1079
|
+
for rr, vr in dref_dom.items():
|
1080
|
+
if rr in rd:
|
1081
|
+
ax = rd.index(rr)
|
1082
|
+
sh[ax] = len(vr) if vr.dtype == int else vr.sum()
|
1077
1083
|
rd[ax] = None
|
1078
1084
|
|
1079
1085
|
# ------------------------
|
@@ -1556,7 +1562,7 @@ def _interp2d(
|
|
1556
1562
|
# ###############################################################
|
1557
1563
|
|
1558
1564
|
|
1559
|
-
def _xunique(dout=None):
|
1565
|
+
def _xunique(dout=None, domain=None):
|
1560
1566
|
""" interpolation on a single point => eliminates a ref """
|
1561
1567
|
|
1562
1568
|
# ----------
|
@@ -1567,13 +1573,17 @@ def _xunique(dout=None):
|
|
1567
1573
|
for k0, v0 in dout.items()
|
1568
1574
|
}
|
1569
1575
|
|
1570
|
-
|
1576
|
+
# Number of Nones expected
|
1577
|
+
nNone = 1 + len(domain)
|
1578
|
+
|
1579
|
+
# check
|
1580
|
+
dwrong = {k0: v0 for k0, v0 in dind.items() if len(v0) != nNone}
|
1571
1581
|
if len(dwrong) > 0:
|
1572
1582
|
lstr = [
|
1573
1583
|
f"\t- {k0}: {dout[k0]['ref']} => {v0}" for k0, v0 in dwrong.items()
|
1574
1584
|
]
|
1575
1585
|
msg = (
|
1576
|
-
"
|
1586
|
+
"Interpolate unique pt => ref should have nNone = 1 + {len(domain)}:\n"
|
1577
1587
|
+ "\n".join(lstr)
|
1578
1588
|
)
|
1579
1589
|
raise Exception(msg)
|
@@ -1,2 +1,2 @@
|
|
1
1
|
# Do not edit, pipeline versioning governed by git tags!
|
2
|
-
__version__ = '0.0.
|
2
|
+
__version__ = '0.0.45'
|
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
|
File without changes
|
File without changes
|