<commit_before>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."""<commit_msg>Remove test for get_grid_shape for scalar grids.<commit_after>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


def test_get_grid_spacing(new_bmi, gid):
    """Test the grid spacing."""
{'fraction_non_alphanumeric': 0.0944, 'fraction_numerical': 0.004266666666666667, 'mean_word_length': 2.2178387650085765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6436493', 'n_tokens_mistral': 644, 'n_tokens_neox': 611, 'n_words': 146}