<commit_before>import volpy

import numpy as np
import numpy.testing as npt

import unittest


class ScalarGridTestCase(unittest.TestCase):

    def setUp(self):
        self.grid = volpy.Grid(np.ones((100, 100, 100)))

    def test_call1(self):
        result = self.grid([[-0.1, -0.1, -0.1]])
        expected = [0]
        npt.assert_almost_equal(expected, result)

    def test_call2(self):
        result = self.grid([[0, 0, 0]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call3(self):
        result = self.grid([[0.5, 0.5, 0.5]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call4(self):
        result = self.grid([[0.98, 0.98, 0.98]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call5(self):
        result = self.grid([[1, 1, 1]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call6(self):
        result = self.grid([[1.1, 1.1, 1.1]])
        expected = [0]
        npt.assert_almost_equal(expected, result)


class VectorGridTestCase(unittest.TestCase):

    def setUp(self):
        self.grid = volpy.Grid(np.ones((100, 100, 100, 3)))

    def test_call1(self):
        result = self.grid([[-0.1, -0.1, -0.1]])
        expected = [[0, 0, 0]]
        npt.assert_almost_equal(expected, result)

    def test_call2(self):
        result = self.grid([[0, 0, 0]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call3(self):
        result = self.grid([[0.5, 0.5, 0.5]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call4(self):
        result = self.grid([[0.98, 0.98, 0.98]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call5(self):
        result = self.grid([[1, 1, 1]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)<commit_msg>test grid default value parameter<commit_after>import volpy

import numpy as np
import numpy.testing as npt

import unittest


class ScalarGridTestCase(unittest.TestCase):

    def setUp(self):
        self.grid = volpy.Grid(np.ones((100, 100, 100)))

    def test_call1(self):
        result = self.grid([[-0.1, -0.1, -0.1]])
        expected = [0]
        npt.assert_almost_equal(expected, result)

    def test_call2(self):
        result = self.grid([[0, 0, 0]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call3(self):
        result = self.grid([[0.5, 0.5, 0.5]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call4(self):
        result = self.grid([[0.98, 0.98, 0.98]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call5(self):
        result = self.grid([[1, 1, 1]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call6(self):
        result = self.grid([[1.1, 1.1, 1.1]])
        expected = [0]
        npt.assert_almost_equal(expected, result)


class DefaultValueTestCase(unittest.TestCase):

    def setUp(self):
        self.grid = volpy.Grid(np.ones((100, 100, 100)), default=-1)

    def test_call1(self):
        '''Out of bounds returns default value'''
        result = self.grid([[-0.1, -0.1, -0.1]])
        expected = [-1]
        npt.assert_almost_equal(expected, result)

    def test_call2(self):
        '''In bounds returns grid value'''
        result = self.grid([[0.5, 0.5, 0.5]])
        expected = [1]
        npt.assert_almost_equal(expected, result)

    def test_call3(self):
        '''One out of bounds coordinate returns default value (positive)'''
        result = self.grid([[0.5, 100, 0.5]])
        expected = [-1]
        npt.assert_almost_equal(expected, result)

    def test_call4(self):
        '''One out of bounds coordinate returns default value (negative)'''
        result = self.grid([[-0.1, 0.5, 0.5]])
        expected = [-1]
        npt.assert_almost_equal(expected, result)


class VectorGridTestCase(unittest.TestCase):

    def setUp(self):
        self.grid = volpy.Grid(np.ones((100, 100, 100, 3)))

    def test_call1(self):
        result = self.grid([[-0.1, -0.1, -0.1]])
        expected = [[0, 0, 0]]
        npt.assert_almost_equal(expected, result)

    def test_call2(self):
        result = self.grid([[0, 0, 0]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call3(self):
        result = self.grid([[0.5, 0.5, 0.5]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call4(self):
        result = self.grid([[0.98, 0.98, 0.98]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)

    def test_call5(self):
        result = self.grid([[1, 1, 1]])
        expected = [[1, 1, 1]]
        npt.assert_almost_equal(expected, result)
{'fraction_non_alphanumeric': 0.15415495784825373, 'fraction_numerical': 0.05319148936170213, 'mean_word_length': 2.4412983425414363, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4075686', 'n_tokens_mistral': 1888, 'n_tokens_neox': 1731, 'n_words': 379}