(self)
| 165 | np.testing.assert_equal(query_1, query_2) |
| 166 | |
| 167 | def test_data_vstack(self): |
| 168 | for n_samples, n_features in product(range(1, 10), range(1, 10)): |
| 169 | # numpy arrays |
| 170 | a, b = np.random.rand(n_samples, n_features), np.random.rand( |
| 171 | n_samples, n_features) |
| 172 | np.testing.assert_almost_equal( |
| 173 | modAL.utils.data.data_vstack((a, b)), |
| 174 | np.concatenate((a, b)) |
| 175 | ) |
| 176 | |
| 177 | # sparse matrices |
| 178 | for format in ['lil', 'csc', 'csr']: |
| 179 | a, b = sp.random(n_samples, n_features, format=format), sp.random( |
| 180 | n_samples, n_features, format=format) |
| 181 | self.assertEqual((modAL.utils.data.data_vstack( |
| 182 | (a, b)) != sp.vstack((a, b))).sum(), 0) |
| 183 | |
| 184 | # lists |
| 185 | a, b = np.random.rand(n_samples, n_features).tolist(), np.random.rand( |
| 186 | n_samples, n_features).tolist() |
| 187 | np.testing.assert_almost_equal( |
| 188 | modAL.utils.data.data_vstack((a, b)), |
| 189 | np.concatenate((a, b)) |
| 190 | ) |
| 191 | |
| 192 | # torch.Tensors |
| 193 | a, b = torch.ones(2, 2), torch.ones(2, 2) |
| 194 | torch.testing.assert_allclose( |
| 195 | modAL.utils.data.data_vstack((a, b)), |
| 196 | torch.cat((a, b)) |
| 197 | ) |
| 198 | |
| 199 | # not supported formats |
| 200 | self.assertRaises(TypeError, modAL.utils.data.data_vstack, (1, 1)) |
| 201 | |
| 202 | # functions from modALu.tils.selection |
| 203 |
nothing calls this directly
no outgoing calls
no test coverage detected