<commit_before>import os
import unittest

import numpy

from chainer import datasets
from chainer.datasets import image_dataset
from chainer import testing


@unittest.skipUnless(image_dataset.available, 'image_cataset is not available')
@testing.parameterize(*testing.product({
    'dtype': [numpy.float32, numpy.int32],
}))
class TestImageDataset(unittest.TestCase):

    def setUp(self):
        root = os.path.join(os.path.dirname(__file__), 'image_dataset')
        path = os.path.join(root, 'img.lst')
        self.dataset = datasets.ImageDataset(path, root=root, dtype=self.dtype)

    def test_len(self):
        self.assertEqual(len(self.dataset), 2)

    def test_get(self):
        img = self.dataset.get_example(0)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (4, 300, 300))

    def test_get_grey(self):
        img = self.dataset.get_example(1)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (1, 300, 300))


@unittest.skipUnless(image_dataset.available, 'image_cataset is not available')
@testing.parameterize(*testing.product({
    'dtype': [numpy.float32, numpy.int32],
}))
class TestLabeledImageDataset(unittest.TestCase):

    def setUp(self):
        root = os.path.join(os.path.dirname(__file__), 'image_dataset')
        path = os.path.join(root, 'labeled_img.lst')
        self.dataset = datasets.LabeledImageDataset(
            path, root=root, dtype=self.dtype)

    def test_len(self):
        self.assertEqual(len(self.dataset), 2)

    def test_get(self):
        img, label = self.dataset.get_example(0)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (4, 300, 300))

        self.assertEqual(label, 0)
<commit_msg>Fix test<commit_after>import os
import unittest

import numpy

from chainer import datasets
from chainer.datasets import image_dataset
from chainer import testing


@testing.parameterize(*testing.product({
    'dtype': [numpy.float32, numpy.int32],
}))
@unittest.skipUnless(image_dataset.available, 'image_cataset is not available')
class TestImageDataset(unittest.TestCase):

    def setUp(self):
        root = os.path.join(os.path.dirname(__file__), 'image_dataset')
        path = os.path.join(root, 'img.lst')
        self.dataset = datasets.ImageDataset(path, root=root, dtype=self.dtype)

    def test_len(self):
        self.assertEqual(len(self.dataset), 2)

    def test_get(self):
        img = self.dataset.get_example(0)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (4, 300, 300))

    def test_get_grey(self):
        img = self.dataset.get_example(1)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (1, 300, 300))


@testing.parameterize(*testing.product({
    'dtype': [numpy.float32, numpy.int32],
}))
@unittest.skipUnless(image_dataset.available, 'image_cataset is not available')
class TestLabeledImageDataset(unittest.TestCase):

    def setUp(self):
        root = os.path.join(os.path.dirname(__file__), 'image_dataset')
        path = os.path.join(root, 'labeled_img.lst')
        self.dataset = datasets.LabeledImageDataset(
            path, root=root, dtype=self.dtype)

    def test_len(self):
        self.assertEqual(len(self.dataset), 2)

    def test_get(self):
        img, label = self.dataset.get_example(0)
        self.assertEqual(img.dtype, self.dtype)
        self.assertEqual(img.shape, (4, 300, 300))

        self.assertEqual(label, 0)

{'fraction_non_alphanumeric': 0.1299515531490453, 'fraction_numerical': 0.019948703334283273, 'mean_word_length': 3.5584415584415585, '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': '4329721', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1119, 'n_words': 213}