astropy/astropy — pull request #1750 by astrofrog (2013-11-05 16:44:42+00:00)
Title: TestComparisonUfuncs.test_comparison_valid_units failing with Numpy 1.8.0 and Numpy dev

I don't quite understand this failure, but here goes:

```
=================================== FAILURES ===================================
___________ TestComparisonUfuncs.test_comparison_valid_units[ufunc0] ___________

self =
ufunc =

@pytest.mark.parametrize(('ufunc'), [np.greater, np.greater_equal,
np.less, np.less_equal,
np.not_equal, np.equal])
def test_comparison_valid_units(self, ufunc):
q_i1 = np.array([-3.3, 2.1, 10.2]) * u.kg / u.s
q_i2 = np.array([10., -5., 1.e6]) * u.g / u.Ms
q_o = ufunc(q_i1, q_i2)
assert not isinstance(q_o, u.Quantity)
assert q_o.dtype == np.bool
assert np.all(q_o == ufunc(q_i1.value, q_i2.to(q_i1.unit).value))
q_o2 = ufunc(q_i1 / q_i2, 2.)
assert not isinstance(q_o2, u.Quantity)
assert q_o2.dtype == np.bool
assert np.all(q_o2 == ufunc((q_i1 / q_i2).to(1).value, 2.))
# comparison with 0., inf, nan is OK even for dimensional quantities
for arbitrary_unit_value in (0., np.inf, np.nan):
> ufunc(q_i1, arbitrary_unit_value)

astropy/units/tests/test_quantity_ufuncs.py:487:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in greater',), , '/private/var/folders/tx/7205v3_143n82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in greater',), , '/private/var/folders/tx/7205v3_143n82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
!!! Recursion detected (same locals & position)
___________ TestComparisonUfuncs.test_comparison_valid_units[ufunc1] ___________

self =
ufunc =

@pytest.mark.parametrize(('ufunc'), [np.greater, np.greater_equal,
np.less, np.less_equal,
np.not_equal, np.equal])
def test_comparison_valid_units(self, ufunc):
q_i1 = np.array([-3.3, 2.1, 10.2]) * u.kg / u.s
q_i2 = np.array([10., -5., 1.e6]) * u.g / u.Ms
q_o = ufunc(q_i1, q_i2)
assert not isinstance(q_o, u.Quantity)
assert q_o.dtype == np.bool
assert np.all(q_o == ufunc(q_i1.value, q_i2.to(q_i1.unit).value))
q_o2 = ufunc(q_i1 / q_i2, 2.)
assert not isinstance(q_o2, u.Quantity)
assert q_o2.dtype == np.bool
assert np.all(q_o2 == ufunc((q_i1 / q_i2).to(1).value, 2.))
# comparison with 0., inf, nan is OK even for dimensional quantities
for arbitrary_unit_value in (0., np.inf, np.nan):
> ufunc(q_i1, arbitrary_unit_value)

astropy/units/tests/test_quantity_ufuncs.py:487:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in greater_equal',), , '/private/var/folders/tx/720...82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in greater_equal',), , '/private/var/folders/tx/720...82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
!!! Recursion detected (same locals & position)
___________ TestComparisonUfuncs.test_comparison_valid_units[ufunc2] ___________

self =
ufunc =

@pytest.mark.parametrize(('ufunc'), [np.greater, np.greater_equal,
np.less, np.less_equal,
np.not_equal, np.equal])
def test_comparison_valid_units(self, ufunc):
q_i1 = np.array([-3.3, 2.1, 10.2]) * u.kg / u.s
q_i2 = np.array([10., -5., 1.e6]) * u.g / u.Ms
q_o = ufunc(q_i1, q_i2)
assert not isinstance(q_o, u.Quantity)
assert q_o.dtype == np.bool
assert np.all(q_o == ufunc(q_i1.value, q_i2.to(q_i1.unit).value))
q_o2 = ufunc(q_i1 / q_i2, 2.)
assert not isinstance(q_o2, u.Quantity)
assert q_o2.dtype == np.bool
assert np.all(q_o2 == ufunc((q_i1 / q_i2).to(1).value, 2.))
# comparison with 0., inf, nan is OK even for dimensional quantities
for arbitrary_unit_value in (0., np.inf, np.nan):
> ufunc(q_i1, arbitrary_unit_value)

astropy/units/tests/test_quantity_ufuncs.py:487:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in less',), , '/private/var/folders/tx/7205v3_143n82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in less',), , '/private/var/folders/tx/7205v3_143n82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
!!! Recursion detected (same locals & position)
___________ TestComparisonUfuncs.test_comparison_valid_units[ufunc3] ___________

self =
ufunc =

@pytest.mark.parametrize(('ufunc'), [np.greater, np.greater_equal,
np.less, np.less_equal,
np.not_equal, np.equal])
def test_comparison_valid_units(self, ufunc):
q_i1 = np.array([-3.3, 2.1, 10.2]) * u.kg / u.s
q_i2 = np.array([10., -5., 1.e6]) * u.g / u.Ms
q_o = ufunc(q_i1, q_i2)
assert not isinstance(q_o, u.Quantity)
assert q_o.dtype == np.bool
assert np.all(q_o == ufunc(q_i1.value, q_i2.to(q_i1.unit).value))
q_o2 = ufunc(q_i1 / q_i2, 2.)
assert not isinstance(q_o2, u.Quantity)
assert q_o2.dtype == np.bool
assert np.all(q_o2 == ufunc((q_i1 / q_i2).to(1).value, 2.))
# comparison with 0., inf, nan is OK even for dimensional quantities
for arbitrary_unit_value in (0., np.inf, np.nan):
> ufunc(q_i1, arbitrary_unit_value)

astropy/units/tests/test_quantity_ufuncs.py:487:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in less_equal',), , '/private/var/folders/tx/7205v3...82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self =
args = (RuntimeWarning('invalid value encountered in less_equal',), , '/private/var/folders/tx/7205v3...82yw2cbsgjwzh00007c/T/astropy-test-5_t4z5/lib.macosx-10.4-x86_64-3.2/astropy/units/tests/test_quantity_ufuncs.py', 487)
kwargs = {}

def _showwarning(self, *args, **kwargs):

# Bail out if we are not catching a warning from Astropy
if not isinstance(args[0], AstropyWarning):
> return self._showwarning_orig(*args, **kwargs)

astropy/logger.py:166:
!!! Recursion detected (same locals & position)
generated xml file: /Users/Shared/Jenkins/Home/jobs/astropy-master-numpydev-osx-10.8-multiconfig/workspace/PV/3.2/junit.xml
======= 4 failed, 4687 passed, 237 skipped, 10 xfailed in 281.52 seconds =======
```

only this function is failing (4 times for different input).