Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion quantities/dimensionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ def _d_divide(q1, q2, out=None):
return q2.dimensionality**-1
p_dict[np.divide] = _d_divide
p_dict[np.true_divide] = _d_divide
p_dict[np.floor_divide] = _d_divide

def _d_check_uniform(q1, q2, out=None):
try:
Expand Down Expand Up @@ -273,7 +274,6 @@ def _d_check_uniform(q1, q2, out=None):
p_dict[np.mod] = _d_check_uniform
p_dict[np.fmod] = _d_check_uniform
p_dict[np.remainder] = _d_check_uniform
p_dict[np.floor_divide] = _d_check_uniform
p_dict[np.hypot] = _d_check_uniform
p_dict[np.equal] = _d_check_uniform
p_dict[np.not_equal] = _d_check_uniform
Expand Down
16 changes: 15 additions & 1 deletion quantities/tests/test_arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class iter_dtypes:

def __init__(self):
self._i = 1
self._typeDict = np.typeDict.copy()
self._typeDict = np.sctypeDict.copy()
self._typeDict[17] = int
self._typeDict[18] = long
self._typeDict[19] = float
Expand Down Expand Up @@ -132,6 +132,20 @@ def test_mul(self):
self.check_rmul(x, y)
dtypes.pop(0)

def test_truediv(self):
q = Quantity([44, 40, 36, 32], units=pq.ms)
self.assertQuantityEqual(
q/(4 * pq.ms),
Quantity([11, 10, 9, 8], units=pq.dimensionless)
)

def test_floordiv(self):
q = Quantity([45, 43, 39, 32], units=pq.ms)
self.assertQuantityEqual(
q//(4 * pq.ms),
Quantity([11, 10, 9, 8], units=pq.dimensionless)
)

def test_mixed_addition(self):
self.assertQuantityEqual(1*pq.ft + 1*pq.m, 4.280839895 * pq.ft)
self.assertQuantityEqual(1*pq.ft + pq.m, 4.280839895 * pq.ft)
Expand Down