@@ -0,0 +1,1985 @@
+import unittest%0A%0Aimport numpy as np%0A%0Afrom chainer import testing%0Afrom chainercv.dataset import AnnotatedImageDatasetMixin%0A%0A%0Aclass SingleAnnotationDataset(AnnotatedImageDatasetMixin):%0A    def __len__(self):%0A        return 10%0A%0A    def get_image(self, i):%0A        return np.random.uniform(0, 256, size=(3, 32, 48)).astype(np.float32)%0A%0A    def get_annotation(self, i):%0A        return np.random.randint(0, 9, dtype=np.int32)%0A%0A%0Aclass MultipleAnnotationDataset(AnnotatedImageDatasetMixin):%0A    def __len__(self):%0A        return 10%0A%0A    def get_image(self, i):%0A        return np.random.uniform(0, 256, (3, 32, 48)).astype(np.float32)%0A%0A    def get_annotation(self, i):%0A        anno0 = np.random.uniform(0, 32, size=(20, 4), dtype=np.float32)%0A        anno1 = np.random.randint(0, 9, size=20, dtype=np.int32)%0A        return anno0, anno1%0A%0A%0A@testing.parameterize(%0A    %7B'dataset': SingleAnnotationDataset, 'n_anno': 1%7D,%0A    %7B'dataset': MultipleAnnotationDataset, 'n_anno': 2%7D,%0A)%0Aclass TestAnnotatedImageDatasetMixin(unittest.TestCase):%0A%0A    def setup(self):%0A        self.dataset = self.dataset()%0A%0A    def test_base_dataset_len(self):%0A        self.assertEqual(len(self.dataset), 10)%0A%0A    def test_base_dataset_index(self):%0A        for i in range(self.dataset):%0A            example = self.dataset%5Bi%5D%0A            self.assertEqual(len(example), 1 + self.n_anno)%0A%0A    def test_base_dataset_slice(self):%0A        for example in self.dataset%5B:%5D:%0A            self.assertEqual(len(example), 1 + self.n_anno)%0A%0A    def test_annotation_dataset_len(self):%0A        self.assertEqual(len(self.dataset.annotations), 10)%0A%0A    def test_annotation_dataset_index(self):%0A        for i in range(self.dataset.annotations):%0A            example = self.dataset.annotations%5Bi%5D%0A            self.assertEqual(len(example), self.n_anno)%0A%0A    def test_annotation_dataset_slice(self):%0A        for example in self.dataset.annotations%5B:%5D:%0A            self.assertEqual(len(example), self.n_anno)%0A%0A%0Atesting.run_module(__name__, __file__)%0A

add test