@@ -7,6 +7,9 @@ cimport cython
7
7
import re
8
8
import sys
9
9
10
+ # initialise NumPy C-API
11
+ np.import_array()
12
+
10
13
11
14
def little_endian ():
12
15
cdef int endian_detector = 1
182
185
('a', np.dtype('i,i')),\
183
186
('b', np.dtype('i,i'))\
184
187
])))) # doctest: +NORMALIZE_WHITESPACE
185
- array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))],
188
+ array([((0, 0), (0, 0)), ((1, 2), (1, 4)), ((1, 2), (1, 4))],
186
189
dtype=[('a', [('f0', '!i4'), ('f1', '!i4')]), ('b', [('f0', '!i4'), ('f1', '!i4')])])
187
190
188
191
>>> print(test_nested_dtypes(np.zeros((3,), dtype=np.dtype([\
235
238
8,16
236
239
237
240
>>> test_point_record() # doctest: +NORMALIZE_WHITESPACE
238
- array([(0., 0.), (1., -1.), (2., -2.)],
241
+ array([(0., 0.), (1., -1.), (2., -2.)],
239
242
dtype=[('x', '!f8'), ('y', '!f8')])
240
243
241
244
"""
@@ -947,4 +950,16 @@ def test_broadcast_comparison(np.ndarray[double, ndim=1] a):
947
950
return a == 0 , obj == 0 , a == 1 , obj == 1
948
951
949
952
950
- include " numpy_common.pxi"
953
+ @testcase
954
+ def test_c_api_searchsorted (np.ndarray arr , other ):
955
+ """
956
+ >>> arr = np.random.randn(10)
957
+ >>> other = np.random.randn(5)
958
+ >>> result, expected = test_c_api_searchsorted(arr, other)
959
+ >>> (result == expected).all()
960
+ True
961
+ """
962
+ result = np.PyArray_SearchSorted(arr, other, np.NPY_SEARCHRIGHT, NULL )
963
+
964
+ expected = arr.searchsorted(other, side = " right" )
965
+ return result, expected
0 commit comments