(self)
| 236 | random_split([1, 2, 3, 4], [1.1]) |
| 237 | |
| 238 | def test_splits_generator(self): |
| 239 | # A random_split without a specific generator should affect the default one |
| 240 | state = torch.get_rng_state() |
| 241 | a = torch.rand(10) |
| 242 | torch.set_rng_state(state) |
| 243 | random_split(range(10), [5, 5]) |
| 244 | b = torch.rand(10) |
| 245 | self.assertNotEqual(a, b) |
| 246 | |
| 247 | # A random_split with a specific generator should not affect the default one |
| 248 | state = torch.get_rng_state() |
| 249 | a = torch.rand(10) |
| 250 | torch.set_rng_state(state) |
| 251 | random_split(range(10), [5, 5], generator=torch.Generator().manual_seed(42)) |
| 252 | b = torch.rand(10) |
| 253 | self.assertEqual(a, b) |
| 254 | |
| 255 | def test_slicing_of_subset_of_dataset(self): |
| 256 | # Testing slicing a subset initialized with a dataset |
nothing calls this directly
no test coverage detected