Skip to content

Commit 6bf7be7

Browse files
authored
Merge pull request #126 from static-frame/125/block-index-refine
`BlockIndex` improvemtns
2 parents bfccbaf + 0f30777 commit 6bf7be7

File tree

4 files changed

+209
-123
lines changed

4 files changed

+209
-123
lines changed

doc/articles/block_index.py

+18-17
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
sys.path.append(os.getcwd())
2121

2222
from performance.reference.block_index import from_blocks
23+
from performance.reference.block_index import indices_to_contiguous_pairs
2324

2425

2526

@@ -130,73 +131,73 @@ def __call__(self):
130131

131132

132133
class BlockIndexIterIntArray(ArrayProcessor):
133-
NAME = 'BlockIndex: iter by int array'
134+
NAME = 'BlockIndex: contig by int array'
134135
SORT = 5
135136

136137
def __call__(self):
137-
_ = list(self.bi.iter_select(self.selector_int_array))
138+
_ = list(self.bi.iter_contiguous(self.selector_int_array))
138139

139140
class TupleIndexIterIntArray(ArrayProcessor):
140-
NAME = 'TupleIndex: iter by int array'
141+
NAME = 'TupleIndex: contig by int array'
141142
SORT = 15
142143

143144
def __call__(self):
144145
ti = self.ti
145-
_ = [ti[i] for i in self.selector_int_array]
146+
_ = list(indices_to_contiguous_pairs(ti[i] for i in self.selector_int_array))
146147

147148

148149
class BlockIndexIterIntList(ArrayProcessor):
149-
NAME = 'BlockIndex: iter by int list'
150+
NAME = 'BlockIndex: contig by int list'
150151
SORT = 6
151152

152153
def __call__(self):
153-
_ = list(self.bi.iter_select(self.selector_int_list))
154+
_ = list(self.bi.iter_contiguous(self.selector_int_list))
154155

155156
class TupleIndexIterIntList(ArrayProcessor):
156-
NAME = 'TupleIndex: iter by int list'
157+
NAME = 'TupleIndex: contig by int list'
157158
SORT = 16
158159

159160
def __call__(self):
160161
ti = self.ti
161-
_ = [ti[i] for i in self.selector_int_list]
162+
_ = list(indices_to_contiguous_pairs(ti[i] for i in self.selector_int_list))
162163

163164

164165
class BlockIndexIterSlice(ArrayProcessor):
165-
NAME = 'BlockIndex: iter by slice'
166+
NAME = 'BlockIndex: contig by slice'
166167
SORT = 7
167168

168169
def __call__(self):
169-
_ = list(self.bi.iter_select(self.selector_slice))
170+
_ = list(self.bi.iter_contiguous(self.selector_slice))
170171

171172
class TupleIndexIterSlice(ArrayProcessor):
172-
NAME = 'TupleIndex: iter by slice'
173+
NAME = 'TupleIndex: contig by slice'
173174
SORT = 17
174175

175176
def __call__(self):
176177
ti = self.ti
177-
_ = list(iter(ti[self.selector_slice]))
178+
_ = list(indices_to_contiguous_pairs(ti[self.selector_slice]))
178179

179180

180181

181182

182183
class BlockIndexIterBoolArray(ArrayProcessor):
183-
NAME = 'BlockIndex: iter by bool array'
184+
NAME = 'BlockIndex: contig by bool array'
184185
SORT = 8
185186

186187
def __call__(self):
187-
_ = list(self.bi.iter_select(self.selector_bool_array))
188+
_ = list(self.bi.iter_contiguous(self.selector_bool_array))
188189

189190
class TupleIndexIterBoolArray(ArrayProcessor):
190-
NAME = 'TupleIndex: iter by bool array'
191+
NAME = 'TupleIndex: contig by bool array'
191192
SORT = 18
192193

193194
def __call__(self):
194195
ti = self.ti
195-
_ = [ti[i] for i, b in enumerate(self.selector_bool_array) if b]
196+
_ = list(indices_to_contiguous_pairs(ti[i] for i, b in enumerate(self.selector_bool_array) if b))
196197

197198

198199
#-------------------------------------------------------------------------------
199-
NUMBER = 5
200+
NUMBER = 50
200201

201202
def seconds_to_display(seconds: float) -> str:
202203
seconds /= NUMBER

src/__init__.pyi

+10-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,14 @@ class BlockIndex:
3131
rows: int
3232
columns: int
3333

34-
def __init__() -> None: ...
34+
def __init__(
35+
block_count: int = 0,
36+
row_count: int = -1,
37+
bir_count: int = 0,
38+
bir_capacity: int = 8,
39+
bir_bytes: bytes = b'',
40+
dtype: np.dtype = None,
41+
) -> None: ...
3542
def register(self, __value: np.ndarray) -> bool: ...
3643
def to_list(self,) -> tp.List[int]: ...
3744
def to_bytes(self,) -> bytes: ...
@@ -48,9 +55,10 @@ class BlockIndex:
4855
) -> tp.Iterator[tp.Tuple[int, int]]: ...
4956
def iter_contiguous(self,
5057
__key: tp.Union[slice, np.ndarray, tp.List[int]],
58+
*,
5159
ascending: bool = False,
5260
reduce: bool = False,
53-
) -> tp.Iterator[tp.Tuple[int, int]]: ...
61+
) -> tp.Iterator[tp.Tuple[int, tp.Union[slice, int]]]: ...
5462

5563

5664
def iterable_str_to_array_1d(

0 commit comments

Comments
 (0)