Skip to content

Commit 2bb351b

Browse files
committed
Enhance ArrayLike class with length, representation, and list conversion methods; update ArrayLikeFactory to accept variable arguments and define an abstract array method
1 parent 896f657 commit 2bb351b

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/adam/core/spatial_math.py

+21-1
Original file line numberDiff line numberDiff line change
@@ -64,12 +64,21 @@ def T(self):
6464
"""
6565
pass
6666

67+
def __len__(self):
68+
return len(self.array)
69+
70+
def __repr__(self):
71+
return self.array.__repr__()
72+
73+
def as_list(self):
74+
for i in range(len(self.array)):
75+
yield self.array[i]
6776

6877
class ArrayLikeFactory(abc.ABC):
6978
"""Abstract class for a generic Array wrapper. Every method should be implemented for every data type."""
7079

7180
@abc.abstractmethod
72-
def zeros(self, x: npt.ArrayLike) -> npt.ArrayLike:
81+
def zeros(self, *x: npt.ArrayLike) -> npt.ArrayLike:
7382
"""
7483
Args:
7584
x (npt.ArrayLike): matrix dimension
@@ -90,6 +99,17 @@ def eye(self, x: npt.ArrayLike) -> npt.ArrayLike:
9099
"""
91100
pass
92101

102+
@abc.abstractmethod
103+
def array(self, x: npt.ArrayLike) -> npt.ArrayLike:
104+
"""
105+
Args:
106+
x (npt.ArrayLike): array
107+
108+
Returns:
109+
npt.ArrayLike: array
110+
"""
111+
pass
112+
93113

94114
class SpatialMath:
95115
"""Class implementing the main geometric functions used for computing rigid-body algorithm

0 commit comments

Comments
 (0)