csa-header 2.0.0__tar.gz → 2.0.1__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 (42) hide show
  1. {csa_header-2.0.0 → csa_header-2.0.1}/CHANGELOG.md +14 -0
  2. {csa_header-2.0.0 → csa_header-2.0.1}/PKG-INFO +4 -3
  3. {csa_header-2.0.0 → csa_header-2.0.1}/README.md +1 -1
  4. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/__about__.py +1 -1
  5. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/ascconv.py +26 -6
  6. {csa_header-2.0.0 → csa_header-2.0.1}/pyproject.toml +2 -1
  7. {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_ascconv_sample.py +18 -0
  8. {csa_header-2.0.0 → csa_header-2.0.1}/.gitignore +0 -0
  9. {csa_header-2.0.0 → csa_header-2.0.1}/CODE_OF_CONDUCT.md +0 -0
  10. {csa_header-2.0.0 → csa_header-2.0.1}/CONTRIBUTING.md +0 -0
  11. {csa_header-2.0.0 → csa_header-2.0.1}/LICENSE.txt +0 -0
  12. {csa_header-2.0.0 → csa_header-2.0.1}/SECURITY.md +0 -0
  13. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/__init__.py +0 -0
  14. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/__init__.py +0 -0
  15. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/header.py +0 -0
  16. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/ascii/messages.py +0 -0
  17. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/examples.py +0 -0
  18. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/exceptions.py +0 -0
  19. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/header.py +0 -0
  20. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/messages.py +0 -0
  21. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/unpacker.py +0 -0
  22. {csa_header-2.0.0 → csa_header-2.0.1}/csa_header/utils.py +0 -0
  23. {csa_header-2.0.0 → csa_header-2.0.1}/examples/README.md +0 -0
  24. {csa_header-2.0.0 → csa_header-2.0.1}/examples/basic_usage_example.py +0 -0
  25. {csa_header-2.0.0 → csa_header-2.0.1}/examples/nibabel_integration.py +0 -0
  26. {csa_header-2.0.0 → csa_header-2.0.1}/tests/__init__.py +0 -0
  27. {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/__init__.py +0 -0
  28. {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/fixtures.py +0 -0
  29. {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_ascconv_parsing.py +0 -0
  30. {csa_header-2.0.0 → csa_header-2.0.1}/tests/ascii/test_header.py +0 -0
  31. {csa_header-2.0.0 → csa_header-2.0.1}/tests/benchmarks/__init__.py +0 -0
  32. {csa_header-2.0.0 → csa_header-2.0.1}/tests/benchmarks/bench_parsing.py +0 -0
  33. {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/__init__.py +0 -0
  34. {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/ascconv_sample.txt +0 -0
  35. {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/dwi_image_header_info +0 -0
  36. {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/e11_series_header_info +0 -0
  37. {csa_header-2.0.0 → csa_header-2.0.1}/tests/files/rsfmri_series_header_info +0 -0
  38. {csa_header-2.0.0 → csa_header-2.0.1}/tests/fixtures.py +0 -0
  39. {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_documentation_examples.py +0 -0
  40. {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_examples.py +0 -0
  41. {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_header.py +0 -0
  42. {csa_header-2.0.0 → csa_header-2.0.1}/tests/test_unpacker.py +0 -0
@@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.1] - 2026-12-03
11
+
12
+ ### Fixed
13
+ - **Python 3.14 compatibility**: parsing an ASCCONV protocol (such as `MrPhoenixProtocol` in a series CSA header)
14
+ no longer fails with `AttributeError: module 'ast' has no attribute 'Num'`. Python 3.14 removed the `ast.Num` and
15
+ `ast.Str` aliases, so literal values are now read from `ast.Constant`. The fix follows Julia's
16
+ ([@juliam98](https://github.com/juliam98)) fix for the same code in dicom_parser
17
+ ([open-dicom/dicom_parser#127](https://github.com/open-dicom/dicom_parser/pull/127)).
18
+
19
+ ### Changed
20
+ - Python 3.14 is now tested in CI and listed in the package classifiers.
21
+
10
22
  ## [2.0.0] - 2025-11-01
11
23
 
12
24
  ### 🔥 Breaking Changes
@@ -221,6 +233,8 @@ Potential features for future releases:
221
233
 
222
234
  ---
223
235
 
236
+ [2.0.1]: https://github.com/open-dicom/csa_header/compare/v2.0.0...v2.0.1
237
+ [2.0.0]: https://github.com/open-dicom/csa_header/compare/v1.0.2...v2.0.0
224
238
  [1.0.1]: https://github.com/open-dicom/csa_header/compare/v1.0.0...v1.0.1
225
239
  [1.0.0]: https://github.com/open-dicom/csa_header/compare/v0.0.1...v1.0.0
226
240
  [0.0.1]: https://github.com/open-dicom/csa_header/releases/tag/v0.0.1
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: csa_header
3
- Version: 2.0.0
3
+ Version: 2.0.1
4
4
  Summary: Parse Siemens CSA header information
5
5
  Project-URL: Documentation, https://github.com/open-dicom/csa_header#readme
6
6
  Project-URL: Issues, https://github.com/open-dicom/csa_header/issues
@@ -16,6 +16,7 @@ Classifier: Programming Language :: Python :: 3.10
16
16
  Classifier: Programming Language :: Python :: 3.11
17
17
  Classifier: Programming Language :: Python :: 3.12
18
18
  Classifier: Programming Language :: Python :: 3.13
19
+ Classifier: Programming Language :: Python :: 3.14
19
20
  Classifier: Programming Language :: Python :: Implementation :: CPython
20
21
  Requires-Python: >=3.9
21
22
  Requires-Dist: numpy>=1.20.0
@@ -74,7 +75,7 @@ The _CSA Image Header Info_ and _CSA Series Header Info_ elements contain encode
74
75
  - **ASCCONV Support**: Automatic parsing of embedded ASCCONV protocol parameters
75
76
  - **Type-Safe**: Complete type hints for all public APIs
76
77
  - **Well-Tested**: 96% test coverage with 161 tests
77
- - **Python 3.9+**: Modern Python with support through Python 3.13
78
+ - **Python 3.9+**: Modern Python with support through Python 3.14
78
79
  - **NiBabel Compatible**: Integrates seamlessly with neuroimaging workflows
79
80
 
80
81
  **Table of Contents**
@@ -44,7 +44,7 @@ The _CSA Image Header Info_ and _CSA Series Header Info_ elements contain encode
44
44
  - **ASCCONV Support**: Automatic parsing of embedded ASCCONV protocol parameters
45
45
  - **Type-Safe**: Complete type hints for all public APIs
46
46
  - **Well-Tested**: 96% test coverage with 161 tests
47
- - **Python 3.9+**: Modern Python with support through Python 3.13
47
+ - **Python 3.9+**: Modern Python with support through Python 3.14
48
48
  - **NiBabel Compatible**: Integrates seamlessly with neuroimaging workflows
49
49
 
50
50
  **Table of Contents**
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2023-present Zvi Baratz <z.baratz@gmail.com>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "2.0.0"
4
+ __version__ = "2.0.1"
@@ -59,6 +59,12 @@ TERMINAL_DIGIT_PATTERN = r"^(.*)\.(\d+)(\s+=)"
59
59
  #: Regular expression to replace terminal integer identifiers.
60
60
  TERMINAL_DIGIT_RE = re.compile(TERMINAL_DIGIT_PATTERN, re.M)
61
61
 
62
+ #: Types of the literal values an ASCCONV assignment may hold.
63
+ LITERAL_VALUE_TYPES = (int, float, str)
64
+
65
+ #: Types of the literal values an ASCCONV assignment may negate.
66
+ NUMERIC_VALUE_TYPES = (int, float)
67
+
62
68
 
63
69
  class AscconvParseError(Exception):
64
70
  """
@@ -203,13 +209,27 @@ def obj_from_atoms(
203
209
 
204
210
 
205
211
  def _get_value(assign: ast.Assign) -> int | float | str:
212
+ """
213
+ Return the literal value assigned by one ASCCONV line.
214
+
215
+ Every literal parses as ``ast.Constant`` (Python 3.8+); the ``ast.Num``
216
+ and ``ast.Str`` aliases this used to check were removed in Python 3.14.
217
+
218
+ Raises
219
+ ------
220
+ AscconvParseError
221
+ The assigned value is not a number, a string or a negated number
222
+ """
206
223
  value = assign.value
207
- if isinstance(value, ast.Num):
208
- return value.n # type: ignore[return-value]
209
- if isinstance(value, ast.Str):
210
- return value.s # type: ignore[return-value]
211
- if isinstance(value, ast.UnaryOp) and isinstance(value.op, ast.USub):
212
- return -value.operand.n # type: ignore[attr-defined,no-any-return]
224
+ if isinstance(value, ast.Constant) and isinstance(value.value, LITERAL_VALUE_TYPES):
225
+ return value.value
226
+ if (
227
+ isinstance(value, ast.UnaryOp)
228
+ and isinstance(value.op, ast.USub)
229
+ and isinstance(value.operand, ast.Constant)
230
+ and isinstance(value.operand.value, NUMERIC_VALUE_TYPES)
231
+ ):
232
+ return -value.operand.value
213
233
  message = messages.UNEXPECTED_RHS.format(value=value)
214
234
  raise AscconvParseError(message)
215
235
 
@@ -12,6 +12,7 @@ classifiers = [
12
12
  "Programming Language :: Python :: 3.11",
13
13
  "Programming Language :: Python :: 3.12",
14
14
  "Programming Language :: Python :: 3.13",
15
+ "Programming Language :: Python :: 3.14",
15
16
  "Programming Language :: Python :: Implementation :: CPython",
16
17
  ]
17
18
  dependencies = ["numpy>=1.20.0", "pydicom>=2.2.0,<4.0"]
@@ -82,7 +83,7 @@ exclude = [
82
83
  ]
83
84
 
84
85
  [[tool.hatch.envs.all.matrix]]
85
- python = ["3.9", "3.10", "3.11", "3.12", "3.13"]
86
+ python = ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
86
87
 
87
88
  [tool.hatch.envs.default]
88
89
  dependencies = ["ipython", "pre-commit"]
@@ -188,3 +188,21 @@ foo.bar[0] = 1
188
188
  """
189
189
  with pytest.raises(AscconvParseError):
190
190
  out = parse_ascconv_text(val_then_list)
191
+
192
+
193
+ def test_literal_values():
194
+ in_text = """\
195
+ lCount = 3
196
+ dRatio = 0.5
197
+ lOffset = -4
198
+ dShift = -0.25
199
+ tName = ""ep2d_bold""
200
+ """
201
+ out = parse_ascconv_text(in_text, delimiter='""')
202
+ assert out == {"lCount": 3, "dRatio": 0.5, "lOffset": -4, "dShift": -0.25, "tName": "ep2d_bold"}
203
+
204
+
205
+ def test_unexpected_values():
206
+ for unexpected_value in ("[1]", "-foo", '-"text"', "None"):
207
+ with pytest.raises(AscconvParseError):
208
+ parse_ascconv_text(f"foo = {unexpected_value}\n")
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes