MCPcopy Create free account
hub / github.com/pytorch/pytorch / test_splits_reproducibility

Method test_splits_reproducibility

test/test_dataloader.py:211–227  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

209 pass
210
211 def test_splits_reproducibility(self):
212 self.assertEqual(
213 [list(x) for x in random_split(range(10), [3, 7], generator=torch.Generator().manual_seed(1))],
214 [[5, 6, 1], [2, 0, 8, 9, 3, 7, 4]],
215 )
216 self.assertEqual(
217 random_split(range(100), [60, 40], generator=torch.Generator().manual_seed(42)),
218 random_split(range(100), [60, 40], generator=torch.Generator().manual_seed(42)),
219 )
220 self.assertEqual(
221 random_split(range(100), [0.5, 0.5], generator=torch.Generator().manual_seed(42)),
222 random_split(range(100), [0.5, 0.5], generator=torch.Generator().manual_seed(42)),
223 )
224 self.assertEqual(
225 random_split(range(100), [0.33, 0.33, 0.34], generator=torch.Generator().manual_seed(42)),
226 random_split(range(100), [0.33, 0.33, 0.34], generator=torch.Generator().manual_seed(42)),
227 )
228
229 def test_incomplete_fractional_splits(self):
230 with self.assertRaises(ValueError):

Callers

nothing calls this directly

Calls 4

random_splitFunction · 0.90
listFunction · 0.85
rangeFunction · 0.50
assertEqualMethod · 0.45

Tested by

no test coverage detected