scipy/skip-factorial-float-tests-on-py310.patch
2020-11-25 19:08:00 +01:00

41 lines
1.6 KiB
Diff

From eabd8ea25fe291665f37fd069a1c574cd30d12cc Mon Sep 17 00:00:00 2001
From: Victor Stinner <vstinner@python.org>
Date: Wed, 25 Nov 2020 11:41:15 +0100
Subject: [PATCH] GH-13122: Skip factorial() float tests on Python 3.10
special.factorial() argument should be an array of integers.
On Python 3.10, math.factorial() reject float.
On Python 3.9, a DeprecationWarning is emitted.
A numpy array casts all integers to float if the array contains a
single NaN.
---
scipy/special/tests/test_basic.py | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/scipy/special/tests/test_basic.py b/scipy/special/tests/test_basic.py
index 9b7260e8435..e2ae29812a5 100644
--- a/scipy/special/tests/test_basic.py
+++ b/scipy/special/tests/test_basic.py
@@ -19,6 +19,7 @@
import itertools
import platform
+import sys
import numpy as np
from numpy import (array, isnan, r_, arange, finfo, pi, sin, cos, tan, exp,
@@ -1822,6 +1823,13 @@ def test_nan_inputs(self, x, exact):
result = special.factorial(x, exact=exact)
assert_(np.isnan(result))
+ # GH-13122: special.factorial() argument should be an array of integers.
+ # On Python 3.10, math.factorial() reject float.
+ # On Python 3.9, a DeprecationWarning is emitted.
+ # A numpy array casts all integers to float if the array contains a
+ # single NaN.
+ @pytest.mark.skipif(sys.version_info >= (3, 10),
+ reason="Python 3.10+ math.factorial() requires int")
def test_mixed_nan_inputs(self):
x = np.array([np.nan, 1, 2, 3, np.nan])
with suppress_warnings() as sup: