@@ -15,7 +15,7 @@ class Quantity(numpy.ndarray):
1515 # TODO: what is an appropriate value?
1616 __array_priority__ = 21
1717
18- def __new__ (cls , magnitude , dtype = 'd' , units = {} , mutable = True ):
18+ def __new__ (cls , magnitude , units = {}, dtype = 'd' , mutable = True ):
1919 if not isinstance (magnitude , numpy .ndarray ):
2020 magnitude = numpy .array (magnitude , dtype = dtype )
2121 if not magnitude .flags .contiguous :
@@ -30,7 +30,7 @@ def __new__(cls, magnitude, dtype='d', units={}, mutable=True):
3030 ret .flags .writeable = mutable
3131 return ret
3232
33- def __init__ (self , data , dtype = 'd' , units = {} , mutable = True ):
33+ def __init__ (self , data , units = {}, dtype = 'd' , mutable = True ):
3434 if isinstance (units , str ):
3535 units = unit_registry [units ].dimensionality
3636 if isinstance (units , Quantity ):
@@ -75,14 +75,14 @@ def __add__(self, other):
7575 assert isinstance (other , Quantity )
7676 dims = self .dimensionality + other .dimensionality
7777 magnitude = self .magnitude + other .magnitude
78- return Quantity (magnitude , magnitude .dtype , dims )
78+ return Quantity (magnitude , dims , magnitude .dtype )
7979
8080 def __sub__ (self , other ):
8181 if self .dimensionality :
8282 assert isinstance (other , Quantity )
8383 dims = self .dimensionality - other .dimensionality
8484 magnitude = self .magnitude - other .magnitude
85- return Quantity (magnitude , magnitude .dtype , dims )
85+ return Quantity (magnitude , dims , magnitude .dtype )
8686
8787 def __mul__ (self , other ):
8888 assert isinstance (other , (numpy .ndarray , int , float ))
@@ -92,7 +92,7 @@ def __mul__(self, other):
9292 except :
9393 dims = copy .copy (self .dimensionality )
9494 magnitude = self .magnitude * other
95- return Quantity (magnitude , magnitude .dtype , dims )
95+ return Quantity (magnitude , dims , magnitude .dtype )
9696
9797 def __truediv__ (self , other ):
9898 assert isinstance (other , (numpy .ndarray , int , float ))
@@ -102,7 +102,7 @@ def __truediv__(self, other):
102102 except :
103103 dims = copy .copy (self .dimensionality )
104104 magnitude = self .magnitude / other
105- return Quantity (magnitude , magnitude .dtype , dims )
105+ return Quantity (magnitude , dims , magnitude .dtype )
106106
107107 __div__ = __truediv__
108108
@@ -119,7 +119,7 @@ def __pow__(self, other):
119119 assert isinstance (other , (numpy .ndarray , int , float ))
120120 dims = self .dimensionality ** other
121121 magnitude = self .magnitude ** other
122- return Quantity (magnitude , magnitude .dtype , dims )
122+ return Quantity (magnitude , dims , magnitude .dtype )
123123
124124 def __repr__ (self ):
125125 return '%s*%s' % (numpy .ndarray .__str__ (self ), self .units )
0 commit comments