Skip to content

Commit 1da66db

Browse files
committed
Make TaggedValue in basic_units a sequence
1 parent 9d12377 commit 1da66db

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

examples/units/basic_units.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,12 @@ def __getattribute__(self, name):
142142
def __array__(self, dtype=object):
143143
return np.asarray(self.value).astype(dtype)
144144

145+
def __len__(self):
146+
return len(self.value)
147+
148+
def __getitem__(self, key):
149+
return type(self)(self.value[key], self.unit)
150+
145151
def __array_wrap__(self, array, context):
146152
return TaggedValue(array, self.unit)
147153

0 commit comments

Comments
 (0)