<commit_before>import unittest
import numpy as np
from numpy.testing import assert_array_equal

import pymt.grids.utils as utils
from pymt.grids import UniformRectilinear, Structured, UnstructuredPoints


class NumpyArrayMixIn(object):
    def assertArrayEqual(self, actual, expected):
        try:
            assert_array_equal(actual, expected)
        except AssertionError as error:
            self.fail(error)


class TestCoordinateUnits(unittest.TestCase):
    def test_one_dim(self):
        self.assertListEqual(['-'], utils.get_default_coordinate_units(1))

    def test_two_dim(self):
        self.assertListEqual(['-', '-'], utils.get_default_coordinate_units(2))

    def test_three_dim(self):
        self.assertListEqual(['-', '-', '-'],
                             utils.get_default_coordinate_units(3))

    def test_zero_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(0)

    def test_four_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(4)


class TestCoordinateNames(unittest.TestCase):
    def test_one_dim(self):
        self.assertListEqual(['x'], utils.get_default_coordinate_names(1))

    def test_two_dim(self):
        self.assertListEqual(['y', 'x'], utils.get_default_coordinate_names(2))

    def test_three_dim(self):
        self.assertListEqual(['z', 'y', 'x'],
                             utils.get_default_coordinate_names(3))

    def test_zero_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(0)

    def test_four_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(4)


class TestArraysAreEqualSize(unittest.TestCase):
    def test_one_array(self):
        utils.assert_arrays_are_equal_size(np.empty(5.))

    def test_two_arrays_equal_size(self):
        utils.assert_arrays_are_equal_size(np.empty(5.), np.empty(5))

    def test_two_arrays_unequal_size(self):
        with self.assertRaises(AssertionError):
            utils.assert_arrays_are_equal_size(np.empty(5.), np.empty(4))


class TestArgsAsNumpyArrays(unittest.TestCase, NumpyArrayMixIn):<commit_msg>Use int rather than float for np.empty, etc.<commit_after>import unittest
import numpy as np
from numpy.testing import assert_array_equal

import pymt.grids.utils as utils
from pymt.grids import UniformRectilinear, Structured, UnstructuredPoints


class NumpyArrayMixIn(object):
    def assertArrayEqual(self, actual, expected):
        try:
            assert_array_equal(actual, expected)
        except AssertionError as error:
            self.fail(error)


class TestCoordinateUnits(unittest.TestCase):
    def test_one_dim(self):
        self.assertListEqual(['-'], utils.get_default_coordinate_units(1))

    def test_two_dim(self):
        self.assertListEqual(['-', '-'], utils.get_default_coordinate_units(2))

    def test_three_dim(self):
        self.assertListEqual(['-', '-', '-'],
                             utils.get_default_coordinate_units(3))

    def test_zero_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(0)

    def test_four_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(4)


class TestCoordinateNames(unittest.TestCase):
    def test_one_dim(self):
        self.assertListEqual(['x'], utils.get_default_coordinate_names(1))

    def test_two_dim(self):
        self.assertListEqual(['y', 'x'], utils.get_default_coordinate_names(2))

    def test_three_dim(self):
        self.assertListEqual(['z', 'y', 'x'],
                             utils.get_default_coordinate_names(3))

    def test_zero_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(0)

    def test_four_dim(self):
        with self.assertRaises(ValueError):
            utils.get_default_coordinate_units(4)


class TestArraysAreEqualSize(unittest.TestCase):
    def test_one_array(self):
        utils.assert_arrays_are_equal_size(np.empty(5, dtype=float))

    def test_two_arrays_equal_size(self):
        utils.assert_arrays_are_equal_size(np.empty(5, dtype=float),
                                           np.empty(5))

    def test_two_arrays_unequal_size(self):
        with self.assertRaises(AssertionError):
            utils.assert_arrays_are_equal_size(np.empty(5, dtype=float),
                                               np.empty(4))


class TestArgsAsNumpyArrays(unittest.TestCase, NumpyArrayMixIn):
{'fraction_non_alphanumeric': 0.10228509249183895, 'fraction_numerical': 0.006528835690968444, 'mean_word_length': 3.2476894639556377, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3688543', 'n_tokens_mistral': 1436, 'n_tokens_neox': 1383, 'n_words': 215}