unitfield 0.1.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.
unitfield/__init__.py ADDED
@@ -0,0 +1,21 @@
1
+ from .core import *
2
+
3
+ Unit2DEndo = Unit2DMappedEndomorphism
4
+ UnitEndo2D = Unit2DMappedEndomorphism
5
+ U2DE = Unit2DMappedEndomorphism
6
+ UEndo2D = Unit2DMappedEndomorphism
7
+ UNDField = UnitNdimField
8
+ MUnitField = MappedUnitField
9
+
10
+
11
+ __version__ = "1.0.0"
12
+ __all__ = [
13
+ 'InterpMethod',
14
+ 'UnitArray',
15
+ 'UnitSpaceVector',
16
+ 'UnitNdimField',
17
+ 'MappedUnitField',
18
+ 'UnitMappedEndomorphism',
19
+ 'Unit2DMappedEndomorphism',
20
+ 'remap_tensor_cv2'
21
+ ]
@@ -0,0 +1,23 @@
1
+ """Unit field transformation module for coordinate mappings."""
2
+
3
+ from .enums import InterpMethod
4
+ from .types import UnitArray, UnitSpaceVector
5
+ from .unitfield import (
6
+ UnitNdimField,
7
+ MappedUnitField,
8
+ UnitMappedEndomorphism,
9
+ Unit2DMappedEndomorphism,
10
+ remap_tensor_cv2
11
+ )
12
+
13
+ __version__ = "1.0.0"
14
+ __all__ = [
15
+ 'InterpMethod',
16
+ 'UnitArray',
17
+ 'UnitSpaceVector',
18
+ 'UnitNdimField',
19
+ 'MappedUnitField',
20
+ 'UnitMappedEndomorphism',
21
+ 'Unit2DMappedEndomorphism',
22
+ 'remap_tensor_cv2'
23
+ ]
@@ -0,0 +1,43 @@
1
+ #UnitFied\unitfield\core\enums.py
2
+ """
3
+ Interpolation method enumerations for unit field transformations.
4
+ """
5
+
6
+ from enum import Enum, unique
7
+ from typing import Dict, Set
8
+
9
+
10
+
11
+ class InterpMethod(Enum):
12
+ """Interpolation methods for unit field sampling."""
13
+
14
+ NEAREST_MANHATTAN = "nearest"
15
+ LINEAR = "linear"
16
+ NEAREST_EUCLIDEAN = "euclidean"
17
+ LANCZOS4 = "lanczos4"
18
+ CUBIC = "cubic"
19
+
20
+ # Backward compatibility alias
21
+ EUCLIDEAN = "euclidean"
22
+
23
+ @classmethod
24
+ def get_cv2_methods(cls) -> Set['InterpMethod']:
25
+ """Get interpolation methods supported by OpenCV backend."""
26
+ return {
27
+ cls.NEAREST_MANHATTAN,
28
+ cls.LINEAR,
29
+ cls.NEAREST_EUCLIDEAN,
30
+ cls.CUBIC,
31
+ cls.LANCZOS4
32
+ }
33
+
34
+ @classmethod
35
+ def get_numpy_methods(cls) -> Dict['InterpMethod', str]:
36
+ """Get mapping of interpolation methods to numpy backend names."""
37
+ return {
38
+ cls.NEAREST_MANHATTAN: "nearest_manhattan",
39
+ cls.LINEAR: "linear",
40
+ cls.NEAREST_EUCLIDEAN: "nearest_euclidean",
41
+ cls.CUBIC: "cubic",
42
+ cls.LANCZOS4: "lanczos4"
43
+ }
@@ -0,0 +1,31 @@
1
+ #UnitFied\unitfield\core\types.py
2
+ """
3
+ Type definitions for unit field transformations.
4
+ """
5
+
6
+ from typing import Annotated, Tuple, List, Union, TypeAlias, Final
7
+ from typing_extensions import TypeAlias as TypeAliasExt
8
+ import numpy as np
9
+ from numpy.typing import NDArray
10
+ from boundednumbers import UnitFloat
11
+
12
+
13
+ # Unit array type (values in [0, 1])
14
+ UnitArray: TypeAlias = Annotated[NDArray[np.floating], "values in [0, 1]"]
15
+
16
+ # Unit space vector types
17
+ UnitSpaceVector: TypeAlias = Union[
18
+ UnitArray,
19
+ Tuple[UnitFloat, ...],
20
+ List[UnitFloat],
21
+ ]
22
+
23
+ # Type aliases for clarity
24
+ Coordinate: TypeAlias = Tuple[UnitFloat, ...]
25
+ PixelCoordinate: TypeAlias = Tuple[float, ...]
26
+ ImageShape: TypeAlias = Tuple[int, int]
27
+
28
+ # Constants
29
+ MAX_CACHE_SIZE: Final[int] = 1024
30
+ DEFAULT_CACHE_SIZE: Final[int] = 128
31
+ DEFAULT_DTYPE: Final[type] = np.float32