Exemplo n.º 1
0
def test_insert_row(mixin_cols):
    """
    Test inserting a row, which works for Column, Quantity, Time and SkyCoord.
    """
    t = QTable(mixin_cols)
    t0 = t.copy()
    t['m'].info.description = 'd'
    idxs = [0, -1, 1, 2, 3]
    if isinstance(
            t['m'],
        (u.Quantity, Column, time.Time, time.TimeDelta, coordinates.SkyCoord)):
        t.insert_row(1, t[-1])

        for name in t.colnames:
            col = t[name]
            if isinstance(col, coordinates.SkyCoord):
                assert skycoord_equal(col, t0[name][idxs])
            else:
                assert np.all(col == t0[name][idxs])

        assert t['m'].info.description == 'd'
    else:
        with pytest.raises(ValueError) as exc:
            t.insert_row(1, t[-1])
        assert "Unable to insert row" in str(exc.value)
Exemplo n.º 2
0
def test_skycoord_with_velocity():
    # Regression test for gh-6447
    sc = SkyCoord([1], [2], unit='deg', galcen_v_sun=None)
    t = Table([sc])
    s = StringIO()
    t.write(s, format='ascii.ecsv', overwrite=True)
    s.seek(0)
    t2 = Table.read(s.read(), format='ascii.ecsv')
    assert skycoord_equal(t2['col0'], sc)
Exemplo n.º 3
0
 def tree_match(old, new):
     NDArrayType.assert_equal(new['a'], old['a'])
     NDArrayType.assert_equal(new['b'], old['b'])
     assert skycoord_equal(new['c'], old['c'])
Exemplo n.º 4
0
 def assert_equal(cls, old, new):
     assert skycoord_equal(old, new)