dkist-processing-math 2.2.1__tar.gz → 2.2.3__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 (41) hide show
  1. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/.readthedocs.yml +2 -2
  2. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/CHANGELOG.rst +19 -0
  3. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/PKG-INFO +4 -4
  4. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/bitbucket-pipelines.yml +1 -1
  5. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/arithmetic.py +19 -0
  6. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/test_arithmetic.py +54 -1
  7. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math.egg-info/PKG-INFO +4 -4
  8. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math.egg-info/requires.txt +1 -1
  9. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/pyproject.toml +3 -3
  10. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/.gitignore +0 -0
  11. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/.pre-commit-config.yaml +0 -0
  12. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/.snyk +0 -0
  13. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/README.rst +0 -0
  14. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/changelog/.gitempty +0 -0
  15. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/__init__.py +0 -0
  16. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/feature.py +0 -0
  17. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/linear_algebra.py +0 -0
  18. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/statistics.py +0 -0
  19. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/__init__.py +0 -0
  20. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/conftest.py +0 -0
  21. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/test_feature.py +0 -0
  22. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/test_linear_algebra.py +0 -0
  23. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/test_statistics.py +0 -0
  24. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/tests/test_transform.py +0 -0
  25. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/transform/__init__.py +0 -0
  26. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/transform/affine.py +0 -0
  27. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/transform/binary.py +0 -0
  28. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/transform/binning.py +0 -0
  29. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math/transform/hough.py +0 -0
  30. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math.egg-info/SOURCES.txt +0 -0
  31. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math.egg-info/dependency_links.txt +0 -0
  32. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/dkist_processing_math.egg-info/top_level.txt +0 -0
  33. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/Makefile +0 -0
  34. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/changelog.rst +0 -0
  35. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/conf.py +0 -0
  36. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/index.rst +0 -0
  37. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/landing_page.rst +0 -0
  38. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/make.bat +0 -0
  39. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/docs/requirements.txt +0 -0
  40. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/licenses/LICENSE.rst +0 -0
  41. {dkist_processing_math-2.2.1 → dkist_processing_math-2.2.3}/setup.cfg +0 -0
@@ -1,8 +1,8 @@
1
1
  version: 2
2
2
  build:
3
- os: ubuntu-20.04
3
+ os: ubuntu-24.04
4
4
  tools:
5
- python: "3.11"
5
+ python: "3.13"
6
6
  apt_packages:
7
7
  - libopenjp2-7
8
8
  - graphviz
@@ -1,3 +1,22 @@
1
+ v2.2.3 (2026-06-15)
2
+ ===================
3
+
4
+ Features
5
+ --------
6
+
7
+ - Add new method to find the closest datetime in a list to a target datetime. (`#26 <https://bitbucket.org/dkistdc/dkist-processing-math/pull-requests/26>`__)
8
+
9
+
10
+ v2.2.2 (2026-04-16)
11
+ ===================
12
+
13
+ Misc
14
+ ----
15
+
16
+ - Update minimum required version of `python` and `dkist-processing-common` to address critical security vulnerabilities. (`#24 <https://bitbucket.org/dkistdc/dkist-processing-math/pull-requests/24>`__)
17
+ - Upgrade Read the Docs LTS build image to Ubuntu 24.04. (`#25 <https://bitbucket.org/dkistdc/dkist-processing-math/pull-requests/25>`__)
18
+
19
+
1
20
  v2.2.1 (2025-08-30)
2
21
  ===================
3
22
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkist-processing-math
3
- Version: 2.2.1
3
+ Version: 2.2.3
4
4
  Summary: Common math functionality used in the DKIST calibrations suite
5
5
  Author-email: NSO / AURA <dkistdc@nso.edu>
6
6
  License: BSD-3-Clause
@@ -10,10 +10,10 @@ Project-URL: Documentation, https://docs.dkist.nso.edu/projects/math
10
10
  Project-URL: Help, https://nso.atlassian.net/servicedesk/customer/portal/5
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.11
14
- Requires-Python: >=3.11
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.13
15
15
  Description-Content-Type: text/x-rst
16
- Requires-Dist: dkist-processing-common>=4.0.0
16
+ Requires-Dist: dkist-processing-common>=13.0.0
17
17
  Requires-Dist: numpy>=1.24.0
18
18
  Requires-Dist: scikit-image>=0.21.0
19
19
  Requires-Dist: scipy>=1.11.0
@@ -1,4 +1,4 @@
1
- image: python:3.11
1
+ image: python:3.13
2
2
  definitions:
3
3
  steps:
4
4
  - step: &download_execute_script
@@ -1,5 +1,6 @@
1
1
  """Arithmetic."""
2
2
 
3
+ from datetime import datetime
3
4
  from typing import Generator
4
5
  from typing import Iterable
5
6
  from typing import Union
@@ -124,3 +125,21 @@ def divide_fits_access_by_array(
124
125
  for obj in access_objs:
125
126
  obj.data = next(divide_arrays_by_array(obj.data, array_to_divide_by))
126
127
  yield obj
128
+
129
+
130
+ def closest_datetime(
131
+ target_datetime: str | datetime, datetimes: list[str | datetime] | str | datetime
132
+ ) -> str | datetime:
133
+ """Find the closest datetime to a target datetime. Return type is of the same type as the datetimes list."""
134
+ if isinstance(target_datetime, str):
135
+ target_datetime = datetime.fromisoformat(target_datetime)
136
+ if isinstance(datetimes, str) or isinstance(datetimes, datetime):
137
+ datetimes = [datetimes]
138
+ converted_datetimes = [
139
+ datetime.fromisoformat(d) if isinstance(d, str) else d for d in datetimes
140
+ ]
141
+ closest_index, _ = min(
142
+ enumerate(converted_datetimes),
143
+ key=lambda dt: abs(dt[1] - target_datetime),
144
+ )
145
+ return datetimes[closest_index]
@@ -1,3 +1,4 @@
1
+ from datetime import datetime
1
2
  from typing import Generator
2
3
 
3
4
  import numpy as np
@@ -5,6 +6,7 @@ import pytest
5
6
  from astropy.io import fits
6
7
  from dkist_processing_common.models.fits_access import FitsAccessBase
7
8
 
9
+ from dkist_processing_math.arithmetic import closest_datetime
8
10
  from dkist_processing_math.arithmetic import divide_arrays_by_array
9
11
  from dkist_processing_math.arithmetic import divide_fits_access_by_array
10
12
  from dkist_processing_math.arithmetic import subtract_array_from_arrays
@@ -18,7 +20,7 @@ def multiple_test_fits_access(request, numpy_arrays):
18
20
  for i, array in enumerate(numpy_arrays):
19
21
  hdu = fits.PrimaryHDU(data=array)
20
22
  hdu.header["TEST"] = i
21
- access_list.append(FitsAccessBase(hdu=hdu))
23
+ access_list.append(FitsAccessBase(header=hdu.header, data=array))
22
24
  if request.param == "multiple":
23
25
  return access_list
24
26
  return access_list[0]
@@ -126,3 +128,54 @@ def test_divide_arrays_by_array_wrong_shape(numpy_arrays_wrong_shape, numpy_arra
126
128
  """
127
129
  with pytest.raises(ValueError):
128
130
  list(divide_arrays_by_array(numpy_arrays_wrong_shape, numpy_array))
131
+
132
+
133
+ @pytest.mark.parametrize(
134
+ "datetimes, expected_result",
135
+ [
136
+ pytest.param(
137
+ ["2025-12-31T00:00:00", "2026-01-07T00:00:00"],
138
+ "2025-12-31T00:00:00",
139
+ id="multiple solar gain ops",
140
+ ),
141
+ pytest.param("2025-12-31T00:00:00", "2025-12-31T00:00:00", id="single solar gain op"),
142
+ ],
143
+ )
144
+ def test_closest_datetime_with_strings(datetimes, expected_result):
145
+ """
146
+ Given: a target datetime and a list of string datetimes
147
+ When: running the closest_datetime method
148
+ Then: the closest datetime from the list of datetimes is returned
149
+ """
150
+ result = closest_datetime(
151
+ target_datetime="2026-01-01T00:00:00",
152
+ datetimes=datetimes,
153
+ )
154
+ assert result == expected_result
155
+
156
+
157
+ @pytest.mark.parametrize(
158
+ "datetimes, expected_result",
159
+ [
160
+ pytest.param(
161
+ [
162
+ datetime(2025, 12, 31),
163
+ datetime(2026, 1, 7),
164
+ ],
165
+ datetime(2025, 12, 31),
166
+ id="multiple solar gain ops",
167
+ ),
168
+ pytest.param(datetime(2025, 12, 31), datetime(2025, 12, 31), id="single solar gain op"),
169
+ ],
170
+ )
171
+ def test_closest_datetime_with_datetimes(datetimes, expected_result):
172
+ """
173
+ Given: a target datetime and a list of datetimes
174
+ When: running the closest_datetime method
175
+ Then: the closest datetime from the list of datetimes is returned
176
+ """
177
+ result = closest_datetime(
178
+ target_datetime=datetime(2026, 1, 1),
179
+ datetimes=datetimes,
180
+ )
181
+ assert result == expected_result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dkist-processing-math
3
- Version: 2.2.1
3
+ Version: 2.2.3
4
4
  Summary: Common math functionality used in the DKIST calibrations suite
5
5
  Author-email: NSO / AURA <dkistdc@nso.edu>
6
6
  License: BSD-3-Clause
@@ -10,10 +10,10 @@ Project-URL: Documentation, https://docs.dkist.nso.edu/projects/math
10
10
  Project-URL: Help, https://nso.atlassian.net/servicedesk/customer/portal/5
11
11
  Classifier: Programming Language :: Python
12
12
  Classifier: Programming Language :: Python :: 3
13
- Classifier: Programming Language :: Python :: 3.11
14
- Requires-Python: >=3.11
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Python: >=3.13
15
15
  Description-Content-Type: text/x-rst
16
- Requires-Dist: dkist-processing-common>=4.0.0
16
+ Requires-Dist: dkist-processing-common>=13.0.0
17
17
  Requires-Dist: numpy>=1.24.0
18
18
  Requires-Dist: scikit-image>=0.21.0
19
19
  Requires-Dist: scipy>=1.11.0
@@ -1,4 +1,4 @@
1
- dkist-processing-common>=4.0.0
1
+ dkist-processing-common>=13.0.0
2
2
  numpy>=1.24.0
3
3
  scikit-image>=0.21.0
4
4
  scipy>=1.11.0
@@ -10,7 +10,7 @@ find = {}
10
10
  [project]
11
11
  dynamic = ["version"]
12
12
  name = "dkist-processing-math"
13
- requires-python = ">=3.11"
13
+ requires-python = ">=3.13"
14
14
  description = "Common math functionality used in the DKIST calibrations suite"
15
15
  readme = "README.rst"
16
16
  authors = [ {name = "NSO / AURA", email = "dkistdc@nso.edu"} ]
@@ -18,10 +18,10 @@ license = {text = "BSD-3-Clause"}
18
18
  classifiers = [
19
19
  "Programming Language :: Python",
20
20
  "Programming Language :: Python :: 3",
21
- "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.13",
22
22
  ]
23
23
  dependencies = [
24
- "dkist-processing-common >= 4.0.0",
24
+ "dkist-processing-common >= 13.0.0",
25
25
  "numpy >= 1.24.0",
26
26
  "scikit-image >= 0.21.0",
27
27
  "scipy >= 1.11.0",