tiamat-python 0.1.16__tar.gz → 0.1.17__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 (51) hide show
  1. {tiamat_python-0.1.16/tiamat_python.egg-info → tiamat_python-0.1.17}/PKG-INFO +26 -2
  2. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/README.md +25 -1
  3. tiamat_python-0.1.17/tests/test_pipeline.py +111 -0
  4. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/pipeline.py +40 -0
  5. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/zarr.py +5 -1
  6. {tiamat_python-0.1.16 → tiamat_python-0.1.17/tiamat_python.egg-info}/PKG-INFO +26 -2
  7. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat_python.egg-info/SOURCES.txt +1 -0
  8. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/LICENSE +0 -0
  9. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/README.rst +0 -0
  10. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/pyproject.toml +0 -0
  11. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/setup.cfg +0 -0
  12. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/setup.py +0 -0
  13. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tests/test_metadata.py +0 -0
  14. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tests/test_package.py +0 -0
  15. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/__init__.py +0 -0
  16. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/array.py +0 -0
  17. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/cache.py +0 -0
  18. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/cli.py +0 -0
  19. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/constants.py +0 -0
  20. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/errors.py +0 -0
  21. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/io.py +0 -0
  22. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/metadata/__init__.py +0 -0
  23. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/metadata/dimensions.py +0 -0
  24. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/metadata/metadata.py +0 -0
  25. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/__init__.py +0 -0
  26. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/factory.py +0 -0
  27. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/generic.py +0 -0
  28. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/memory.py +0 -0
  29. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/nifti.py +0 -0
  30. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/pipeline.py +0 -0
  31. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/processing.py +0 -0
  32. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/protocol.py +0 -0
  33. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/readers/stack.py +0 -0
  34. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/serialization.py +0 -0
  35. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/__init__.py +0 -0
  36. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/access.py +0 -0
  37. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/affine.py +0 -0
  38. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/axes.py +0 -0
  39. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/color.py +0 -0
  40. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/coordinates.py +0 -0
  41. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/dfield.py +0 -0
  42. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/intensity_mapping.py +0 -0
  43. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/mask.py +0 -0
  44. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/metadata.py +0 -0
  45. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/normalization.py +0 -0
  46. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/protocol.py +0 -0
  47. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat/transformers/view.py +0 -0
  48. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat_python.egg-info/dependency_links.txt +0 -0
  49. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat_python.egg-info/entry_points.txt +0 -0
  50. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat_python.egg-info/requires.txt +0 -0
  51. {tiamat_python-0.1.16 → tiamat_python-0.1.17}/tiamat_python.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tiamat-python
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Tiled Image Access, Manipulation, and Analysis Toolkit
5
5
  Author-email: "Big Data Analytics Group, Forschungszentrum Juelich, Institute of Neuroscience and Medicine (INM-1)" <inm1-bda@fz-juelich.de>
6
6
  License:
@@ -351,7 +351,31 @@ See the [`examples/`](./examples) directory for usage demonstrations and pipelin
351
351
 
352
352
  ### Releases
353
353
 
354
- Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags on the master branch.
354
+ Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags (`vX.Y.Z`) on the master branch.
355
+ The package version is derived from the tag (`setuptools-git-versioning`), so there is no version string to bump in the code.
356
+
357
+ Releases are made with `release.sh` in two steps:
358
+
359
+ ```bash
360
+ # 1. Prepare: branch release/vX.Y.Z off origin/develop, run tests + pre-commit,
361
+ # bump codemeta.json, push and open a merge request into master.
362
+ ./release.sh start [patch|minor|major] # default: patch
363
+
364
+ # 2. Review and merge the MR into master in GitLab (fix things on the release branch if needed).
365
+
366
+ # 3. Publish: tag origin/master with the version from codemeta.json, push the tag
367
+ # (triggers the publish:pypi CI job) and merge master back into develop.
368
+ # Asks before each push unless -y is given.
369
+ ./release.sh finish [-y]
370
+ ```
371
+
372
+ Notes:
373
+
374
+ - The next version is computed from the highest existing `vX.Y.Z` tag.
375
+ - Tags always go on master. The `publish:pypi` job refuses to publish tags that are not on master.
376
+ - `start` refuses to run if `develop` does not contain the last release tag. Run `./release.sh finish` first to merge master back into develop.
377
+ - `finish` can be re-run safely: if the tag already exists on master, it only does the back-merge.
378
+ - Requires `git`, `jq`, `pytest` and `pre-commit`. The test and lint commands and the remote can be overridden with `TEST_CMD`, `PRECOMMIT_CMD` and `REMOTE`.
355
379
 
356
380
  ---
357
381
 
@@ -113,7 +113,31 @@ See the [`examples/`](./examples) directory for usage demonstrations and pipelin
113
113
 
114
114
  ### Releases
115
115
 
116
- Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags on the master branch.
116
+ Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags (`vX.Y.Z`) on the master branch.
117
+ The package version is derived from the tag (`setuptools-git-versioning`), so there is no version string to bump in the code.
118
+
119
+ Releases are made with `release.sh` in two steps:
120
+
121
+ ```bash
122
+ # 1. Prepare: branch release/vX.Y.Z off origin/develop, run tests + pre-commit,
123
+ # bump codemeta.json, push and open a merge request into master.
124
+ ./release.sh start [patch|minor|major] # default: patch
125
+
126
+ # 2. Review and merge the MR into master in GitLab (fix things on the release branch if needed).
127
+
128
+ # 3. Publish: tag origin/master with the version from codemeta.json, push the tag
129
+ # (triggers the publish:pypi CI job) and merge master back into develop.
130
+ # Asks before each push unless -y is given.
131
+ ./release.sh finish [-y]
132
+ ```
133
+
134
+ Notes:
135
+
136
+ - The next version is computed from the highest existing `vX.Y.Z` tag.
137
+ - Tags always go on master. The `publish:pypi` job refuses to publish tags that are not on master.
138
+ - `start` refuses to run if `develop` does not contain the last release tag. Run `./release.sh finish` first to merge master back into develop.
139
+ - `finish` can be re-run safely: if the tag already exists on master, it only does the back-merge.
140
+ - Requires `git`, `jq`, `pytest` and `pre-commit`. The test and lint commands and the remote can be overridden with `TEST_CMD`, `PRECOMMIT_CMD` and `REMOTE`.
117
141
 
118
142
  ---
119
143
 
@@ -0,0 +1,111 @@
1
+ """
2
+ Tests for Pipeline.concat (and its ``+`` operator alias).
3
+ """
4
+
5
+ import pytest
6
+
7
+ from tiamat.pipeline import Pipeline
8
+ from tiamat.readers.factory import get_reader
9
+
10
+
11
+ class _DummyTransformer:
12
+ """Minimal transformer stand-in; identity is all concat cares about."""
13
+
14
+
15
+ def _custom_reader_factory(fname, **kwargs):
16
+ raise NotImplementedError("not meant to be called in concat tests")
17
+
18
+
19
+ def _other_reader_factory(fname, **kwargs):
20
+ raise NotImplementedError("not meant to be called in concat tests")
21
+
22
+
23
+ class TestConcat:
24
+ """Tests for Pipeline.concat."""
25
+
26
+ def test_transformers_are_concatenated_in_order(self):
27
+ """Resulting transformers are self's followed by other's, preserving order."""
28
+ t1, t2, t3 = _DummyTransformer(), _DummyTransformer(), _DummyTransformer()
29
+ left = Pipeline(transformers=[t1, t2])
30
+ right = Pipeline(transformers=[t3])
31
+
32
+ combined = left.concat(right)
33
+
34
+ assert combined.transformers == [t1, t2, t3]
35
+
36
+ def test_add_operator_delegates_to_concat(self):
37
+ """The ``+`` operator produces the same result as concat."""
38
+ t1, t2 = _DummyTransformer(), _DummyTransformer()
39
+ left = Pipeline(transformers=[t1])
40
+ right = Pipeline(transformers=[t2])
41
+
42
+ assert (left + right).transformers == left.concat(right).transformers
43
+
44
+ def test_concat_returns_new_pipeline_without_mutating_operands(self):
45
+ """concat does not mutate either input pipeline."""
46
+ t1, t2 = _DummyTransformer(), _DummyTransformer()
47
+ left = Pipeline(transformers=[t1])
48
+ right = Pipeline(transformers=[t2])
49
+
50
+ combined = left.concat(right)
51
+
52
+ assert combined is not left and combined is not right
53
+ assert left.transformers == [t1]
54
+ assert right.transformers == [t2]
55
+
56
+ def test_non_pipeline_raises(self):
57
+ """Concatenating with a non-Pipeline raises NotImplementedError."""
58
+ left = Pipeline()
59
+ with pytest.raises(NotImplementedError, match="cannot add pipeline"):
60
+ left.concat("not a pipeline")
61
+
62
+ def test_reader_factory_defaults_to_get_reader_when_neither_customized(self):
63
+ """When both operands use the default reader, the result does too."""
64
+ combined = Pipeline().concat(Pipeline())
65
+ assert combined.reader_factory is get_reader
66
+
67
+ def test_reader_factory_takes_self_when_only_self_customized(self):
68
+ """self's custom reader_factory is used when other uses the default."""
69
+ left = Pipeline(reader_factory=_custom_reader_factory)
70
+ combined = left.concat(Pipeline())
71
+ assert combined.reader_factory is _custom_reader_factory
72
+
73
+ def test_reader_factory_takes_other_when_only_other_customized(self):
74
+ """other's custom reader_factory is used when self uses the default."""
75
+ right = Pipeline(reader_factory=_other_reader_factory)
76
+ combined = Pipeline().concat(right)
77
+ assert combined.reader_factory is _other_reader_factory
78
+
79
+ def test_reader_factory_prefers_other_when_both_customized(self):
80
+ """other's reader_factory takes precedence when both are customized."""
81
+ left = Pipeline(reader_factory=_custom_reader_factory)
82
+ right = Pipeline(reader_factory=_other_reader_factory)
83
+ combined = left.concat(right)
84
+ assert combined.reader_factory is _other_reader_factory
85
+
86
+ @pytest.mark.parametrize(
87
+ "left_flag,right_flag,expected",
88
+ [
89
+ (False, False, False),
90
+ (True, False, True),
91
+ (False, True, True),
92
+ (True, True, True),
93
+ ],
94
+ )
95
+ def test_auto_register_is_logical_or(self, left_flag, right_flag, expected):
96
+ """auto_register_default_readers is the logical OR of both operands."""
97
+ left = Pipeline(auto_register_default_readers=left_flag)
98
+ right = Pipeline(auto_register_default_readers=right_flag)
99
+ assert left.concat(right).auto_register_default_readers is expected
100
+
101
+ def test_metadata_overrides_are_merged(self):
102
+ """Non-overlapping metadata_overrides keys from both operands are merged."""
103
+ left = Pipeline(metadata_overrides={"a": 1})
104
+ right = Pipeline(metadata_overrides={"b": 2})
105
+ assert left.concat(right).metadata_overrides == {"a": 1, "b": 2}
106
+
107
+ def test_metadata_overrides_other_takes_precedence_on_conflict(self):
108
+ """On key conflict, other's metadata_overrides value wins."""
109
+ left = Pipeline(metadata_overrides={"a": 1, "shared": "left"})
110
+ right = Pipeline(metadata_overrides={"shared": "right"})
111
+ assert left.concat(right).metadata_overrides == {"a": 1, "shared": "right"}
@@ -126,6 +126,46 @@ class Pipeline:
126
126
  metadata=metadata[-1],
127
127
  )
128
128
 
129
+ def __add__(self, other):
130
+ return self.concat(other)
131
+
132
+ def concat(self, other):
133
+ """
134
+ Concatenates this pipeline with another, returning a new combined pipeline.
135
+
136
+ The resulting pipeline applies this pipeline's transformers first, followed
137
+ by ``other``'s transformers. It is also accessible via the ``+`` operator
138
+ (``self + other``).
139
+
140
+ Args:
141
+ other (Pipeline): The pipeline to append after this one.
142
+
143
+ Returns:
144
+ Pipeline: A new pipeline whose ``transformers`` are this pipeline's
145
+ transformers followed by ``other``'s. The ``reader_factory`` is
146
+ resolved by preferring a non-default factory, with ``other``'s
147
+ taking precedence when both define one. ``auto_register_default_readers``
148
+ is the logical OR of both pipelines, and ``metadata_overrides`` is the
149
+ merge of both with ``other``'s values taking precedence on key conflicts.
150
+
151
+ Raises:
152
+ NotImplementedError: If ``other`` is not a ``Pipeline`` instance.
153
+ """
154
+ if not isinstance(other, Pipeline):
155
+ raise NotImplementedError(f"cannot add pipeline to {other.__class__}")
156
+ reader_factory = get_reader
157
+ if self.reader_factory is not get_reader:
158
+ reader_factory = self.reader_factory
159
+ if other.reader_factory is not get_reader:
160
+ reader_factory = other.reader_factory
161
+
162
+ return Pipeline(
163
+ transformers=[*self.transformers, *other.transformers],
164
+ auto_register_default_readers=(self.auto_register_default_readers or other.auto_register_default_readers),
165
+ reader_factory=reader_factory,
166
+ metadata_overrides={**self.metadata_overrides, **other.metadata_overrides},
167
+ )
168
+
129
169
  def read_metadata(self, file_name: str, **reader_kwargs: Any) -> ImageMetadata:
130
170
  """
131
171
  Reads and transforms image metadata.
@@ -222,8 +222,12 @@ class OmeZarrReader(ImageReader):
222
222
  dims = [_axis_to_dim(ax, md) for ax in self.axes_names]
223
223
  vmin, vmax = self.value_range
224
224
 
225
+ # OME-NGFF label images carry "image-label" metadata: serve them as segmentation
226
+ # (nearest-neighbour resampling, segmentation layer in Neuroglancer).
227
+ image_type = md.IMAGE_TYPE_SEGMENTATION if "image-label" in self._ome_meta else md.IMAGE_TYPE_IMAGE
228
+
225
229
  return md.ImageMetadata(
226
- image_type=md.IMAGE_TYPE_IMAGE,
230
+ image_type=image_type,
227
231
  shape=self.shape,
228
232
  dtype=self.dtype,
229
233
  file_path=self.fname,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tiamat-python
3
- Version: 0.1.16
3
+ Version: 0.1.17
4
4
  Summary: Tiled Image Access, Manipulation, and Analysis Toolkit
5
5
  Author-email: "Big Data Analytics Group, Forschungszentrum Juelich, Institute of Neuroscience and Medicine (INM-1)" <inm1-bda@fz-juelich.de>
6
6
  License:
@@ -351,7 +351,31 @@ See the [`examples/`](./examples) directory for usage demonstrations and pipelin
351
351
 
352
352
  ### Releases
353
353
 
354
- Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags on the master branch.
354
+ Releases to [pypi](https://pypi.org/project/tiamat-python/) are automatically performed on semantic versioning tags (`vX.Y.Z`) on the master branch.
355
+ The package version is derived from the tag (`setuptools-git-versioning`), so there is no version string to bump in the code.
356
+
357
+ Releases are made with `release.sh` in two steps:
358
+
359
+ ```bash
360
+ # 1. Prepare: branch release/vX.Y.Z off origin/develop, run tests + pre-commit,
361
+ # bump codemeta.json, push and open a merge request into master.
362
+ ./release.sh start [patch|minor|major] # default: patch
363
+
364
+ # 2. Review and merge the MR into master in GitLab (fix things on the release branch if needed).
365
+
366
+ # 3. Publish: tag origin/master with the version from codemeta.json, push the tag
367
+ # (triggers the publish:pypi CI job) and merge master back into develop.
368
+ # Asks before each push unless -y is given.
369
+ ./release.sh finish [-y]
370
+ ```
371
+
372
+ Notes:
373
+
374
+ - The next version is computed from the highest existing `vX.Y.Z` tag.
375
+ - Tags always go on master. The `publish:pypi` job refuses to publish tags that are not on master.
376
+ - `start` refuses to run if `develop` does not contain the last release tag. Run `./release.sh finish` first to merge master back into develop.
377
+ - `finish` can be re-run safely: if the tag already exists on master, it only does the back-merge.
378
+ - Requires `git`, `jq`, `pytest` and `pre-commit`. The test and lint commands and the remote can be overridden with `TEST_CMD`, `PRECOMMIT_CMD` and `REMOTE`.
355
379
 
356
380
  ---
357
381
 
@@ -5,6 +5,7 @@ pyproject.toml
5
5
  setup.py
6
6
  tests/test_metadata.py
7
7
  tests/test_package.py
8
+ tests/test_pipeline.py
8
9
  tiamat/__init__.py
9
10
  tiamat/array.py
10
11
  tiamat/cache.py
File without changes
File without changes
File without changes