essreduce 25.7.1__py3-none-any.whl → 25.9.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.
ess/reduce/data.py CHANGED
@@ -1,10 +1,29 @@
1
1
  # SPDX-License-Identifier: BSD-3-Clause
2
- # Copyright (c) 2024 Scipp contributors (https://github.com/scipp)
3
- import pooch
2
+ # Copyright (c) 2025 Scipp contributors (https://github.com/scipp)
3
+ """Data files bundled with ESSreduce."""
4
+
5
+ from functools import cache
6
+ from pathlib import Path
4
7
 
5
8
 
6
9
  class Registry:
7
- def __init__(self, instrument: str, files: dict[str, str], version: str):
10
+ """A registry for data files.
11
+
12
+ Note
13
+ ----
14
+ This class requires [Pooch](https://www.fatiando.org/pooch/latest/) which
15
+ is not a hard dependency of ESSreduce and needs to be installed separately.
16
+ """
17
+
18
+ def __init__(
19
+ self,
20
+ instrument: str,
21
+ files: dict[str, str],
22
+ version: str,
23
+ retry_if_failed: int = 3,
24
+ ) -> None:
25
+ import pooch
26
+
8
27
  self._registry = pooch.create(
9
28
  path=pooch.os_cache(f'ess/{instrument}'),
10
29
  env=f'ESS_{instrument.upper()}_DATA_DIR',
@@ -12,14 +31,27 @@ class Registry:
12
31
  + '{version}/',
13
32
  version=version,
14
33
  registry=files,
34
+ retry_if_failed=retry_if_failed,
15
35
  )
36
+ self._unzip_processor = pooch.Unzip()
16
37
 
17
- def __contains__(self, key):
38
+ def __contains__(self, key: str) -> bool:
39
+ """Return True if the key is in the registry."""
18
40
  return key in self._registry.registry
19
41
 
20
- def get_path(self, name: str, unzip: bool = False) -> str:
21
- """
22
- Get the path to a file in the registry.
42
+ @cache # noqa: B019
43
+ def get_path(self, name: str, unzip: bool = False) -> Path:
44
+ """Get the path to a file in the registry.
45
+
46
+ Downloads the file if necessary.
47
+
48
+ Note that return values of this method are cached to avoid recomputing
49
+ potentially expensive checksums.
50
+ This usually means that the ``Registry`` object itself gets stored until the
51
+ Python interpreter shuts down.
52
+ However, registries are small and do not own resources.
53
+ It is anyway expected that the registry objects are stored at
54
+ module scope and live until program exit.
23
55
 
24
56
  Parameters
25
57
  ----------
@@ -27,8 +59,17 @@ class Registry:
27
59
  Name of the file to get the path for.
28
60
  unzip:
29
61
  If `True`, unzip the file before returning the path.
62
+
63
+ Returns
64
+ -------
65
+ :
66
+ The Path to the file.
30
67
  """
31
- return self._registry.fetch(name, processor=pooch.Unzip() if unzip else None)
68
+ return Path(
69
+ self._registry.fetch(
70
+ name, processor=self._unzip_processor if unzip else None
71
+ )
72
+ )
32
73
 
33
74
 
34
75
  _bifrost_registry = Registry(
@@ -75,37 +116,37 @@ _loki_registry = Registry(
75
116
  )
76
117
 
77
118
 
78
- def bifrost_simulated_elastic() -> str:
119
+ def bifrost_simulated_elastic() -> Path:
79
120
  """McStas simulation with elastic incoherent scattering + phonon."""
80
121
  return _bifrost_registry.get_path('BIFROST_20240914T053723.h5')
81
122
 
82
123
 
83
- def loki_tutorial_sample_run_60250() -> str:
124
+ def loki_tutorial_sample_run_60250() -> Path:
84
125
  """Sample run with sample and sample holder/can, no transmission monitor in beam."""
85
126
  return _loki_registry.get_path('60250-2022-02-28_2215.nxs')
86
127
 
87
128
 
88
- def loki_tutorial_sample_run_60339() -> str:
129
+ def loki_tutorial_sample_run_60339() -> Path:
89
130
  """Sample run with sample and sample holder/can, no transmission monitor in beam."""
90
131
  return _loki_registry.get_path('60339-2022-02-28_2215.nxs')
91
132
 
92
133
 
93
- def loki_tutorial_background_run_60248() -> str:
134
+ def loki_tutorial_background_run_60248() -> Path:
94
135
  """Background run with sample holder/can only, no transmission monitor."""
95
136
  return _loki_registry.get_path('60248-2022-02-28_2215.nxs')
96
137
 
97
138
 
98
- def loki_tutorial_background_run_60393() -> str:
139
+ def loki_tutorial_background_run_60393() -> Path:
99
140
  """Background run with sample holder/can only, no transmission monitor."""
100
141
  return _loki_registry.get_path('60393-2022-02-28_2215.nxs')
101
142
 
102
143
 
103
- def loki_tutorial_sample_transmission_run() -> str:
144
+ def loki_tutorial_sample_transmission_run() -> Path:
104
145
  """Sample transmission run (sample + sample holder/can + transmission monitor)."""
105
146
  return _loki_registry.get_path('60394-2022-02-28_2215.nxs')
106
147
 
107
148
 
108
- def dream_coda_test_file() -> str:
149
+ def dream_coda_test_file() -> Path:
109
150
  """CODA file for DREAM where most pulses have been removed.
110
151
 
111
152
  See ``tools/shrink_nexus.py``.
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: essreduce
3
+ Version: 25.9.0
4
+ Summary: Common data reduction tools for the ESS facility
5
+ Author: Scipp contributors
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Bug Tracker, https://github.com/scipp/essreduce/issues
8
+ Project-URL: Documentation, https://scipp.github.io/essreduce
9
+ Project-URL: Source, https://github.com/scipp/essreduce
10
+ Classifier: Intended Audience :: Science/Research
11
+ Classifier: Natural Language :: English
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3 :: Only
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.11
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: sciline>=25.05.1
24
+ Requires-Dist: scipp>=25.04.0
25
+ Requires-Dist: scippneutron>=25.02.0
26
+ Requires-Dist: scippnexus>=24.11.0
27
+ Provides-Extra: test
28
+ Requires-Dist: ipywidgets>=8.1; extra == "test"
29
+ Requires-Dist: numba>=0.59; extra == "test"
30
+ Requires-Dist: pooch>=1.5; extra == "test"
31
+ Requires-Dist: pytest>=7.0; extra == "test"
32
+ Requires-Dist: scipy>=1.14; extra == "test"
33
+ Requires-Dist: tof>=25.05.0; extra == "test"
34
+ Dynamic: license-file
35
+
36
+ [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
37
+ [![PyPI badge](http://img.shields.io/pypi/v/essreduce.svg)](https://pypi.python.org/pypi/essreduce)
38
+ [![Anaconda-Server Badge](https://anaconda.org/conda-forge/essreduce/badges/version.svg)](https://anaconda.org/conda-forge/essreduce)
39
+ [![License: BSD 3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
40
+
41
+ # ESSreduce
42
+
43
+ ## About
44
+
45
+ Common data reduction tools for the ESS facility
46
+
47
+ ## Installation
48
+
49
+ ```sh
50
+ python -m pip install essreduce
51
+ ```
@@ -1,5 +1,5 @@
1
1
  ess/reduce/__init__.py,sha256=o1pWRP9YGwTukM_k-qlG6KcoXOpMb0PDVH59vod12lw,419
2
- ess/reduce/data.py,sha256=0N7iq1363tO16ntMztTNjxkQDFst-Gnp9awpgUOBVdY,4133
2
+ ess/reduce/data.py,sha256=66FYykg1do4xc_oEEeCu3pyAsyFwniUqEE3ofQIVvwI,5337
3
3
  ess/reduce/logging.py,sha256=6n8Czq4LZ3OK9ENlKsWSI1M3KvKv6_HSoUiV4__IUlU,357
4
4
  ess/reduce/parameter.py,sha256=4sCfoKOI2HuO_Q7JLH_jAXnEOFANSn5P3NdaOBzhJxc,4635
5
5
  ess/reduce/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -39,9 +39,9 @@ ess/reduce/widgets/_spinner.py,sha256=2VY4Fhfa7HMXox2O7UbofcdKsYG-AJGrsgGJB85nDX
39
39
  ess/reduce/widgets/_string_widget.py,sha256=iPAdfANyXHf-nkfhgkyH6gQDklia0LebLTmwi3m-iYQ,1482
40
40
  ess/reduce/widgets/_switchable_widget.py,sha256=fjKz99SKLhIF1BLgGVBSKKn3Lu_jYBwDYGeAjbJY3Q8,2390
41
41
  ess/reduce/widgets/_vector_widget.py,sha256=aTaBqCFHZQhrIoX6-sSqFWCPePEW8HQt5kUio8jP1t8,1203
42
- essreduce-25.7.1.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
43
- essreduce-25.7.1.dist-info/METADATA,sha256=wJNhY-mZpbNQwbSdKA1Ju0gTYSAU62tivdyuBmgG5Pc,3768
44
- essreduce-25.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
- essreduce-25.7.1.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
46
- essreduce-25.7.1.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
47
- essreduce-25.7.1.dist-info/RECORD,,
42
+ essreduce-25.9.0.dist-info/licenses/LICENSE,sha256=nVEiume4Qj6jMYfSRjHTM2jtJ4FGu0g-5Sdh7osfEYw,1553
43
+ essreduce-25.9.0.dist-info/METADATA,sha256=T-UsR4D9r5xXxCRWnc_LFgI9ogEWKK2GBkfn5MD4cP8,1936
44
+ essreduce-25.9.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
45
+ essreduce-25.9.0.dist-info/entry_points.txt,sha256=PMZOIYzCifHMTe4pK3HbhxUwxjFaZizYlLD0td4Isb0,66
46
+ essreduce-25.9.0.dist-info/top_level.txt,sha256=0JxTCgMKPLKtp14wb1-RKisQPQWX7i96innZNvHBr-s,4
47
+ essreduce-25.9.0.dist-info/RECORD,,
@@ -1,82 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: essreduce
3
- Version: 25.7.1
4
- Summary: Common data reduction tools for the ESS facility
5
- Author: Scipp contributors
6
- License: BSD 3-Clause License
7
-
8
- Copyright (c) 2024, Scipp contributors (https://github.com/scipp)
9
- All rights reserved.
10
-
11
- Redistribution and use in source and binary forms, with or without
12
- modification, are permitted provided that the following conditions are met:
13
-
14
- 1. Redistributions of source code must retain the above copyright notice, this
15
- list of conditions and the following disclaimer.
16
-
17
- 2. Redistributions in binary form must reproduce the above copyright notice,
18
- this list of conditions and the following disclaimer in the documentation
19
- and/or other materials provided with the distribution.
20
-
21
- 3. Neither the name of the copyright holder nor the names of its
22
- contributors may be used to endorse or promote products derived from
23
- this software without specific prior written permission.
24
-
25
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
26
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28
- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
29
- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
31
- SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
32
- CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
33
- OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35
-
36
- Project-URL: Bug Tracker, https://github.com/scipp/essreduce/issues
37
- Project-URL: Documentation, https://scipp.github.io/essreduce
38
- Project-URL: Source, https://github.com/scipp/essreduce
39
- Classifier: Intended Audience :: Science/Research
40
- Classifier: License :: OSI Approved :: BSD License
41
- Classifier: Natural Language :: English
42
- Classifier: Operating System :: OS Independent
43
- Classifier: Programming Language :: Python :: 3
44
- Classifier: Programming Language :: Python :: 3 :: Only
45
- Classifier: Programming Language :: Python :: 3.10
46
- Classifier: Programming Language :: Python :: 3.11
47
- Classifier: Programming Language :: Python :: 3.12
48
- Classifier: Programming Language :: Python :: 3.13
49
- Classifier: Topic :: Scientific/Engineering
50
- Classifier: Typing :: Typed
51
- Requires-Python: >=3.10
52
- Description-Content-Type: text/markdown
53
- License-File: LICENSE
54
- Requires-Dist: sciline>=25.05.1
55
- Requires-Dist: scipp>=25.01.0
56
- Requires-Dist: scippneutron>=25.02.0
57
- Requires-Dist: scippnexus>=24.11.0
58
- Provides-Extra: test
59
- Requires-Dist: ipywidgets; extra == "test"
60
- Requires-Dist: numba; extra == "test"
61
- Requires-Dist: pooch; extra == "test"
62
- Requires-Dist: pytest; extra == "test"
63
- Requires-Dist: scipy>=1.7.0; extra == "test"
64
- Requires-Dist: tof>=25.05.0; extra == "test"
65
- Dynamic: license-file
66
-
67
- [![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
68
- [![PyPI badge](http://img.shields.io/pypi/v/essreduce.svg)](https://pypi.python.org/pypi/essreduce)
69
- [![Anaconda-Server Badge](https://anaconda.org/scipp/essreduce/badges/version.svg)](https://anaconda.org/scipp/essreduce)
70
- [![License: BSD 3-Clause](https://img.shields.io/badge/License-BSD%203--Clause-blue.svg)](LICENSE)
71
-
72
- # ESSreduce
73
-
74
- ## About
75
-
76
- Common data reduction tools for the ESS facility
77
-
78
- ## Installation
79
-
80
- ```sh
81
- python -m pip install essreduce
82
- ```