summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorSebastian Berg <sebastian@sipsolutions.net>2020-09-12 15:36:09 -0500
committerGitHub <noreply@github.com>2020-09-12 15:36:09 -0500
commit8adeca227a39640b0ad4db38ca34a77a0bb50c8f (patch)
treef8cfa27a28eabe4b52ee4465419c391bbc64420d /numpy/core
parentc7d83e7412169399586272176d5ad839b568ba57 (diff)
parent52b4c49ef8ad74a811b9b0e751d913da9d1a5933 (diff)
downloadnumpy-8adeca227a39640b0ad4db38ca34a77a0bb50c8f.tar.gz
Merge pull request #17150 from eric-wieser/cython-isinstance
ENH: Add support for the abstract scalars to cython code
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/examples/checks.pyx4
-rw-r--r--numpy/core/tests/test_cython.py8
2 files changed, 12 insertions, 0 deletions
diff --git a/numpy/core/tests/examples/checks.pyx b/numpy/core/tests/examples/checks.pyx
index ecf0ad3fa..151979db7 100644
--- a/numpy/core/tests/examples/checks.pyx
+++ b/numpy/core/tests/examples/checks.pyx
@@ -24,3 +24,7 @@ def get_td64_value(obj):
def get_dt64_unit(obj):
return cnp.get_datetime64_unit(obj)
+
+
+def is_integer(obj):
+ return isinstance(obj, (cnp.integer, int))
diff --git a/numpy/core/tests/test_cython.py b/numpy/core/tests/test_cython.py
index 63524b269..bfdb692d7 100644
--- a/numpy/core/tests/test_cython.py
+++ b/numpy/core/tests/test_cython.py
@@ -126,3 +126,11 @@ def test_get_datetime64_unit(install_temp):
result = checks.get_dt64_unit(td64)
expected = 5
assert result == expected
+
+
+def test_abstract_scalars(install_temp):
+ import checks
+
+ assert checks.is_integer(1)
+ assert checks.is_integer(np.int8(1))
+ assert checks.is_integer(np.uint64(1))