import warnings

import numpy as np


def test_get_grid_shape(new_bmi, gid):
    """Test the grid shape."""
    gtype = new_bmi.get_grid_type(gid)
    if gtype == 'uniform_rectilinear':
        ndim = new_bmi.get_grid_rank(gid)

        shape = np.empty(ndim, dtype=np.int32)
        try:
            rtn = new_bmi.get_grid_shape(gid, shape)
        except TypeError:
            warnings.warn('get_grid_shape should take two arguments')
            rtn = new_bmi.get_grid_shape(gid)
            shape[:] = rtn
        else:
            assert rtn is shape

        for dim in shape:
            assert dim > 0

    if gtype == 'scalar':
        ndim = new_bmi.get_grid_rank(gid)

        shape = np.empty(ndim, dtype=np.int32)
        try:
            rtn = new_bmi.get_grid_shape(gid, shape)
        except TypeError:
            warnings.warn('get_grid_shape should take two arguments')
            rtn = new_bmi.get_grid_shape(gid)
        else:
            assert rtn is shape
        np.testing.assert_equal(shape, ())


def test_get_grid_spacing(new_bmi, gid):
    """Test the grid spacing."""
    gtype = new_bmi.get_grid_type(gid)
    if gtype == 'uniform_rectilinear':
        ndim = new_bmi.get_grid_rank(gid)

        spacing = np.empty(ndim, dtype=float)
        assert spacing is new_bmi.get_grid_spacing(gid, spacing)

@@ -609,422 +609,8 @@
  0%0A%0A
-    if gtype == 'scalar':%0A        ndim = new_bmi.get_grid_rank(gid)%0A%0A        shape = np.empty(ndim, dtype=np.int32)%0A        try:%0A            rtn = new_bmi.get_grid_shape(gid, shape)%0A        except TypeError:%0A            warnings.warn('get_grid_shape should take two arguments')%0A            rtn = new_bmi.get_grid_shape(gid)%0A        else:%0A            assert rtn is shape%0A        np.testing.assert_equal(shape, ())%0A%0A
 %0Adef

Remove test for get_grid_shape for scalar grids.