jupyter-analysis-tools 1.2.0__py3-none-any.whl → 1.2.2__py3-none-any.whl
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.
- jupyter_analysis_tools/__init__.py +3 -2
- jupyter_analysis_tools/readdata.py +38 -24
- jupyter_analysis_tools/utils.py +2 -1
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/METADATA +41 -5
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/RECORD +9 -9
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/WHEEL +0 -0
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/licenses/AUTHORS.rst +0 -0
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/licenses/LICENSE +0 -0
- {jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/top_level.txt +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# __init__.py
|
|
3
3
|
|
|
4
|
-
__version__ = "1.2.
|
|
4
|
+
__version__ = "1.2.2"
|
|
5
5
|
|
|
6
6
|
from .binning import reBin
|
|
7
7
|
from .git import checkRepo, isNBstripoutActivated, isNBstripoutInstalled, isRepo
|
|
8
|
-
from .readdata import readdata
|
|
8
|
+
from .readdata import readdata
|
|
9
9
|
from .readdata import readdata as readPDH
|
|
10
|
+
from .readdata import readPDHmeta, readSSF
|
|
10
11
|
from .utils import setLocaleUTF8
|
|
11
12
|
from .widgets import PathSelector, showBoolStatus
|
|
12
13
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
# -*- coding: utf-8 -*-
|
|
2
2
|
# readdata.py
|
|
3
3
|
|
|
4
|
-
import json
|
|
5
4
|
import warnings
|
|
6
5
|
import xml.etree.ElementTree as et
|
|
7
6
|
from pathlib import Path
|
|
@@ -62,20 +61,28 @@ def convertValue(val):
|
|
|
62
61
|
pass
|
|
63
62
|
return val
|
|
64
63
|
|
|
64
|
+
|
|
65
65
|
def xmlPDHToDict(root):
|
|
66
66
|
result = {}
|
|
67
67
|
stack = [(root, result)]
|
|
68
68
|
while stack:
|
|
69
69
|
elem, parentCont = stack.pop()
|
|
70
70
|
elemCont = {}
|
|
71
|
-
key = elem.attrib.pop("key", None)
|
|
72
71
|
idx = -1
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
key = elem.attrib.pop("key", None)
|
|
73
|
+
if ( # get a unique key, the key can occur in multiple groups in PDH
|
|
74
|
+
key is not None and elem.tag == "group" and elem.attrib.get("id", None) is not None
|
|
75
|
+
):
|
|
76
|
+
key = elem.attrib.pop("id")
|
|
77
|
+
if ( # skip empty elements with a key only early
|
|
78
|
+
not len(list(elem))
|
|
79
|
+
and not len(elem.attrib)
|
|
80
|
+
and not (elem.text and len(elem.text.strip()))
|
|
81
|
+
):
|
|
82
|
+
continue
|
|
76
83
|
if elem.tag == "list":
|
|
77
84
|
elemCont = []
|
|
78
|
-
else:
|
|
85
|
+
else: # add attributes & values to dict
|
|
79
86
|
# Attach text, if any
|
|
80
87
|
if elem.text and len(elem.text.strip()):
|
|
81
88
|
if elem.tag in ("value", "reference"):
|
|
@@ -84,17 +91,20 @@ def xmlPDHToDict(root):
|
|
|
84
91
|
elemCont["#text"] = convertValue(elem.text)
|
|
85
92
|
# Attach attributes, if any
|
|
86
93
|
if elem.attrib:
|
|
87
|
-
elemCont.update(
|
|
88
|
-
|
|
94
|
+
elemCont.update(
|
|
95
|
+
{k: convertValue(v) for k, v in elem.attrib.items() if len(v.strip())}
|
|
96
|
+
)
|
|
97
|
+
if key == "unit" and "value" in elemCont: # fix some units
|
|
89
98
|
elemCont["value"] = elemCont["value"].replace("_", "")
|
|
90
99
|
if "unit" in elemCont:
|
|
91
100
|
elemCont["unit"] = elemCont["unit"].replace("_", "")
|
|
92
101
|
# reduce the extracted dict&attributes
|
|
93
|
-
idx = elemCont.get("index", -1)
|
|
102
|
+
idx = elemCont.get("index", -1) # insert last/append if no index given
|
|
94
103
|
value = elemCont.get("value", None)
|
|
95
|
-
if value is not None and (
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
if value is not None and (
|
|
105
|
+
len(elemCont) == 1 or (len(elemCont) == 2 and "index" in elemCont)
|
|
106
|
+
):
|
|
107
|
+
elemCont = value # contains value only
|
|
98
108
|
parentKey = elem.tag
|
|
99
109
|
if key is not None and parentKey in ("list", "value", "group"):
|
|
100
110
|
# skip one level in hierarchy for these generic containers
|
|
@@ -103,21 +113,22 @@ def xmlPDHToDict(root):
|
|
|
103
113
|
try:
|
|
104
114
|
if isinstance(parentCont, list):
|
|
105
115
|
parentCont.insert(idx, elemCont)
|
|
106
|
-
elif parentKey not in parentCont:
|
|
107
|
-
if key is None:
|
|
116
|
+
elif parentKey not in parentCont: # add as new list
|
|
117
|
+
if key is None: # make a list
|
|
108
118
|
parentCont[parentKey] = elemCont
|
|
109
|
-
else:
|
|
119
|
+
else: # have a key
|
|
110
120
|
parentCont[parentKey] = {key: elemCont}
|
|
111
|
-
else:
|
|
112
|
-
if
|
|
113
|
-
|
|
121
|
+
else: # parentKey exists already
|
|
122
|
+
if not isinstance(parentCont[parentKey], list) and not isinstance(
|
|
123
|
+
parentCont[parentKey], dict
|
|
124
|
+
):
|
|
114
125
|
# if its a plain value before, make a list out of it and append in next step
|
|
115
126
|
parentCont[parentKey] = [parentCont[parentKey]]
|
|
116
127
|
if isinstance(parentCont[parentKey], list):
|
|
117
128
|
parentCont[parentKey].append(elemCont)
|
|
118
129
|
elif key is not None:
|
|
119
130
|
parentCont[parentKey].update({key: elemCont})
|
|
120
|
-
else:
|
|
131
|
+
else: # key is None
|
|
121
132
|
parentCont[parentKey].update(elemCont)
|
|
122
133
|
except AttributeError:
|
|
123
134
|
raise
|
|
@@ -126,31 +137,34 @@ def xmlPDHToDict(root):
|
|
|
126
137
|
# fix some entry values, weird Anton Paar PDH format
|
|
127
138
|
try:
|
|
128
139
|
oldts = result["fileinfo"]["parameter"]["DateTime"]["value"]
|
|
129
|
-
|
|
140
|
+
# timestamp seems to be based on around 2009-01-01 (a day give or take)
|
|
141
|
+
delta = (39 * 365 + 10) * 24 * 3600
|
|
130
142
|
# make it compatible to datetime.datetime routines
|
|
131
|
-
result["fileinfo"]["parameter"]["DateTime"]["value"] = oldts+delta
|
|
143
|
+
result["fileinfo"]["parameter"]["DateTime"]["value"] = oldts + delta
|
|
132
144
|
except KeyError:
|
|
133
145
|
pass
|
|
134
146
|
return result
|
|
135
147
|
|
|
148
|
+
|
|
136
149
|
def readPDHmeta(fp):
|
|
137
150
|
fp = Path(fp)
|
|
138
151
|
if fp.suffix.lower() != ".pdh":
|
|
139
152
|
warnings.warn("readPDHmeta() supports .pdh files only!")
|
|
140
|
-
return
|
|
153
|
+
return # for PDH files
|
|
141
154
|
lines = ""
|
|
142
155
|
with open(fp) as fd:
|
|
143
156
|
lines = fd.readlines()
|
|
144
157
|
nrows = int(lines[2].split()[0])
|
|
145
|
-
xml = "".join(lines[nrows+5:])
|
|
158
|
+
xml = "".join(lines[nrows + 5 :])
|
|
146
159
|
return xmlPDHToDict(et.fromstring(xml))
|
|
147
160
|
|
|
161
|
+
|
|
148
162
|
def readSSF(fp):
|
|
149
163
|
fp = Path(fp)
|
|
150
164
|
if fp.suffix.lower() != ".ssf":
|
|
151
165
|
warnings.warn("readSession() supports .ssf files only!")
|
|
152
166
|
return # for PDH files
|
|
153
167
|
data = ""
|
|
154
|
-
with open(fp, encoding=
|
|
168
|
+
with open(fp, encoding="utf-8-sig") as fd:
|
|
155
169
|
data = fd.read()
|
|
156
170
|
return xmlPDHToDict(et.fromstring(data))
|
jupyter_analysis_tools/utils.py
CHANGED
|
@@ -89,7 +89,8 @@ def addEnvScriptsToPATH():
|
|
|
89
89
|
"""Prepends the *Scripts* directory of the current Python environment base directory to systems
|
|
90
90
|
PATH variable.
|
|
91
91
|
|
|
92
|
-
It is intended for Conda (Miniforge) environments on Windows that do not have this in their PATH
|
|
92
|
+
It is intended for Conda (Miniforge) environments on Windows that do not have this in their PATH
|
|
93
|
+
environment variable, causing them to miss many commands provided from this location.
|
|
93
94
|
"""
|
|
94
95
|
envPath = [p for p in sys.path if p.endswith("Lib")]
|
|
95
96
|
if not envPath:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: jupyter-analysis-tools
|
|
3
|
-
Version: 1.2.
|
|
3
|
+
Version: 1.2.2
|
|
4
4
|
Summary: Yet another Python library with helpers and utilities for data analysis and processing.
|
|
5
5
|
Author-email: Ingo Breßler <dev@ingobressler.net>
|
|
6
6
|
License: MIT license
|
|
@@ -53,8 +53,8 @@ Yet another Python library with helpers and utilities for data analysis and proc
|
|
|
53
53
|
:target: https://pypi.org/project/jupyter-analysis-tools
|
|
54
54
|
:alt: PyPI Package latest release
|
|
55
55
|
|
|
56
|
-
.. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.2.
|
|
57
|
-
:target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.2.
|
|
56
|
+
.. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.2.2.svg
|
|
57
|
+
:target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.2.2...main
|
|
58
58
|
:alt: Commits since latest release
|
|
59
59
|
|
|
60
60
|
.. |license| image:: https://img.shields.io/pypi/l/jupyter-analysis-tools.svg
|
|
@@ -104,9 +104,9 @@ https://BAMresearch.github.io/jupyter-analysis-tools
|
|
|
104
104
|
Development
|
|
105
105
|
===========
|
|
106
106
|
|
|
107
|
-
|
|
107
|
+
Run all tests with::
|
|
108
108
|
|
|
109
|
-
tox
|
|
109
|
+
tox -e py
|
|
110
110
|
|
|
111
111
|
Note, to combine the coverage data from all the tox environments run:
|
|
112
112
|
|
|
@@ -127,6 +127,42 @@ Note, to combine the coverage data from all the tox environments run:
|
|
|
127
127
|
|
|
128
128
|
# CHANGELOG
|
|
129
129
|
|
|
130
|
+
## v1.2.2 (2025-07-15)
|
|
131
|
+
|
|
132
|
+
### Bug fixes
|
|
133
|
+
|
|
134
|
+
* readPDHmeta: use unique dict keys, the xmk *key* can occur in multiple groups in PDH ([`ef41c81`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/ef41c81d40d801b5baf86f56cf9012ca35d2ccde))
|
|
135
|
+
|
|
136
|
+
### Documentation
|
|
137
|
+
|
|
138
|
+
* pyproject: revert specify readme+changelog document types ([`1baa762`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1baa762d441fe0a1b7b663b9d0589de857277426))
|
|
139
|
+
|
|
140
|
+
* pyproject: specify readme+changelog document types to render overview on pypi correctly ([`6e4d1e5`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/6e4d1e56640b604f971ddca8dabd8d1aff5c9bf1))
|
|
141
|
+
|
|
142
|
+
* ghpages: make sure .nojekyll exists after purging old html docs ([`4847845`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/4847845cc06884b6e589b26897e83411d649ef4d))
|
|
143
|
+
|
|
144
|
+
## v1.2.1 (2025-07-11)
|
|
145
|
+
|
|
146
|
+
### Bug fixes
|
|
147
|
+
|
|
148
|
+
* readme: trigger new version after style changes ([`8b2b5e9`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/8b2b5e93c0f24ae59afaa764abdc508e994946b4))
|
|
149
|
+
|
|
150
|
+
### Code style
|
|
151
|
+
|
|
152
|
+
* __init__: imports format ([`6f07790`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/6f07790a04e43736b1c0fbce0eac54d0b661a7cf))
|
|
153
|
+
|
|
154
|
+
* utils: satisfy flake8 ([`9657474`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/9657474e94a4d9887c4a6b653e0ffa403e666d02))
|
|
155
|
+
|
|
156
|
+
* readdata: satisfy flake8 ([`36bf6e8`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/36bf6e8be67a2ebd345c5557c2352710bcebed82))
|
|
157
|
+
|
|
158
|
+
### Continuous integration
|
|
159
|
+
|
|
160
|
+
* workflow: publish only if the docs are good ([`a663ed3`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/a663ed3d1fd87079a4fd7cf419132a129280a562))
|
|
161
|
+
|
|
162
|
+
### Testing
|
|
163
|
+
|
|
164
|
+
* utils: fix imports ([`ddd5369`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/ddd5369b8037f583c6900aea25522a56126c9d32))
|
|
165
|
+
|
|
130
166
|
## v1.2.0 (2025-07-11)
|
|
131
167
|
|
|
132
168
|
### Features
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
jupyter_analysis_tools/__init__.py,sha256=
|
|
1
|
+
jupyter_analysis_tools/__init__.py,sha256=97TJ2mR74urGEdLA3G-jQqcSh_w-HKzX3XYzBZfez6A,386
|
|
2
2
|
jupyter_analysis_tools/analysis.py,sha256=AiAvUO648f0PYXqLfal1kDH926neasE5c1RYFu9wtYg,1768
|
|
3
3
|
jupyter_analysis_tools/binning.py,sha256=d6eXRC3IOnnJIF25OfEASyWedT71EX2nF7jAgGJ9suQ,14536
|
|
4
4
|
jupyter_analysis_tools/datalocations.py,sha256=BakfiZOMcBwp-_DAn7l57lGWZmZGNnk0j73V75nLBUA,4322
|
|
5
5
|
jupyter_analysis_tools/distrib.py,sha256=uyh2jXDdXR6dfd36CAoE5_psoFF0bfA6l1wletPD7Xo,16515
|
|
6
6
|
jupyter_analysis_tools/git.py,sha256=mqSk5nnAFrmk1_2KFuKVrDWOkRbGbAQOq2N1DfxhNpg,2216
|
|
7
7
|
jupyter_analysis_tools/plotting.py,sha256=L2gwSjlBVK8OneAfSuna3vCJIg2rSEdvd9TfEbM2Als,1183
|
|
8
|
-
jupyter_analysis_tools/readdata.py,sha256=
|
|
9
|
-
jupyter_analysis_tools/utils.py,sha256=
|
|
8
|
+
jupyter_analysis_tools/readdata.py,sha256=6Tncwo3NSYAnyLQzAhDtiUyp1Xpw3CahqQ_5NeGhJqI,6030
|
|
9
|
+
jupyter_analysis_tools/utils.py,sha256=dFE34fYQS7ivCfNy0nwwNPyBdZhIzW9QrxwjvvIHlIQ,5319
|
|
10
10
|
jupyter_analysis_tools/widgets.py,sha256=rA8qPvY9nS1OtykZwXtCTG29K-N_MYFVb5Aj8yK40_s,2996
|
|
11
|
-
jupyter_analysis_tools-1.2.
|
|
12
|
-
jupyter_analysis_tools-1.2.
|
|
13
|
-
jupyter_analysis_tools-1.2.
|
|
14
|
-
jupyter_analysis_tools-1.2.
|
|
15
|
-
jupyter_analysis_tools-1.2.
|
|
16
|
-
jupyter_analysis_tools-1.2.
|
|
11
|
+
jupyter_analysis_tools-1.2.2.dist-info/licenses/AUTHORS.rst,sha256=SUxxgElDBm6WdCbBBFfcr0ZE3SolWL0T0aS5Fym1198,100
|
|
12
|
+
jupyter_analysis_tools-1.2.2.dist-info/licenses/LICENSE,sha256=SrbIwXA1ZLTO6uwZneJMpvdgiC-3fhNl0vwb3ALoY4g,1107
|
|
13
|
+
jupyter_analysis_tools-1.2.2.dist-info/METADATA,sha256=xNHzAqCaV-gPgp8HB96pEeekWAWWJDeIhmJHDk0vgOA,37932
|
|
14
|
+
jupyter_analysis_tools-1.2.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
15
|
+
jupyter_analysis_tools-1.2.2.dist-info/top_level.txt,sha256=ei_0x-BF85FLoJ_h67ySwDFowtqus_gI4_0GR466PEU,23
|
|
16
|
+
jupyter_analysis_tools-1.2.2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
{jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{jupyter_analysis_tools-1.2.0.dist-info → jupyter_analysis_tools-1.2.2.dist-info}/top_level.txt
RENAMED
|
File without changes
|