Skip to content

Commit 5ccd67c

Browse files
author
Darren Dale
committed
changed Quantity ctor kwarg order
1 parent 6e8055c commit 5ccd67c

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

quantities/constants/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
def _cd(name):
1010
entry = _pc[name]
11-
q = Quantity(entry['value'], 'd', entry['units'])
11+
q = Quantity(entry['value'], entry['units'], 'd')
1212
q.precision = entry['precision']
1313
return q
1414

quantities/quantity.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

quantities/units/unitquantity.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def __new__(cls, name, reference_quantity=None):
1414
return Quantity.__new__(
1515
cls,
1616
1.0,
17-
dtype='d',
1817
units={},
18+
dtype='d',
1919
mutable=False
2020
)
2121

2222
def __init__(self, name, reference_quantity=None):
2323
self._name = name
24-
Quantity.__init__(self, 1.0, 'd', {self:1}, mutable=False)
24+
Quantity.__init__(self, 1.0, {self:1}, 'd', mutable=False)
2525

2626
if reference_quantity is None:
2727
reference_quantity = self
@@ -106,7 +106,7 @@ class Dimensionless(UnitQuantity):
106106

107107
def __init__(self, name, reference_quantity=None):
108108
self._name = name
109-
Quantity.__init__(self, 1.0, 'd', {}, mutable=False)
109+
Quantity.__init__(self, 1.0, {}, 'd', mutable=False)
110110

111111
if reference_quantity is None:
112112
reference_quantity = self

0 commit comments

Comments
 (0)