MCPcopy Create free account
hub / github.com/numpy/numpy / Vec

Class Vec

numpy/core/tests/test_multiarray.py:6597–6619  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6595
6596 def test_vecobject(self):
6597 class Vec:
6598 def __init__(self, sequence=None):
6599 if sequence is None:
6600 sequence = []
6601 self.array = np.array(sequence)
6602
6603 def __add__(self, other):
6604 out = Vec()
6605 out.array = self.array + other.array
6606 return out
6607
6608 def __sub__(self, other):
6609 out = Vec()
6610 out.array = self.array - other.array
6611 return out
6612
6613 def __mul__(self, other): # with scalar
6614 out = Vec(self.array.copy())
6615 out.array *= other
6616 return out
6617
6618 def __rmul__(self, other):
6619 return self*other
6620
6621 U_non_cont = np.transpose([[1., 1.], [1., 2.]])
6622 U_cont = np.ascontiguousarray(U_non_cont)

Callers 4

__add__Method · 0.85
__sub__Method · 0.85
__mul__Method · 0.85
test_vecobjectMethod · 0.85

Calls

no outgoing calls

Tested by 4

__add__Method · 0.68
__sub__Method · 0.68
__mul__Method · 0.68
test_vecobjectMethod · 0.68