From 6c52d5e0e11abe2df8e7160bccea56b1ec31c7f1 Mon Sep 17 00:00:00 2001 From: Soumya Snigdha Kundu Date: Mon, 6 Jul 2026 15:05:30 +0100 Subject: [PATCH] Reuse random data across container types in quantile test test_many_elements_quantile regenerated random data for every container type; generate it once per element count and reuse across types. Test-only speedup, identical coverage. Signed-off-by: Soumya Snigdha Kundu --- tests/transforms/test_utils_pytorch_numpy_unification.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/transforms/test_utils_pytorch_numpy_unification.py b/tests/transforms/test_utils_pytorch_numpy_unification.py index a78fcab0d1..76c378e260 100644 --- a/tests/transforms/test_utils_pytorch_numpy_unification.py +++ b/tests/transforms/test_utils_pytorch_numpy_unification.py @@ -51,10 +51,11 @@ def test_percentile(self): @skip_if_quick def test_many_elements_quantile(self): # pytorch#64947 - for p in TEST_NDARRAYS: - for elements in (1000, 17_000_000): + for elements in (1000, 17_000_000): + data = np.random.randn(elements) + for p in TEST_NDARRAYS: + x = p(data) for t in [*TEST_NDARRAYS, list]: - x = p(np.random.randn(elements)) q = percentile(x, t([10, 50])) if isinstance(x, torch.Tensor): self.assertIsInstance(q, torch.Tensor)