def _arg_func_keepdims(func, *args):
    base = GridData(np.arange(30).reshape(5, 6),
                   axis_labels=('x', 'y'),
                   axis_units=('a', 'b'),
                   voxel_size=(1, 2),
                   axis_offsets=(1, 0))

    r = getattr(base, func)(*args, keepdims=True)
    r2 = getattr(base.view(ndarray), func)(*args, keepdims=True)
    assert_array_equal(r, r2)
def test_transpose():
    base = GridData(np.arange(30).reshape(5, 6),
                   axis_labels=('x', 'y'),
                   axis_units=('a', 'b'),
                   voxel_size=(1, 2),
                   axis_offsets=(1, 0))

    for tt in [base.T, base.transpose()]:
        for k in _axis_attrs:
            a = getattr(tt, k)
            b = getattr(base, k)[::-1]
            if isinstance(a, ndarray):
                assert_array_equal(a, b)
            else:
                assert_equal(a, b)
def test_explicit_creation():
    base = np.arange(30).reshape(5, 6)
    tt = GridData(base)
    assert_array_equal(base, tt.view(ndarray))