________________________ TestComparisonUfuncs.test_sign ________________________
self = <astropy.units.tests.test_quantity_ufuncs.TestComparisonUfuncs object at 0x7ff185a05370>
def test_sign(self):
q = [1., np.inf, -np.inf, np.nan, -1., 0.] * u.m
# Ignore "invalid value encountered in sign" warning on Windows.
if sys.platform.startswith('win'):
ctx = np.errstate(invalid='ignore')
else:
ctx = nullcontext()
with ctx:
> out = np.sign(q)
astropy/units/tests/test_quantity_ufuncs.py:723:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <Quantity [ 1., inf, -inf, nan, -1., 0.] m>
function = <ufunc 'sign'>, method = '__call__'
inputs = (<Quantity [ 1., inf, -inf, nan, -1., 0.] m>,), kwargs = {}
converters = [None], unit = None, out = None
arrays = [array([ 1., inf, -inf, nan, -1., 0.])]
input_ = array([ 1., inf, -inf, nan, -1., 0.]), converter = None
def __array_ufunc__(self, function, method, *inputs, **kwargs):
"""[…]"""
# […]
converters, unit = converters_and_unit(function, method, *inputs)
out = kwargs.get('out', None)
# Avoid loop back by turning any Quantity output into array views.
if out is not None:
# If pre-allocated output is used, check it is suitable.
# This also returns array view, to ensure we don't loop back.
if function.nout == 1:
out = out[0]
out_array = check_output(out, unit, inputs, function=function)
# Ensure output argument remains a tuple.
kwargs['out'] = (out_array,) if function.nout == 1 else out_array
# Same for inputs, but here also convert if necessary.
arrays = []
for input_, converter in zip(inputs, converters):
input_ = getattr(input_, 'value', input_)
arrays.append(converter(input_) if converter else input_)
# Call our superclass's __array_ufunc__
> result = super().__array_ufunc__(function, method, *arrays, **kwargs)
E RuntimeWarning: invalid value encountered in sign
astropy/units/quantity.py:481: RuntimeWarning
_____________________ TestInplaceUfuncs.test_sign_inplace ______________________
self = <astropy.units.tests.test_quantity_ufuncs.TestInplaceUfuncs object at 0x7ff16f2d3f70>
def test_sign_inplace(self):
q = [1., np.inf, -np.inf, np.nan, -1., 0.] * u.m
check = np.empty(q.shape, q.dtype)
# Ignore "invalid value encountered in sign" warning on Windows.
if sys.platform.startswith('win'):
ctx = np.errstate(invalid='ignore')
else:
ctx = nullcontext()
with ctx:
> np.sign(q.value, out=check)
E RuntimeWarning: invalid value encountered in sign
astropy/units/tests/test_quantity_ufuncs.py:931: RuntimeWarning
___________________________ test_footprint_contains ____________________________
def test_footprint_contains():
"""[…]"""
header = """[…]""" # noqa
header = fits.Header.fromstring(header.strip(), '\n')
test_wcs = wcs.WCS(header)
hasCoord = test_wcs.footprint_contains(SkyCoord(254, 2, unit='deg'))
assert hasCoord
hasCoord = test_wcs.footprint_contains(SkyCoord(240, 2, unit='deg'))
assert not hasCoord
# Ignore "invalid value encountered in less" warning on Windows.
if sys.platform.startswith('win'):
ctx = np.errstate(invalid='ignore')
else:
ctx = nullcontext()
with ctx:
> hasCoord = test_wcs.footprint_contains(SkyCoord(24, 2, unit='deg'))
astropy/wcs/tests/test_wcs.py:1227:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
astropy/wcs/wcs.py:3111: in footprint_contains
return coord.contained_by(self, **kwargs)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
(24., 2.)>
wcs = WCS Keywords
Number of WCS axes: 2
CTYPE : 'RA---TAN' 'DEC--TAN'
CRVAL : 250.34971683647 2.2808772582495
CRPIX ...0786 -0.001042120133257
PC2_1 PC2_2 : 0.001181477028705 -0.005590809742987
CDELT : 1.0 1.0
NAXIS : 2136 2078
image = None, kwargs = {}, ymax = 2078, xmax = 2136
warnings = <module 'warnings' from '/usr/lib/python3.8/warnings.py'>
x = array(nan), y = array(nan)
def contained_by(self, wcs, image=None, **kwargs):
"""[…]"""
if image is not None:
ymax, xmax = image.shape
else:
xmax, ymax = wcs._naxis
import warnings
with warnings.catch_warnings():
# Suppress warnings since they just mean we didn't find the coordinate
warnings.simplefilter("ignore")
try:
x, y = self.to_pixel(wcs, **kwargs)
except Exception:
return False
> return (x < xmax) & (x > 0) & (y < ymax) & (y > 0)
E RuntimeWarning: invalid value encountered in less
Python 3.8.0, Numpy 1.17.4.
#9724 allowed me to re-enable the warnings-as-error behavior, which gives some additional RuntimeWarnings converted to errors (aside from DeprecationWarnings):
Similar:
and another "invalid value" RuntimeWarning:
Python 3.8.0, Numpy 1.17.4.