Closed fzimmermann89 closed 3 weeks ago
Coverage Report
Tests | Skipped | Failures | Errors | Time |
---|---|---|---|---|
1916 | 0 :zzz: | 0 :x: | 0 :fire: | 1m 37s :stopwatch: |
I also moved Rotation out of utils (as it depended on SpatialDimension) and TYPE_CHECKING guarded modify_acq_info to avoid circular imports. Functions in utils should not depend on data classes (otherwise, we can't use them in data classes) As modify_acq_info will be deprecated anyways once we move that functionality into acqinfo, I only added the future annotations and guard.
These changes might be moved to a separate (stacked) PR .
I removed xyz to force us to always be zyx or be explicit about it and write (spatialdim.x,spatialdim.y,spatialdim.z). Otherwise, the temptation to wrongly use xyz is high..
This passes all tests from #416 and passes mypy
(To be merged after #418 into main)
:file_folder: Download as zip :mag: View online
i cleaned the type hints a bit.
also, I removed the conversion option from the class methods. Instead, there is now an apply_ that is used after creation to do the conversion. This will anyways be required for rearranging etc..
Also, I added typing asserts as tests. This is in the same test_spatialdimension.py file, even though the tests is not actually run by pytest -- just parsed by mypy.
maybe @schuenke can have another look ...
Why do we want to support np.ndarray
for SpatialDimension? It would be nice if that would be supported in the init and maybe from_-functions but it could then be converted to tensors.
Why do we want to support
np.ndarray
for SpatialDimension? It would be nice if that would be supported in the init and maybe from_-functions but it could then be converted to tensors.
from_array* will convert to tensors. I mostly added nd.array type hints to see if the hints are correct or if errors are just hidden by the fact that there is only one vector type supported. The biggest uses I see is for compatibility and object arrays (example: array of callables). I would leave it in as long as it doesn't cause issues.
I would leave it in as long as it doesn't cause issues.
It seems strange to me why we would support ndarrays here when everywhere else we ensure torch.tensors. I would go the other way and remove it unless we really need it. Otherwise we should also support it for getitem/setitem
Otherwise we should also support it for getitem/setitem
I added the overloads for getitem and setitem and a test for these.
Otherwise we should also support it for getitem/setitem
I added the overloads for getitem and setitem and a test for these.
Scratch that (Was kümmert mich mein Geschwätz von gestern). I removed np.ndarray support, as I wont use a SpatialDimension of callables in the use case I had in mind anyway.
pre-commit.ci autofix
pre-commit.ci autofix
Follow up to #416 with correct type hints