it's fine to increment the seed of the failing test (but you shouldn't need
to increment it more than once; otherwise something is probably actually
wrong).
+
+3. `test_geometric_sample`, `test_binomial_sample` and `test_poisson_sample`
+ are validated against `scipy.stats.` which are not guaranteed to be identical
+ across different versions of scipy (namely, they yield invalid results in 1.7+)
"""
import math
from torch._six import inf
from torch.testing._internal.common_utils import \
(TestCase, run_tests, set_rng_seed, TEST_WITH_UBSAN, load_tests,
- gradcheck, IS_MACOS, IS_WINDOWS)
+ gradcheck, IS_WINDOWS)
from torch.testing._internal.common_cuda import TEST_CUDA
from torch.autograd import grad
from torch.autograd.functional import jacobian
self.assertEqual(float(Geometric(s).entropy()), scipy.stats.geom(s, loc=-1).entropy().item(), atol=1e-3, rtol=0)
@unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595")
- @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347")
@unittest.skipIf(not TEST_NUMPY, "NumPy not found")
def test_geometric_sample(self):
set_rng_seed(0) # see Note [Randomized statistical tests]
self.assertRaises(NotImplementedError, Binomial(10, p).entropy)
@unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595")
- @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347")
@unittest.skipIf(not TEST_NUMPY, "NumPy not found")
def test_binomial_sample(self):
set_rng_seed(0) # see Note [Randomized statistical tests]
torch.testing.assert_allclose(rate_zero.grad, torch.inf)
@unittest.skipIf(IS_WINDOWS, "See https://github.com/pytorch/pytorch/issues/64595")
- @unittest.skipIf(IS_MACOS, "See https://github.com/pytorch/pytorch/issues/60347")
@unittest.skipIf(not TEST_NUMPY, "Numpy not found")
def test_poisson_sample(self):
set_rng_seed(1) # see Note [Randomized statistical tests]