jupyter-analysis-tools 1.0.0__tar.gz → 1.2.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.
Files changed (62) hide show
  1. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/.cookiecutterrc +1 -1
  2. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/CHANGELOG.md +38 -0
  3. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/MANIFEST.in +1 -0
  4. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/PKG-INFO +45 -4
  5. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/README.rst +2 -2
  6. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/conf.py +1 -2
  7. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/pyproject.toml +6 -2
  8. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/__init__.py +2 -5
  9. jupyter_analysis_tools-1.2.0/src/jupyter_analysis_tools/readdata.py +156 -0
  10. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/utils.py +38 -14
  11. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools.egg-info/PKG-INFO +45 -4
  12. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools.egg-info/SOURCES.txt +7 -2
  13. jupyter_analysis_tools-1.2.0/src/jupyter_analysis_tools.egg-info/requires.txt +5 -0
  14. jupyter_analysis_tools-1.2.0/testdata/2015-03-20-Silica.ssf.json +810 -0
  15. jupyter_analysis_tools-1.2.0/testdata/2015-03-20-Silica.ssfz +0 -0
  16. jupyter_analysis_tools-1.2.0/testdata/S2842 water.json +1798 -0
  17. jupyter_analysis_tools-1.2.0/testdata/S2842 water.pdh +1782 -0
  18. jupyter_analysis_tools-1.2.0/testdata/S2843[9].pdh +936 -0
  19. jupyter_analysis_tools-1.2.0/tests/readdata.py +104 -0
  20. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/tests/requirements.txt +1 -1
  21. jupyter_analysis_tools-1.2.0/tests/utils.py +33 -0
  22. jupyter_analysis_tools-1.0.0/src/jupyter_analysis_tools/notebook_utils.py +0 -36
  23. jupyter_analysis_tools-1.0.0/src/jupyter_analysis_tools/readdata.py +0 -47
  24. jupyter_analysis_tools-1.0.0/src/jupyter_analysis_tools.egg-info/requires.txt +0 -2
  25. jupyter_analysis_tools-1.0.0/tests/test_jupyter_analysis_tools.py +0 -6
  26. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/.editorconfig +0 -0
  27. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/.pre-commit-config.yaml +0 -0
  28. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/AUTHORS.rst +0 -0
  29. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/CONTRIBUTING.rst +0 -0
  30. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/LICENSE +0 -0
  31. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/requirements.txt +0 -0
  32. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/build.yml +0 -0
  33. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/ci-cd.yml +0 -0
  34. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/coverage.yml +0 -0
  35. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/docs.yml +0 -0
  36. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/release.yml +0 -0
  37. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/templates/.github/workflows/tests.yml +0 -0
  38. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/ci/update.py +0 -0
  39. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/_templates/class.rst +0 -0
  40. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/_templates/module.rst +0 -0
  41. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/authors.rst +0 -0
  42. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/changelog.rst +0 -0
  43. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/contributing.rst +0 -0
  44. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/index.rst +0 -0
  45. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/installation.rst +0 -0
  46. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/readme.rst +0 -0
  47. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/reference/index.rst +0 -0
  48. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/requirements.txt +0 -0
  49. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/spelling_wordlist.txt +0 -0
  50. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/docs/usage.rst +0 -0
  51. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/setup.cfg +0 -0
  52. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/analysis.py +0 -0
  53. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/binning.py +0 -0
  54. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/datalocations.py +0 -0
  55. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/distrib.py +0 -0
  56. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/git.py +0 -0
  57. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/plotting.py +0 -0
  58. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools/widgets.py +0 -0
  59. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools.egg-info/dependency_links.txt +0 -0
  60. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/src/jupyter_analysis_tools.egg-info/top_level.txt +0 -0
  61. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/templates/CHANGELOG.md.j2 +0 -0
  62. {jupyter_analysis_tools-1.0.0 → jupyter_analysis_tools-1.2.0}/tox.ini +0 -0
@@ -20,7 +20,7 @@ default_context:
20
20
  release_date: 'today'
21
21
  year_from: '2018'
22
22
  year_to: '2023'
23
- version: '1.0.0'
23
+ version: '1.2.0'
24
24
  pypi_host: 'pypi.org'
25
25
  license: 'MIT license'
26
26
  sphinx_theme: 'furo'
@@ -1,5 +1,43 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## v1.2.0 (2025-07-11)
4
+
5
+ ### Features
6
+
7
+ * readdata: readSSF() renamed from readSession(), tests added with expected JSON output ([`e2197f6`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/e2197f6bcb032c1bc1a9a7435e024dda763228c4))
8
+
9
+ * readPDHmeta: routine for reading metadata part from .PDH and .SSF files ([`ea6a1d5`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/ea6a1d554f3763fc05022ae8e4e8909f0993cd43))
10
+
11
+ ### Testing
12
+
13
+ * readdata: path separator depends on platform ([`1b2866f`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1b2866f13307c2cf2dedc59f36d7372442ddbfd8))
14
+
15
+ * readdata: testdata files and testing, using pathlib instead of old os.path ([`aeacfa4`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/aeacfa4a949d7293f2cd3ce5e3004fddf20ecc02))
16
+
17
+ ## v1.1.0 (2025-07-10)
18
+
19
+ ### Bug fixes
20
+
21
+ * packaging: add dependencies for project and testing ([`2729a45`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/2729a45958893c9acd07af9463bbf7d657db626b))
22
+
23
+ ### Documentation
24
+
25
+ * utils: reformat doc strings ([`1cf9b9b`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1cf9b9b969e075a75a41e19bfb526378b68a0ed7))
26
+
27
+ ### Features
28
+
29
+ * utils: addEnvScriptsToPATH() ([`a8c22e0`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/a8c22e0d37a5627d5955c1f7f7eebcb0bc99206e))
30
+
31
+ * notebook_utils: remove method for finding notebook file path currentNBpath() ([`13a5a60`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/13a5a60436c7926c478f2ab3f2c309a86b653218))
32
+
33
+ ### Refactoring
34
+
35
+ * utils: appendToPATH() using pathlib, verifed test included ([`35f37fc`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/35f37fc19cdcf4b575dc0525400f3c0212bb0faf))
36
+
37
+ ### Testing
38
+
39
+ * readdata: test data for reading PDH and SSFZ ([`9b919d2`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/9b919d24e1fa5679b49cebf576e471d6e4e9b655))
40
+
3
41
  ## v1.0.0 (2025-07-09)
4
42
 
5
43
  ### Bug fixes
@@ -17,3 +17,4 @@ include README.rst
17
17
 
18
18
  global-exclude *.py[cod] __pycache__/* *.so *.dylib .DS_Store */.ipynb_checkpoints/*
19
19
  recursive-include templates *.j2
20
+ recursive-include testdata *.pdh *.ssfz *.json
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jupyter-analysis-tools
3
- Version: 1.0.0
3
+ Version: 1.2.0
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
@@ -30,7 +30,10 @@ Classifier: Intended Audience :: Science/Research
30
30
  Description-Content-Type: text/x-rst
31
31
  License-File: LICENSE
32
32
  License-File: AUTHORS.rst
33
- Requires-Dist: notebook
33
+ Requires-Dist: numpy
34
+ Requires-Dist: scipy
35
+ Requires-Dist: pandas
36
+ Requires-Dist: matplotlib
34
37
  Requires-Dist: ipywidgets
35
38
  Dynamic: license-file
36
39
 
@@ -50,8 +53,8 @@ Yet another Python library with helpers and utilities for data analysis and proc
50
53
  :target: https://pypi.org/project/jupyter-analysis-tools
51
54
  :alt: PyPI Package latest release
52
55
 
53
- .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.0.0.svg
54
- :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.0.0...main
56
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.2.0.svg
57
+ :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.2.0...main
55
58
  :alt: Commits since latest release
56
59
 
57
60
  .. |license| image:: https://img.shields.io/pypi/l/jupyter-analysis-tools.svg
@@ -124,6 +127,44 @@ Note, to combine the coverage data from all the tox environments run:
124
127
 
125
128
  # CHANGELOG
126
129
 
130
+ ## v1.2.0 (2025-07-11)
131
+
132
+ ### Features
133
+
134
+ * readdata: readSSF() renamed from readSession(), tests added with expected JSON output ([`e2197f6`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/e2197f6bcb032c1bc1a9a7435e024dda763228c4))
135
+
136
+ * readPDHmeta: routine for reading metadata part from .PDH and .SSF files ([`ea6a1d5`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/ea6a1d554f3763fc05022ae8e4e8909f0993cd43))
137
+
138
+ ### Testing
139
+
140
+ * readdata: path separator depends on platform ([`1b2866f`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1b2866f13307c2cf2dedc59f36d7372442ddbfd8))
141
+
142
+ * readdata: testdata files and testing, using pathlib instead of old os.path ([`aeacfa4`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/aeacfa4a949d7293f2cd3ce5e3004fddf20ecc02))
143
+
144
+ ## v1.1.0 (2025-07-10)
145
+
146
+ ### Bug fixes
147
+
148
+ * packaging: add dependencies for project and testing ([`2729a45`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/2729a45958893c9acd07af9463bbf7d657db626b))
149
+
150
+ ### Documentation
151
+
152
+ * utils: reformat doc strings ([`1cf9b9b`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1cf9b9b969e075a75a41e19bfb526378b68a0ed7))
153
+
154
+ ### Features
155
+
156
+ * utils: addEnvScriptsToPATH() ([`a8c22e0`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/a8c22e0d37a5627d5955c1f7f7eebcb0bc99206e))
157
+
158
+ * notebook_utils: remove method for finding notebook file path currentNBpath() ([`13a5a60`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/13a5a60436c7926c478f2ab3f2c309a86b653218))
159
+
160
+ ### Refactoring
161
+
162
+ * utils: appendToPATH() using pathlib, verifed test included ([`35f37fc`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/35f37fc19cdcf4b575dc0525400f3c0212bb0faf))
163
+
164
+ ### Testing
165
+
166
+ * readdata: test data for reading PDH and SSFZ ([`9b919d2`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/9b919d24e1fa5679b49cebf576e471d6e4e9b655))
167
+
127
168
  ## v1.0.0 (2025-07-09)
128
169
 
129
170
  ### Bug fixes
@@ -14,8 +14,8 @@ Yet another Python library with helpers and utilities for data analysis and proc
14
14
  :target: https://pypi.org/project/jupyter-analysis-tools
15
15
  :alt: PyPI Package latest release
16
16
 
17
- .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.0.0.svg
18
- :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.0.0...main
17
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.2.0.svg
18
+ :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.2.0...main
19
19
  :alt: Commits since latest release
20
20
 
21
21
  .. |license| image:: https://img.shields.io/pypi/l/jupyter-analysis-tools.svg
@@ -29,7 +29,7 @@ project = "Jupyter Analysis Tools"
29
29
  year = "2018-2023"
30
30
  author = "Ingo Breßler"
31
31
  copyright = "{0}, {1}".format(year, author)
32
- version = "1.0.0"
32
+ version = "1.2.0"
33
33
  release = version
34
34
  commit_id = None
35
35
  try:
@@ -42,7 +42,6 @@ except subprocess.CalledProcessError as e:
42
42
 
43
43
  autodoc_mock_imports = [
44
44
  "ipykernel",
45
- "notebook",
46
45
  "pandas",
47
46
  "ipywidgets",
48
47
  "matplotlib",
@@ -27,8 +27,7 @@ classifiers = [
27
27
  "Intended Audience :: Science/Research",
28
28
  ]
29
29
  dependencies = [
30
- "notebook",
31
- "ipywidgets"
30
+ "numpy", "scipy", "pandas", "matplotlib", "ipywidgets"
32
31
  ]
33
32
 
34
33
  [project.urls]
@@ -84,3 +83,8 @@ group_by_package = true
84
83
  known_first_party = "jupyter_analysis_tools"
85
84
  ensure_newline_before_comments = true
86
85
  extend_skip = ["ci/templates", ".ipynb_checkpoints"]
86
+
87
+ [tool.docformatter]
88
+ recursive = true
89
+ wrap-summaries = 100
90
+ wrap-descriptions = 100
@@ -1,16 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # __init__.py
3
3
 
4
- __version__ = "1.0.0"
4
+ __version__ = "1.2.0"
5
5
 
6
6
  from .binning import reBin
7
7
  from .git import checkRepo, isNBstripoutActivated, isNBstripoutInstalled, isRepo
8
- from .notebook_utils import currentNBpath
9
- from .readdata import readdata
8
+ from .readdata import readdata, readPDHmeta, readSSF
10
9
  from .readdata import readdata as readPDH
11
10
  from .utils import setLocaleUTF8
12
11
  from .widgets import PathSelector, showBoolStatus
13
12
 
14
13
  setLocaleUTF8()
15
-
16
- # vim: set ts=4 sts=4 sw=4 tw=0:
@@ -0,0 +1,156 @@
1
+ # -*- coding: utf-8 -*-
2
+ # readdata.py
3
+
4
+ import json
5
+ import warnings
6
+ import xml.etree.ElementTree as et
7
+ from pathlib import Path
8
+
9
+ import pandas as pd
10
+
11
+
12
+ def readdata(fpath, q_range=None, read_csv_args=None, print_filename=True):
13
+ """Read a datafile pandas Dataframe
14
+ extract a file_name
15
+ select q-range: q_min <= q <= q_max
16
+ """
17
+ fpath = Path(fpath)
18
+ if print_filename:
19
+ print(f"Reading file '{str(fpath)}'")
20
+ if read_csv_args is None:
21
+ read_csv_args = dict()
22
+ if "sep" not in read_csv_args:
23
+ read_csv_args.update(sep=r"\s+")
24
+ if "names" not in read_csv_args:
25
+ read_csv_args.update(names=("q", "I", "e"))
26
+ if "index_col" not in read_csv_args:
27
+ read_csv_args.update(index_col=False)
28
+ # print("f_read_data, read_csv_args:", read_csv_args) # for debugging
29
+
30
+ file_ext = fpath.suffix
31
+ if file_ext.lower() == ".pdh": # for PDH files
32
+ nrows = pd.read_csv(
33
+ fpath,
34
+ skiprows=2,
35
+ nrows=1,
36
+ usecols=[
37
+ 0,
38
+ ],
39
+ sep=r"\s+",
40
+ header=None,
41
+ ).values[0, 0]
42
+ read_csv_args.update(skiprows=5, nrows=nrows)
43
+ df = pd.read_csv(fpath, **read_csv_args)
44
+
45
+ # select q-range
46
+ if q_range is not None:
47
+ q_min, q_max = q_range
48
+ df = df[(df.q > q_min) & (df.q < q_max)]
49
+
50
+ filename = fpath.stem.split("[")[0]
51
+ return df, filename
52
+
53
+
54
+ def convertValue(val):
55
+ val = val.strip()
56
+ try:
57
+ return int(val)
58
+ except ValueError:
59
+ try:
60
+ return float(val)
61
+ except ValueError:
62
+ pass
63
+ return val
64
+
65
+ def xmlPDHToDict(root):
66
+ result = {}
67
+ stack = [(root, result)]
68
+ while stack:
69
+ elem, parentCont = stack.pop()
70
+ elemCont = {}
71
+ key = elem.attrib.pop("key", None)
72
+ idx = -1
73
+ if (not len(list(elem)) and not len(elem.attrib)
74
+ and not (elem.text and len(elem.text.strip()))):
75
+ continue # skip empty elements with a key only early
76
+ if elem.tag == "list":
77
+ elemCont = []
78
+ else: # add attributes & values to dict
79
+ # Attach text, if any
80
+ if elem.text and len(elem.text.strip()):
81
+ if elem.tag in ("value", "reference"):
82
+ elemCont["value"] = convertValue(elem.text)
83
+ else:
84
+ elemCont["#text"] = convertValue(elem.text)
85
+ # Attach attributes, if any
86
+ if elem.attrib:
87
+ elemCont.update({k: convertValue(v) for k, v in elem.attrib.items() if len(v.strip())})
88
+ if key == "unit" and "value" in elemCont: # fix some units
89
+ elemCont["value"] = elemCont["value"].replace("_", "")
90
+ if "unit" in elemCont:
91
+ elemCont["unit"] = elemCont["unit"].replace("_", "")
92
+ # reduce the extracted dict&attributes
93
+ idx = elemCont.get("index", -1) # insert last/append if no index given
94
+ value = elemCont.get("value", None)
95
+ if value is not None and (len(elemCont) == 1
96
+ or (len(elemCont) == 2 and "index" in elemCont)):
97
+ elemCont = value # contains value only
98
+ parentKey = elem.tag
99
+ if key is not None and parentKey in ("list", "value", "group"):
100
+ # skip one level in hierarchy for these generic containers
101
+ parentKey = key
102
+ key = None
103
+ try:
104
+ if isinstance(parentCont, list):
105
+ parentCont.insert(idx, elemCont)
106
+ elif parentKey not in parentCont: # add as new list
107
+ if key is None: # make a list
108
+ parentCont[parentKey] = elemCont
109
+ else: # have a key
110
+ parentCont[parentKey] = {key: elemCont}
111
+ else: # parentKey exists already
112
+ if (not isinstance(parentCont[parentKey], list) and
113
+ not isinstance(parentCont[parentKey], dict)):
114
+ # if its a plain value before, make a list out of it and append in next step
115
+ parentCont[parentKey] = [parentCont[parentKey]]
116
+ if isinstance(parentCont[parentKey], list):
117
+ parentCont[parentKey].append(elemCont)
118
+ elif key is not None:
119
+ parentCont[parentKey].update({key: elemCont})
120
+ else: # key is None
121
+ parentCont[parentKey].update(elemCont)
122
+ except AttributeError:
123
+ raise
124
+ # reversed for correct order
125
+ stack += [(child, elemCont) for child in reversed(list(elem))]
126
+ # fix some entry values, weird Anton Paar PDH format
127
+ try:
128
+ oldts = result["fileinfo"]["parameter"]["DateTime"]["value"]
129
+ delta = (39*365+10)*24*3600 # timestamp seems to be based on around 2009-01-01 (a day give or take)
130
+ # make it compatible to datetime.datetime routines
131
+ result["fileinfo"]["parameter"]["DateTime"]["value"] = oldts+delta
132
+ except KeyError:
133
+ pass
134
+ return result
135
+
136
+ def readPDHmeta(fp):
137
+ fp = Path(fp)
138
+ if fp.suffix.lower() != ".pdh":
139
+ warnings.warn("readPDHmeta() supports .pdh files only!")
140
+ return # for PDH files
141
+ lines = ""
142
+ with open(fp) as fd:
143
+ lines = fd.readlines()
144
+ nrows = int(lines[2].split()[0])
145
+ xml = "".join(lines[nrows+5:])
146
+ return xmlPDHToDict(et.fromstring(xml))
147
+
148
+ def readSSF(fp):
149
+ fp = Path(fp)
150
+ if fp.suffix.lower() != ".ssf":
151
+ warnings.warn("readSession() supports .ssf files only!")
152
+ return # for PDH files
153
+ data = ""
154
+ with open(fp, encoding='utf-8-sig') as fd:
155
+ data = fd.read()
156
+ return xmlPDHToDict(et.fromstring(data))
@@ -17,7 +17,7 @@ indent = " "
17
17
 
18
18
 
19
19
  def setLocaleUTF8():
20
- """Fix the Jupyter locale which is not UTF-8 by default on some systems (older Windows?)."""
20
+ """Fix the Jupyter locale which is not UTF-8 by default on Windows."""
21
21
  locOld = locale.getpreferredencoding(False).lower()
22
22
 
23
23
  def getpreferredencoding(do_setlocale=True):
@@ -42,8 +42,7 @@ def isWindows():
42
42
 
43
43
 
44
44
  def isList(obj):
45
- """Return true if the provided object is list-like including a numpy array
46
- but not a string.
45
+ """Return true if the provided object is list-like including a numpy array but not a string.
47
46
 
48
47
  >>> isList([1, 2, 'a'])
49
48
  True
@@ -68,18 +67,41 @@ def shortenWinPath(path):
68
67
  return win32api.GetShortPathName(path)
69
68
 
70
69
 
71
- def appendToPATH(parentPath, subdirs=None):
70
+ def appendToPATH(parentPath, subdirs=None, verbose=False):
72
71
  """Adds the given path with each subdirectory to the PATH environment variable."""
73
- if not os.path.isdir(parentPath):
72
+ parentPath = Path(parentPath)
73
+ if not parentPath.is_dir():
74
74
  return # nothing to do
75
75
  if subdirs is None:
76
76
  subdirs = ["."]
77
+ sep = ";" if isWindows() else ":"
78
+ PATH = os.environ["PATH"].split(sep)
77
79
  for path in subdirs:
78
- path = os.path.realpath(os.path.join(parentPath, *path.split("/")))
79
- print(indent, path, "\t[{}]".format(os.path.isdir(path)))
80
- if path in os.environ["PATH"]:
81
- continue
82
- os.environ["PATH"] += ";" + path
80
+ path = parentPath / path
81
+ if verbose:
82
+ print(indent, path, "[exists: {}]".format(path.is_dir()))
83
+ if path not in PATH:
84
+ PATH.append(str(path))
85
+ os.environ["PATH"] = sep.join(PATH)
86
+
87
+
88
+ def addEnvScriptsToPATH():
89
+ """Prepends the *Scripts* directory of the current Python environment base directory to systems
90
+ PATH variable.
91
+
92
+ It is intended for Conda (Miniforge) environments on Windows that do not have this in their PATH environment variable, causing them to miss many commands provided from this location.
93
+ """
94
+ envPath = [p for p in sys.path if p.endswith("Lib")]
95
+ if not envPath:
96
+ return # probably not a Miniforge environment
97
+ envPath = envPath[0]
98
+ envPath = Path(envPath).parent / "Scripts"
99
+ sep = ";" if isWindows() else ":"
100
+ environPATH = os.environ["PATH"].split(sep)
101
+ # print(environPATH)
102
+ if envPath.exists() and str(envPath) not in environPATH:
103
+ environPATH = [str(envPath)] + environPATH
104
+ os.environ["PATH"] = sep.join(environPATH)
83
105
 
84
106
 
85
107
  def checkWinFor7z():
@@ -126,9 +148,11 @@ def pushd(new_dir):
126
148
 
127
149
 
128
150
  def setPackage(globalsdict):
129
- """Sets the current directory of the notebook as python package
130
- to make relative module imports work.
131
- Usage: `setPackage(globals())`"""
151
+ """Sets the current directory of the notebook as python package to make relative module imports
152
+ work.
153
+
154
+ Usage: `setPackage(globals())`
155
+ """
132
156
  path = Path().resolve()
133
157
  searchpath = str(path.parent)
134
158
  if searchpath not in sys.path:
@@ -145,7 +169,7 @@ def grouper(iterable, n, fillvalue=None):
145
169
 
146
170
 
147
171
  def fmtErr(val, std, precision=2, width=None):
148
- """Formats a given value and its std. deviation to physics notation, e.g. '1.23(4)'."""
172
+ """Formats a given value and its stdandard deviation to physics notation, e.g. '1.23(4)'."""
149
173
  if width is None:
150
174
  width = ""
151
175
  fmt = "{:" + str(width) + "." + str(precision) + "f}({:.0f})"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jupyter-analysis-tools
3
- Version: 1.0.0
3
+ Version: 1.2.0
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
@@ -30,7 +30,10 @@ Classifier: Intended Audience :: Science/Research
30
30
  Description-Content-Type: text/x-rst
31
31
  License-File: LICENSE
32
32
  License-File: AUTHORS.rst
33
- Requires-Dist: notebook
33
+ Requires-Dist: numpy
34
+ Requires-Dist: scipy
35
+ Requires-Dist: pandas
36
+ Requires-Dist: matplotlib
34
37
  Requires-Dist: ipywidgets
35
38
  Dynamic: license-file
36
39
 
@@ -50,8 +53,8 @@ Yet another Python library with helpers and utilities for data analysis and proc
50
53
  :target: https://pypi.org/project/jupyter-analysis-tools
51
54
  :alt: PyPI Package latest release
52
55
 
53
- .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.0.0.svg
54
- :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.0.0...main
56
+ .. |commits-since| image:: https://img.shields.io/github/commits-since/BAMresearch/jupyter-analysis-tools/v1.2.0.svg
57
+ :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.2.0...main
55
58
  :alt: Commits since latest release
56
59
 
57
60
  .. |license| image:: https://img.shields.io/pypi/l/jupyter-analysis-tools.svg
@@ -124,6 +127,44 @@ Note, to combine the coverage data from all the tox environments run:
124
127
 
125
128
  # CHANGELOG
126
129
 
130
+ ## v1.2.0 (2025-07-11)
131
+
132
+ ### Features
133
+
134
+ * readdata: readSSF() renamed from readSession(), tests added with expected JSON output ([`e2197f6`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/e2197f6bcb032c1bc1a9a7435e024dda763228c4))
135
+
136
+ * readPDHmeta: routine for reading metadata part from .PDH and .SSF files ([`ea6a1d5`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/ea6a1d554f3763fc05022ae8e4e8909f0993cd43))
137
+
138
+ ### Testing
139
+
140
+ * readdata: path separator depends on platform ([`1b2866f`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1b2866f13307c2cf2dedc59f36d7372442ddbfd8))
141
+
142
+ * readdata: testdata files and testing, using pathlib instead of old os.path ([`aeacfa4`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/aeacfa4a949d7293f2cd3ce5e3004fddf20ecc02))
143
+
144
+ ## v1.1.0 (2025-07-10)
145
+
146
+ ### Bug fixes
147
+
148
+ * packaging: add dependencies for project and testing ([`2729a45`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/2729a45958893c9acd07af9463bbf7d657db626b))
149
+
150
+ ### Documentation
151
+
152
+ * utils: reformat doc strings ([`1cf9b9b`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1cf9b9b969e075a75a41e19bfb526378b68a0ed7))
153
+
154
+ ### Features
155
+
156
+ * utils: addEnvScriptsToPATH() ([`a8c22e0`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/a8c22e0d37a5627d5955c1f7f7eebcb0bc99206e))
157
+
158
+ * notebook_utils: remove method for finding notebook file path currentNBpath() ([`13a5a60`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/13a5a60436c7926c478f2ab3f2c309a86b653218))
159
+
160
+ ### Refactoring
161
+
162
+ * utils: appendToPATH() using pathlib, verifed test included ([`35f37fc`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/35f37fc19cdcf4b575dc0525400f3c0212bb0faf))
163
+
164
+ ### Testing
165
+
166
+ * readdata: test data for reading PDH and SSFZ ([`9b919d2`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/9b919d24e1fa5679b49cebf576e471d6e4e9b655))
167
+
127
168
  ## v1.0.0 (2025-07-09)
128
169
 
129
170
  ### Bug fixes
@@ -36,7 +36,6 @@ src/jupyter_analysis_tools/binning.py
36
36
  src/jupyter_analysis_tools/datalocations.py
37
37
  src/jupyter_analysis_tools/distrib.py
38
38
  src/jupyter_analysis_tools/git.py
39
- src/jupyter_analysis_tools/notebook_utils.py
40
39
  src/jupyter_analysis_tools/plotting.py
41
40
  src/jupyter_analysis_tools/readdata.py
42
41
  src/jupyter_analysis_tools/utils.py
@@ -47,5 +46,11 @@ src/jupyter_analysis_tools.egg-info/dependency_links.txt
47
46
  src/jupyter_analysis_tools.egg-info/requires.txt
48
47
  src/jupyter_analysis_tools.egg-info/top_level.txt
49
48
  templates/CHANGELOG.md.j2
49
+ testdata/2015-03-20-Silica.ssf.json
50
+ testdata/2015-03-20-Silica.ssfz
51
+ testdata/S2842 water.json
52
+ testdata/S2842 water.pdh
53
+ testdata/S2843[9].pdh
54
+ tests/readdata.py
50
55
  tests/requirements.txt
51
- tests/test_jupyter_analysis_tools.py
56
+ tests/utils.py
@@ -0,0 +1,5 @@
1
+ numpy
2
+ scipy
3
+ pandas
4
+ matplotlib
5
+ ipywidgets