Ejemplo n.º 1
0
 def test_download_train(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     train = tecator.Tecator(root=rootdir,
                             train=True,
                             download=True,
                             verbose=False)
     train = tecator.Tecator(root=rootdir, download=True, verbose=False)
     x_train, y_train = train.data, train.targets
     self.assertEqual(x_train.shape[0], 144)
     self.assertEqual(y_train.shape[0], 144)
     self.assertEqual(x_train.shape[1], 100)
Ejemplo n.º 2
0
 def test_download_test(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     test = tecator.Tecator(root=rootdir, train=False, verbose=False)
     x_test, y_test = test.data, test.targets
     self.assertEqual(x_test.shape[0], 71)
     self.assertEqual(y_test.shape[0], 71)
     self.assertEqual(x_test.shape[1], 100)
Ejemplo n.º 3
0
 def test_loadable_with_dataloader(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     test = tecator.Tecator(root=rootdir, train=False, verbose=False)
     _ = torch.utils.data.DataLoader(test, batch_size=64, shuffle=True)
Ejemplo n.º 4
0
 def test_getitem(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     test = tecator.Tecator(root=rootdir, train=False, verbose=False)
     x, y = test[0]
     self.assertEqual(x.shape[0], 100)
     self.assertIsInstance(y, int)
Ejemplo n.º 5
0
 def test_class_to_idx(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     test = tecator.Tecator(root=rootdir, train=False, verbose=False)
     _ = test.class_to_idx
Ejemplo n.º 6
0
 def test_repr(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     train = tecator.Tecator(rootdir, download=True, verbose=True)
     self.assertTrue('Split: Train' in train.__repr__())
Ejemplo n.º 7
0
 def test_download_caching(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     _ = tecator.Tecator(rootdir, download=True, verbose=False)
     _ = tecator.Tecator(rootdir, download=False, verbose=False)
Ejemplo n.º 8
0
 def test_download_false(self):
     rootdir = self.artifacts_dir.rpartition('/')[0]
     self._remove_artifacts()
     with self.assertRaises(RuntimeError):
         _ = tecator.Tecator(rootdir, download=False)