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 .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: python
sudo: false
env:
matrix:
- NUMPY_VERSION="1.7.1"
- NUMPY_VERSION="1.8.2"
- NUMPY_VERSION="1.9.1"
python:
- 2.6
Expand Down
8 changes: 7 additions & 1 deletion quantities/dimensionality.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def string(self):
@property
def unicode(self):
return markup.format_units_unicode(self)

@property
def latex(self):
return markup.format_units_latex(self)
Expand Down Expand Up @@ -285,6 +285,12 @@ def _d_check_uniform(q1, q2, out=None):
p_dict[np.floor_divide] = _d_check_uniform
p_dict[np.arctan2] = _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
p_dict[np.less] = _d_check_uniform
p_dict[np.less_equal] = _d_check_uniform
p_dict[np.greater] = _d_check_uniform
p_dict[np.greater_equal] = _d_check_uniform

def _d_power(q1, q2, out=None):
if getattr(q2, 'dimensionality', None):
Expand Down
36 changes: 36 additions & 0 deletions quantities/tests/test_umath.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,39 @@ def test_radians(self):
def test_unwrap(self):
self.assertQuantityEqual(np.unwrap([0,3*np.pi]*pq.radians), [0,np.pi])
self.assertQuantityEqual(np.unwrap([0,540]*pq.deg), [0,180]*pq.deg)

def test_equal(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 1.0) * pq.m
self.assertTrue(np.all(np.equal(arr1, arr2)))
self.assertFalse(np.all(np.equal(arr1, arr2 * 2)))

def test_not_equal(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 1.0) * pq.m
self.assertTrue(np.all(np.not_equal(arr1, arr2*2)))
self.assertFalse(np.all(np.not_equal(arr1, arr2)))

def test_less(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 1.0) * pq.m
self.assertTrue(np.all(np.less(arr1, arr2*2)))
self.assertFalse(np.all(np.less(arr1*2, arr2)))

def test_less_equal(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 2.0) * pq.m
self.assertTrue(np.all(np.less_equal(arr1, arr2)))
self.assertFalse(np.all(np.less_equal(arr2, arr1)))

def test_greater(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 2.0) * pq.m
self.assertTrue(np.all(np.greater(arr2*1.01, arr1)))
self.assertFalse(np.all(np.greater(arr2, arr1)))

def test_greater_equal(self):
arr1 = (1, 1) * pq.m
arr2 = (1.0, 2.0) * pq.m
self.assertTrue(np.all(np.greater_equal(arr2, arr1)))
self.assertFalse(np.all(np.greater_equal(arr2*0.99, arr1)))
13 changes: 11 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
from distutils.command.sdist import sdist as _sdist
from distutils.command.build import build as _build
import os
import sys

import versioneer

TEST_RESULT = None

cmdclass = versioneer.get_cmdclass()

Expand Down Expand Up @@ -88,7 +90,8 @@ def run(self):
else:
import unittest
suite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=self.verbosity+1).run(suite)
global TEST_RESULT
TEST_RESULT = unittest.TextTestRunner(verbosity=self.verbosity+1).run(suite)

cmdclass['test'] = test

Expand Down Expand Up @@ -137,8 +140,14 @@ def run(self):
platforms = 'Any',
requires = [
'python (>=2.6.0)',
'numpy (>=1.4.0)',
'numpy (>=1.8.2)',
],
url = 'http://packages.python.org/quantities',
version = versioneer.get_version(),
)

if __name__ == '__main__':
if TEST_RESULT is not None:
if len(TEST_RESULT.errors) > 0:
# failing test -> Set non-success exit-code
sys.exit(os.EX_OK+1)