Skip to content

Commit c83acf0

Browse files
committed
Add performant version of np.unique for ValueArray
1 parent 95e698b commit c83acf0

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

tunits/core/cython/with_unit_value_array.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ class ValueArray(WithUnit):
150150
def allclose(WithUnit self, other, *args, **kw) -> bool:
151151
return np.allclose(self.value, other[self.unit], *args, **kw)
152152

153+
def unique(WithUnit self):
154+
return np.unique(self[self.unit]) * self.unit
155+
153156
@classmethod
154157
def from_proto(cls: type[T], msg: 'tunits_pb2.ValueArray') -> T:
155158
return cls(_ndarray_from_proto(msg), _proto_to_units(msg.units))

0 commit comments

Comments
 (0)