@@ -15,22 +15,24 @@ cimport numpy as cnp
15
15
from numpy cimport (
16
16
NPY_INT64,
17
17
int64_t,
18
+ ndarray,
18
19
)
19
20
20
21
cnp.import_array()
21
22
22
23
from pandas._libs.algos import ensure_int64
24
+ from pandas._libs.util cimport is_integer_object
23
25
24
26
25
27
@cython.final
26
28
cdef class BlockPlacement:
27
29
# __slots__ = '_as_slice', '_as_array', '_len'
28
30
cdef:
29
31
slice _as_slice
30
- object _as_array
32
+ ndarray _as_array # Note: this still allows `None`
31
33
bint _has_slice, _has_array, _is_known_slice_like
32
34
33
- def __init__ (self , val ):
35
+ def __cinit__ (self , val ):
34
36
cdef:
35
37
slice slc
36
38
@@ -39,7 +41,7 @@ cdef class BlockPlacement:
39
41
self ._has_slice = False
40
42
self ._has_array = False
41
43
42
- if isinstance (val, int ):
44
+ if is_integer_object (val):
43
45
slc = slice (val, val + 1 , 1 )
44
46
self ._as_slice = slc
45
47
self ._has_slice = True
@@ -160,12 +162,12 @@ cdef class BlockPlacement:
160
162
np.concatenate([self .as_array] + [o.as_array for o in others])
161
163
)
162
164
163
- cdef iadd(self , other):
165
+ cdef BlockPlacement iadd(self , other):
164
166
cdef:
165
167
slice s = self ._ensure_has_slice()
166
168
Py_ssize_t other_int, start, stop, step, l
167
169
168
- if isinstance (other, int ) and s is not None :
170
+ if is_integer_object (other) and s is not None :
169
171
other_int = < Py_ssize_t> other
170
172
171
173
if other_int == 0 :
@@ -438,13 +440,13 @@ def get_blkno_placements(blknos, group: bool = True):
438
440
"""
439
441
Parameters
440
442
----------
441
- blknos : array of int64
443
+ blknos : np.ndarray[ int64]
442
444
group : bool, default True
443
445
444
446
Returns
445
447
-------
446
448
iterator
447
- yield (BlockPlacement, blkno )
449
+ yield (blkno, BlockPlacement )
448
450
"""
449
451
blknos = ensure_int64(blknos)
450
452
0 commit comments