Exemplo n.º 1
0
def test_get_extreme_position():
    coords = SkyCoord([-1, 0, 1, np.nan]*u.arcsec, [-2, 0, 2, -np.nan]*u.arcsec, frame=frames.Helioprojective)

    assert _get_extreme_position(coords, 'Tx', operator=np.nanmin) == -1
    assert _get_extreme_position(coords, 'Ty', operator=np.nanmin) == -2

    assert _get_extreme_position(coords, 'Tx', operator=np.nanmax) == 1
    assert _get_extreme_position(coords, 'Ty', operator=np.nanmax) == 2

    with pytest.raises(ValueError):
        _get_extreme_position(coords, 'lon', operator=np.nanmax)
def test_get_extreme_position():
    coords = SkyCoord([-1, 0, 1, np.nan]*u.arcsec, [-2, 0, 2, -np.nan]*u.arcsec, frame=frames.Helioprojective)

    assert _get_extreme_position(coords, 'Tx', operator=np.nanmin) == -1
    assert _get_extreme_position(coords, 'Ty', operator=np.nanmin) == -2

    assert _get_extreme_position(coords, 'Tx', operator=np.nanmax) == 1
    assert _get_extreme_position(coords, 'Ty', operator=np.nanmax) == 2

    with pytest.raises(ValueError):
        _get_extreme_position(coords, 'lon', operator=np.nanmax)
Exemplo n.º 3
0
def test_get_extreme_position():
    coords = SkyCoord([-1, 0, 1, np.nan] * u.arcsec,
                      [-2, 0, 2, -np.nan] * u.arcsec,
                      frame=frames.Helioprojective)

    with pytest.warns(RuntimeWarning, match='All-NaN axis encountered'):
        assert _get_extreme_position(coords, 'Tx', operator=np.nanmin) == -1
        assert _get_extreme_position(coords, 'Ty', operator=np.nanmin) == -2

        assert _get_extreme_position(coords, 'Tx', operator=np.nanmax) == 1
        assert _get_extreme_position(coords, 'Ty', operator=np.nanmax) == 2

    with pytest.raises(ValueError):
        _get_extreme_position(coords, 'lon', operator=np.nanmax)
Exemplo n.º 4
0
def test_get_extreme_position():
    # Ignore some invalid NaN comparisions within astropy
    # (fixed in astropy 4.0.1 https://github.com/astropy/astropy/pull/9843)
    with np.errstate(invalid='ignore'):
        coords = SkyCoord([-1, 0, 1, np.nan]*u.arcsec, [-2, 0, 2, -np.nan]
                          * u.arcsec, frame=frames.Helioprojective)

    with pytest.warns(RuntimeWarning, match='All-NaN axis encountered'):
        assert _get_extreme_position(coords, 'Tx', operator=np.nanmin) == -1
        assert _get_extreme_position(coords, 'Ty', operator=np.nanmin) == -2

        assert _get_extreme_position(coords, 'Tx', operator=np.nanmax) == 1
        assert _get_extreme_position(coords, 'Ty', operator=np.nanmax) == 2

    with pytest.raises(ValueError):
        _get_extreme_position(coords, 'lon', operator=np.nanmax)