MCPcopy Index your code
hub / github.com/numpy/numpy / PhysicalQuantity

Class PhysicalQuantity

numpy/_core/tests/test_function_base.py:37–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35 return platform.machine().startswith('arm') and architecture[0] == '32bit'
36
37class PhysicalQuantity(float):
38 def __new__(cls, value):
39 return float.__new__(cls, value)
40
41 def __add__(self, x):
42 assert_(isinstance(x, PhysicalQuantity))
43 return PhysicalQuantity(float(x) + float(self))
44 __radd__ = __add__
45
46 def __sub__(self, x):
47 assert_(isinstance(x, PhysicalQuantity))
48 return PhysicalQuantity(float(self) - float(x))
49
50 def __rsub__(self, x):
51 assert_(isinstance(x, PhysicalQuantity))
52 return PhysicalQuantity(float(x) - float(self))
53
54 def __mul__(self, x):
55 return PhysicalQuantity(float(x) * float(self))
56 __rmul__ = __mul__
57
58 def __truediv__(self, x):
59 return PhysicalQuantity(float(self) / float(x))
60
61 def __rtruediv__(self, x):
62 return PhysicalQuantity(float(x) / float(self))
63
64
65class PhysicalQuantity2(ndarray):

Callers 9

__add__Method · 0.85
__sub__Method · 0.85
__rsub__Method · 0.85
__mul__Method · 0.85
__truediv__Method · 0.85
__rtruediv__Method · 0.85

Calls

no outgoing calls

Tested by 9

__add__Method · 0.68
__sub__Method · 0.68
__rsub__Method · 0.68
__mul__Method · 0.68
__truediv__Method · 0.68
__rtruediv__Method · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…