jupyter-analysis-tools 1.0.0__py3-none-any.whl → 1.1.0__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.
@@ -1,16 +1,13 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # __init__.py
3
3
 
4
- __version__ = "1.0.0"
4
+ __version__ = "1.1.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
8
  from .readdata import readdata
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:
@@ -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.1.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.1.0.svg
57
+ :target: https://github.com/BAMresearch/jupyter-analysis-tools/compare/v1.1.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,30 @@ Note, to combine the coverage data from all the tox environments run:
124
127
 
125
128
  # CHANGELOG
126
129
 
130
+ ## v1.1.0 (2025-07-10)
131
+
132
+ ### Bug fixes
133
+
134
+ * packaging: add dependencies for project and testing ([`2729a45`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/2729a45958893c9acd07af9463bbf7d657db626b))
135
+
136
+ ### Documentation
137
+
138
+ * utils: reformat doc strings ([`1cf9b9b`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/1cf9b9b969e075a75a41e19bfb526378b68a0ed7))
139
+
140
+ ### Features
141
+
142
+ * utils: addEnvScriptsToPATH() ([`a8c22e0`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/a8c22e0d37a5627d5955c1f7f7eebcb0bc99206e))
143
+
144
+ * notebook_utils: remove method for finding notebook file path currentNBpath() ([`13a5a60`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/13a5a60436c7926c478f2ab3f2c309a86b653218))
145
+
146
+ ### Refactoring
147
+
148
+ * utils: appendToPATH() using pathlib, verifed test included ([`35f37fc`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/35f37fc19cdcf4b575dc0525400f3c0212bb0faf))
149
+
150
+ ### Testing
151
+
152
+ * readdata: test data for reading PDH and SSFZ ([`9b919d2`](https://github.com/BAMresearch/jupyter-analysis-tools/commit/9b919d24e1fa5679b49cebf576e471d6e4e9b655))
153
+
127
154
  ## v1.0.0 (2025-07-09)
128
155
 
129
156
  ### Bug fixes
@@ -1,17 +1,16 @@
1
- jupyter_analysis_tools/__init__.py,sha256=56tfdRxdt1BLkFcipMas0-sbeVXpldPVoggIHrkEJMw,419
1
+ jupyter_analysis_tools/__init__.py,sha256=I4Vdvl5uMDvIcs12ZZlMYaFzLrCrUerH5ZkWzgSKhUs,343
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
- jupyter_analysis_tools/notebook_utils.py,sha256=5MwYjUy4Skn9goFOP_qKFPPBN4VkffBishHVSD_fPFo,1263
8
7
  jupyter_analysis_tools/plotting.py,sha256=L2gwSjlBVK8OneAfSuna3vCJIg2rSEdvd9TfEbM2Als,1183
9
8
  jupyter_analysis_tools/readdata.py,sha256=Z0LCAYKEauItdDF6H0gJYR74EKgR2-XFHo5gKlTz7cw,1348
10
- jupyter_analysis_tools/utils.py,sha256=KEzQMp4fY8KfL1Cc03Kj85lftoBWYuzEu7HmwNW761M,4402
9
+ jupyter_analysis_tools/utils.py,sha256=cwbviD1YP06rVhtItdORHEbp8fQ7JfhcrYDONRM336Y,5315
11
10
  jupyter_analysis_tools/widgets.py,sha256=rA8qPvY9nS1OtykZwXtCTG29K-N_MYFVb5Aj8yK40_s,2996
12
- jupyter_analysis_tools-1.0.0.dist-info/licenses/AUTHORS.rst,sha256=SUxxgElDBm6WdCbBBFfcr0ZE3SolWL0T0aS5Fym1198,100
13
- jupyter_analysis_tools-1.0.0.dist-info/licenses/LICENSE,sha256=SrbIwXA1ZLTO6uwZneJMpvdgiC-3fhNl0vwb3ALoY4g,1107
14
- jupyter_analysis_tools-1.0.0.dist-info/METADATA,sha256=RmJTHcgRAtcwIOgDrII1GgRnHg1zanDEpsIIwWoUoHc,34113
15
- jupyter_analysis_tools-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
16
- jupyter_analysis_tools-1.0.0.dist-info/top_level.txt,sha256=ei_0x-BF85FLoJ_h67ySwDFowtqus_gI4_0GR466PEU,23
17
- jupyter_analysis_tools-1.0.0.dist-info/RECORD,,
11
+ jupyter_analysis_tools-1.1.0.dist-info/licenses/AUTHORS.rst,sha256=SUxxgElDBm6WdCbBBFfcr0ZE3SolWL0T0aS5Fym1198,100
12
+ jupyter_analysis_tools-1.1.0.dist-info/licenses/LICENSE,sha256=SrbIwXA1ZLTO6uwZneJMpvdgiC-3fhNl0vwb3ALoY4g,1107
13
+ jupyter_analysis_tools-1.1.0.dist-info/METADATA,sha256=34HMf-Q8hrdj1SemL1o8-eJEAyhLBz--BX3c2B_6GUM,35291
14
+ jupyter_analysis_tools-1.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ jupyter_analysis_tools-1.1.0.dist-info/top_level.txt,sha256=ei_0x-BF85FLoJ_h67ySwDFowtqus_gI4_0GR466PEU,23
16
+ jupyter_analysis_tools-1.1.0.dist-info/RECORD,,
@@ -1,36 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- # notebook_utils.py
3
-
4
- import json
5
- import os
6
- import urllib
7
-
8
- import ipykernel
9
-
10
- try:
11
- from notebook import notebookapp
12
- except ImportError:
13
- from notebook import app as notebookapp
14
-
15
-
16
- def currentNBpath():
17
- """Returns the absolute path of the Notebook or None if it cannot be determined
18
- NOTE: works only for *Jupyter Notebook* (not Jupyter Lab)
19
- and when the security is token-based or there is also no password.
20
- """
21
- connection_file = os.path.basename(ipykernel.get_connection_file())
22
- kernel_id = connection_file.split("-", 1)[1].split(".")[0]
23
-
24
- for srv in notebookapp.list_running_servers():
25
- try:
26
- if srv["token"] == "" and not srv["password"]: # No token and no password, ahem...
27
- req = urllib.request.urlopen(srv["url"] + "api/sessions")
28
- else:
29
- req = urllib.request.urlopen(srv["url"] + "api/sessions?token=" + srv["token"])
30
- sessions = json.load(req)
31
- for sess in sessions:
32
- if sess["kernel"]["id"] == kernel_id:
33
- return os.path.join(srv["notebook_dir"], sess["notebook"]["path"])
34
- except OSError:
35
- pass # There may be stale entries in the runtime directory
36
- return None