8000 TST: Check that Cython intp conversion uses normal integer rules · numpy/numpy@09eb7d5 · GitHub
[go: up one dir, main page]

Skip to content

Commit 09eb7d5

Browse files
committed
TST: Check that Cython intp conversion uses normal integer rules
10000
1 parent af2c4cf commit 09eb7d5

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

numpy/core/tests/examples/cython/checks.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,6 @@ def get_dt64_unit(obj):
3030

3131
def is_integer(obj):
3232
return isinstance(obj, (cnp.integer, int))
33+
34+
def conv_intp(cnp.intp_t val):
35+
return val

numpy/core/tests/test_cython.py

Lines changed: 11 additions & 0 deletions
< 44B9 tr class="diff-line-row">
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,14 @@ def test_abstract_scalars(install_temp):
122122
assert checks.is_integer(1)
123123
assert checks.is_integer(np.int8(1))
124124
assert checks.is_integer(np.uint64(1))
125+
126+
def test_conv_intp(install_temp):
127+
import checks
128+
129+
class myint:
130+
def __int__(self):
131+
return 3
132+
133+
# These conversion passes via `__int__`, not `__index__`:
134+
assert checks.conv_intp(3.) == 3
135+
assert checks.conv_intp(myint()) == 3

0 commit comments

Comments
 (0)
0