Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- test_api.py .F
- test_frames.py .....F........FFFF
- =============================================================================== FAILURES ===============================================================================
- __________________________________________________________________________ test_highlevel_api __________________________________________________________________________
- def test_highlevel_api():
- from astropy.coordinates import SkyCoord
- from ..frames import HelioGraphicStonyhurst, HelioCentric
- # This method tests the high-level API as is done in Astropy.
- # SkyCoord should be SunPy-ready by the time the coordinates
- # API is in the codebase.
- sc = SkyCoord(SphericalRepresentation(lon=10*u.deg, lat=10*u.deg,
- distance=1*u.kpc),
- frame="heliographicstonyhurst",dateobs="2011/01/01T00:00:45")
- # Heliocentric coordinates are in kilometres.
- sc = SkyCoord(hlon=10*u.deg, hlat=10*u.deg, frame="heliographicstonyhurst")
- sc = SkyCoord(x=10*u.km, y=10*u.km, z=10*u.km, frame="heliocentric")
- # One can initialize using low-level objects.
- sc = SkyCoord(HelioGraphicStonyhurst(hlon=8*u.deg, hlat=10*u.deg, dateobs=
- "2011/01/01T00:00:45"))
- # An error is induced as a high-level object needs position data.
- # Frames can be initialized without this data, SkyCoord cannot.
- with pytest.raises(ValueError):
- sc = SkyCoord(frame="heliocentric")
- # The underlying frame object of the high-level object, when
- # accessed in a call to `repr`, is printed in the following
- # way - '<HelioGraphicStonyhurst Coordinate: lon=10*u.deg, lat=10*u.deg>'
- string = repr(sc.frame)
- > assert '<HelioGraphicStonyhurst Coordinate: B0=' in string
- E assert '<HelioGraphicStonyhurst Coordinate: B0=' in '<HelioGraphicStonyhurst Coordinate: dateobs=2011-01-01 00:00:45, L0=0.0 deg, B0=0.0 deg, hlon=8.0 deg, hlat=10.0 deg, rad=695508.0 km>'
- test_api.py:89: AssertionError
- ___________________________________________________________________________ test_frame_repr ____________________________________________________________________________
- def test_frame_repr():
- # Tests the repr() of a frame.
- hgc = HelioGraphicCarrington()
- > assert repr(hgc).startswith('<HelioGraphicCarrington Frame: B0=')
- E assert <built-in method startswith of str object at 0x7feb77f59490>('<HelioGraphicCarrington Frame: B0=')
- E + where <built-in method startswith of str object at 0x7feb77f59490> = '<HelioGraphicCarrington Frame: dateobs=None, L0=0.0 deg, B0=0.0 deg>'.startswith
- E + where '<HelioGraphicCarrington Frame: dateobs=None, L0=0.0 deg, B0=0.0 deg>' = repr(<HelioGraphicCarrington Frame: dateobs=None, L0=0.0 deg, B0=0.0 deg>)
- test_frames.py:152: AssertionError
- _______________________________________________________ test_wcs_numbers[input0-expected0-extras0-heliocentric] ________________________________________________________
- input = <Quantity [ 40., 32.] arcsec>, expected = <Quantity [ 28748691., 22998953.] m>, extras = {'dateobs': '2011/01/01T00:00:45', 'frame': 'helioprojective'}
- to = 'heliocentric'
- @pytest.mark.parametrize("input, expected, extras, to",
- [([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'frame': 'helioprojective'}, 'heliocentric'),
- ([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'distance': 0.5 * u.au, 'frame': 'helioprojective'},
- 'heliocentric'),
- ([28748691, 22998953, 0] * u.m, [40.0, 32.0] * u.arcsec,
- {'frame': 'heliocentric'}, 'helioprojective'),
- ([13.0, 58.0, 0] * u.m, [1.0791282e-06*u.deg, -7.0640732*u.deg,
- RSun],
- {'frame': 'heliocentric'}, 'heliographicstonyhurst')])
- def test_wcs_numbers(input, expected, extras, to):
- dateobs = '2011/01/01T00:00:45'
- extras['dateobs'] = dateobs
- rtol = 1e-10
- sc = SkyCoord(*input, **extras)
- sc_trans = sc.transform_to(to)
- if sc_trans.representation is SphericalWrap180Representation:
- npt.assert_allclose(sc_trans.spherical.lon, expected[0].to(u.deg))
- npt.assert_allclose(sc_trans.spherical.lat, expected[1].to(u.deg))
- if expected[2] is not None:
- npt.assert_allclose(sc_trans.spherical.distance, expected[2].to(u.km))
- elif sc_trans.representation is CartesianRepresentation:
- > npt.assert_allclose(sc_trans.cartesian.x, expected[0].to(u.km))
- test_frames.py:342:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:1297: in assert_allclose
- verbose=verbose, header=header)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- comparison = <function compare at 0x7feb777edd70>, x = <Quantity 28876.152176423377 km>, y = <Quantity 28748.691 km>, err_msg = '', verbose = True
- header = 'Not equal to tolerance rtol=1e-07, atol=0', precision = 6
- def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
- header='', precision=6):
- from numpy.core import array, isnan, isinf, any, all, inf
- x = array(x, copy=False, subok=True)
- y = array(y, copy=False, subok=True)
- def isnumber(x):
- return x.dtype.char in '?bhilqpBHILQPefdgFDG'
- def chk_same_position(x_id, y_id, hasval='nan'):
- """Handling nan/inf: check that x and y have the nan/inf at the same
- locations."""
- try:
- assert_array_equal(x_id, y_id)
- except AssertionError:
- msg = build_err_msg([x, y],
- err_msg + '\nx and y %s location mismatch:' \
- % (hasval), verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- raise AssertionError(msg)
- try:
- cond = (x.shape==() or y.shape==()) or x.shape == y.shape
- if not cond:
- msg = build_err_msg([x, y],
- err_msg
- + '\n(shapes %s, %s mismatch)' % (x.shape,
- y.shape),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- raise AssertionError(msg)
- if isnumber(x) and isnumber(y):
- x_isnan, y_isnan = isnan(x), isnan(y)
- x_isinf, y_isinf = isinf(x), isinf(y)
- # Validate that the special values are in the same place
- if any(x_isnan) or any(y_isnan):
- chk_same_position(x_isnan, y_isnan, hasval='nan')
- if any(x_isinf) or any(y_isinf):
- # Check +inf and -inf separately, since they are different
- chk_same_position(x == +inf, y == +inf, hasval='+inf')
- chk_same_position(x == -inf, y == -inf, hasval='-inf')
- # Combine all the special values
- x_id, y_id = x_isnan, y_isnan
- x_id |= x_isinf
- y_id |= y_isinf
- # Only do the comparison if actual values are left
- if all(x_id):
- return
- if any(x_id):
- val = comparison(x[~x_id], y[~y_id])
- else:
- val = comparison(x, y)
- else:
- val = comparison(x, y)
- if isinstance(val, bool):
- cond = val
- reduced = [0]
- else:
- reduced = val.ravel()
- cond = reduced.all()
- reduced = reduced.tolist()
- if not cond:
- match = 100-100.0*reduced.count(1)/len(reduced)
- msg = build_err_msg([x, y],
- err_msg
- + '\n(mismatch %s%%)' % (match,),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- > raise AssertionError(msg)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 100.0%)
- E x: Quantity(<Quantity 28876.152176423377 km>)
- E y: Quantity(<Quantity 28748.691 km>)
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:665: AssertionError
- _______________________________________________________ test_wcs_numbers[input1-expected1-extras1-heliocentric] ________________________________________________________
- input = <Quantity [ 40., 32.] arcsec>, expected = <Quantity [ 28748691., 22998953.] m>
- extras = {'dateobs': '2011/01/01T00:00:45', 'distance': <Quantity 0.5 AU>, 'frame': 'helioprojective'}, to = 'heliocentric'
- @pytest.mark.parametrize("input, expected, extras, to",
- [([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'frame': 'helioprojective'}, 'heliocentric'),
- ([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'distance': 0.5 * u.au, 'frame': 'helioprojective'},
- 'heliocentric'),
- ([28748691, 22998953, 0] * u.m, [40.0, 32.0] * u.arcsec,
- {'frame': 'heliocentric'}, 'helioprojective'),
- ([13.0, 58.0, 0] * u.m, [1.0791282e-06*u.deg, -7.0640732*u.deg,
- RSun],
- {'frame': 'heliocentric'}, 'heliographicstonyhurst')])
- def test_wcs_numbers(input, expected, extras, to):
- dateobs = '2011/01/01T00:00:45'
- extras['dateobs'] = dateobs
- rtol = 1e-10
- sc = SkyCoord(*input, **extras)
- sc_trans = sc.transform_to(to)
- if sc_trans.representation is SphericalWrap180Representation:
- npt.assert_allclose(sc_trans.spherical.lon, expected[0].to(u.deg))
- npt.assert_allclose(sc_trans.spherical.lat, expected[1].to(u.deg))
- if expected[2] is not None:
- npt.assert_allclose(sc_trans.spherical.distance, expected[2].to(u.km))
- elif sc_trans.representation is CartesianRepresentation:
- > npt.assert_allclose(sc_trans.cartesian.x, expected[0].to(u.km))
- test_frames.py:342:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:1297: in assert_allclose
- verbose=verbose, header=header)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- comparison = <function compare at 0x7feb77f61488>, x = <Quantity 14505.418610563212 km>, y = <Quantity 28748.691 km>, err_msg = '', verbose = True
- header = 'Not equal to tolerance rtol=1e-07, atol=0', precision = 6
- def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
- header='', precision=6):
- from numpy.core import array, isnan, isinf, any, all, inf
- x = array(x, copy=False, subok=True)
- y = array(y, copy=False, subok=True)
- def isnumber(x):
- return x.dtype.char in '?bhilqpBHILQPefdgFDG'
- def chk_same_position(x_id, y_id, hasval='nan'):
- """Handling nan/inf: check that x and y have the nan/inf at the same
- locations."""
- try:
- assert_array_equal(x_id, y_id)
- except AssertionError:
- msg = build_err_msg([x, y],
- err_msg + '\nx and y %s location mismatch:' \
- % (hasval), verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- raise AssertionError(msg)
- try:
- cond = (x.shape==() or y.shape==()) or x.shape == y.shape
- if not cond:
- msg = build_err_msg([x, y],
- err_msg
- + '\n(shapes %s, %s mismatch)' % (x.shape,
- y.shape),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- raise AssertionError(msg)
- if isnumber(x) and isnumber(y):
- x_isnan, y_isnan = isnan(x), isnan(y)
- x_isinf, y_isinf = isinf(x), isinf(y)
- # Validate that the special values are in the same place
- if any(x_isnan) or any(y_isnan):
- chk_same_position(x_isnan, y_isnan, hasval='nan')
- if any(x_isinf) or any(y_isinf):
- # Check +inf and -inf separately, since they are different
- chk_same_position(x == +inf, y == +inf, hasval='+inf')
- chk_same_position(x == -inf, y == -inf, hasval='-inf')
- # Combine all the special values
- x_id, y_id = x_isnan, y_isnan
- x_id |= x_isinf
- y_id |= y_isinf
- # Only do the comparison if actual values are left
- if all(x_id):
- return
- if any(x_id):
- val = comparison(x[~x_id], y[~y_id])
- else:
- val = comparison(x, y)
- else:
- val = comparison(x, y)
- if isinstance(val, bool):
- cond = val
- reduced = [0]
- else:
- reduced = val.ravel()
- cond = reduced.all()
- reduced = reduced.tolist()
- if not cond:
- match = 100-100.0*reduced.count(1)/len(reduced)
- msg = build_err_msg([x, y],
- err_msg
- + '\n(mismatch %s%%)' % (match,),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- > raise AssertionError(msg)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 100.0%)
- E x: Quantity(<Quantity 14505.418610563212 km>)
- E y: Quantity(<Quantity 28748.691 km>)
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:665: AssertionError
- ______________________________________________________ test_wcs_numbers[input2-expected2-extras2-helioprojective] ______________________________________________________
- input = <Quantity [ 28748691., 22998953., 0.] m>, expected = <Quantity [ 40., 32.] arcsec>, extras = {'dateobs': '2011/01/01T00:00:45', 'frame': 'heliocentric'}
- to = 'helioprojective'
- @pytest.mark.parametrize("input, expected, extras, to",
- [([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'frame': 'helioprojective'}, 'heliocentric'),
- ([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'distance': 0.5 * u.au, 'frame': 'helioprojective'},
- 'heliocentric'),
- ([28748691, 22998953, 0] * u.m, [40.0, 32.0] * u.arcsec,
- {'frame': 'heliocentric'}, 'helioprojective'),
- ([13.0, 58.0, 0] * u.m, [1.0791282e-06*u.deg, -7.0640732*u.deg,
- RSun],
- {'frame': 'heliocentric'}, 'heliographicstonyhurst')])
- def test_wcs_numbers(input, expected, extras, to):
- dateobs = '2011/01/01T00:00:45'
- extras['dateobs'] = dateobs
- rtol = 1e-10
- sc = SkyCoord(*input, **extras)
- sc_trans = sc.transform_to(to)
- if sc_trans.representation is SphericalWrap180Representation:
- > npt.assert_allclose(sc_trans.spherical.lon, expected[0].to(u.deg))
- test_frames.py:337:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:1297: in assert_allclose
- verbose=verbose, header=header)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- comparison = <function compare at 0x7feb777ed2a8>, x = <Longitude 0.01101070912868738 deg>, y = <Quantity 0.011111111111111112 deg>, err_msg = '', verbose = True
- header = 'Not equal to tolerance rtol=1e-07, atol=0', precision = 6
- def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
- header='', precision=6):
- from numpy.core import array, isnan, isinf, any, all, inf
- x = array(x, copy=False, subok=True)
- y = array(y, copy=False, subok=True)
- def isnumber(x):
- return x.dtype.char in '?bhilqpBHILQPefdgFDG'
- def chk_same_position(x_id, y_id, hasval='nan'):
- """Handling nan/inf: check that x and y have the nan/inf at the same
- locations."""
- try:
- assert_array_equal(x_id, y_id)
- except AssertionError:
- msg = build_err_msg([x, y],
- err_msg + '\nx and y %s location mismatch:' \
- % (hasval), verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- raise AssertionError(msg)
- try:
- cond = (x.shape==() or y.shape==()) or x.shape == y.shape
- if not cond:
- msg = build_err_msg([x, y],
- err_msg
- + '\n(shapes %s, %s mismatch)' % (x.shape,
- y.shape),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- raise AssertionError(msg)
- if isnumber(x) and isnumber(y):
- x_isnan, y_isnan = isnan(x), isnan(y)
- x_isinf, y_isinf = isinf(x), isinf(y)
- # Validate that the special values are in the same place
- if any(x_isnan) or any(y_isnan):
- chk_same_position(x_isnan, y_isnan, hasval='nan')
- if any(x_isinf) or any(y_isinf):
- # Check +inf and -inf separately, since they are different
- chk_same_position(x == +inf, y == +inf, hasval='+inf')
- chk_same_position(x == -inf, y == -inf, hasval='-inf')
- # Combine all the special values
- x_id, y_id = x_isnan, y_isnan
- x_id |= x_isinf
- y_id |= y_isinf
- # Only do the comparison if actual values are left
- if all(x_id):
- return
- if any(x_id):
- val = comparison(x[~x_id], y[~y_id])
- else:
- val = comparison(x, y)
- else:
- val = comparison(x, y)
- if isinstance(val, bool):
- cond = val
- reduced = [0]
- else:
- reduced = val.ravel()
- cond = reduced.all()
- reduced = reduced.tolist()
- if not cond:
- match = 100-100.0*reduced.count(1)/len(reduced)
- msg = build_err_msg([x, y],
- err_msg
- + '\n(mismatch %s%%)' % (match,),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- > raise AssertionError(msg)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 100.0%)
- E x: Longitude(<Longitude 0.01101070912868738 deg>)
- E y: Quantity(<Quantity 0.011111111111111112 deg>)
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:665: AssertionError
- __________________________________________________ test_wcs_numbers[input3-expected3-extras3-heliographicstonyhurst] ___________________________________________________
- input = <Quantity [ 13., 58., 0.] m>, expected = [<Quantity 1.0791282e-06 deg>, <Quantity -7.0640732 deg>, <Quantity 695508.0 km>]
- extras = {'dateobs': '2011/01/01T00:00:45', 'frame': 'heliocentric'}, to = 'heliographicstonyhurst'
- @pytest.mark.parametrize("input, expected, extras, to",
- [([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'frame': 'helioprojective'}, 'heliocentric'),
- ([40.0, 32.0] * u.arcsec, [28748691, 22998953] * u.m,
- {'distance': 0.5 * u.au, 'frame': 'helioprojective'},
- 'heliocentric'),
- ([28748691, 22998953, 0] * u.m, [40.0, 32.0] * u.arcsec,
- {'frame': 'heliocentric'}, 'helioprojective'),
- ([13.0, 58.0, 0] * u.m, [1.0791282e-06*u.deg, -7.0640732*u.deg,
- RSun],
- {'frame': 'heliocentric'}, 'heliographicstonyhurst')])
- def test_wcs_numbers(input, expected, extras, to):
- dateobs = '2011/01/01T00:00:45'
- extras['dateobs'] = dateobs
- rtol = 1e-10
- sc = SkyCoord(*input, **extras)
- sc_trans = sc.transform_to(to)
- if sc_trans.representation is SphericalWrap180Representation:
- > npt.assert_allclose(sc_trans.spherical.lon, expected[0].to(u.deg))
- test_frames.py:337:
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:1297: in assert_allclose
- verbose=verbose, header=header)
- _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
- comparison = <function compare at 0x7feb77d64230>, x = <Longitude 90.0 deg>, y = <Quantity 1.0791282e-06 deg>, err_msg = '', verbose = True
- header = 'Not equal to tolerance rtol=1e-07, atol=0', precision = 6
- def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
- header='', precision=6):
- from numpy.core import array, isnan, isinf, any, all, inf
- x = array(x, copy=False, subok=True)
- y = array(y, copy=False, subok=True)
- def isnumber(x):
- return x.dtype.char in '?bhilqpBHILQPefdgFDG'
- def chk_same_position(x_id, y_id, hasval='nan'):
- """Handling nan/inf: check that x and y have the nan/inf at the same
- locations."""
- try:
- assert_array_equal(x_id, y_id)
- except AssertionError:
- msg = build_err_msg([x, y],
- err_msg + '\nx and y %s location mismatch:' \
- % (hasval), verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- raise AssertionError(msg)
- try:
- cond = (x.shape==() or y.shape==()) or x.shape == y.shape
- if not cond:
- msg = build_err_msg([x, y],
- err_msg
- + '\n(shapes %s, %s mismatch)' % (x.shape,
- y.shape),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- raise AssertionError(msg)
- if isnumber(x) and isnumber(y):
- x_isnan, y_isnan = isnan(x), isnan(y)
- x_isinf, y_isinf = isinf(x), isinf(y)
- # Validate that the special values are in the same place
- if any(x_isnan) or any(y_isnan):
- chk_same_position(x_isnan, y_isnan, hasval='nan')
- if any(x_isinf) or any(y_isinf):
- # Check +inf and -inf separately, since they are different
- chk_same_position(x == +inf, y == +inf, hasval='+inf')
- chk_same_position(x == -inf, y == -inf, hasval='-inf')
- # Combine all the special values
- x_id, y_id = x_isnan, y_isnan
- x_id |= x_isinf
- y_id |= y_isinf
- # Only do the comparison if actual values are left
- if all(x_id):
- return
- if any(x_id):
- val = comparison(x[~x_id], y[~y_id])
- else:
- val = comparison(x, y)
- else:
- val = comparison(x, y)
- if isinstance(val, bool):
- cond = val
- reduced = [0]
- else:
- reduced = val.ravel()
- cond = reduced.all()
- reduced = reduced.tolist()
- if not cond:
- match = 100-100.0*reduced.count(1)/len(reduced)
- msg = build_err_msg([x, y],
- err_msg
- + '\n(mismatch %s%%)' % (match,),
- verbose=verbose, header=header,
- names=('x', 'y'), precision=precision)
- if not cond :
- > raise AssertionError(msg)
- E AssertionError:
- E Not equal to tolerance rtol=1e-07, atol=0
- E
- E (mismatch 100.0%)
- E x: Longitude(<Longitude 90.0 deg>)
- E y: Quantity(<Quantity 1.0791282e-06 deg>)
- /home/pritishc/.virtualenvs/sunpy/local/lib/python2.7/site-packages/numpy/testing/utils.py:665: AssertionError
- ================================================================= 6 failed, 14 passed in 7.52 seconds ==================================================================
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement