Skip to content

Commit 0efd450

Browse files
committed
Fix small formatting issues
1 parent 725c28b commit 0efd450

4 files changed

Lines changed: 12 additions & 13 deletions

File tree

bench/ctable/extend.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,4 +114,3 @@ class RowModel(BaseModel):
114114
print(f"{'Python list of lists':<30} {t_from_list:>12.4f} {'1.00x':>18}")
115115
print(f"{'NumPy structured array':<30} {t_from_np:>12.4f} {t_from_list / t_from_np:>17.2f}x")
116116
print(f"{'Existing CTable':<30} {t_from_ctable:>12.4f} {t_from_list / t_from_ctable:>17.2f}x")
117-

src/blosc2/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -596,7 +596,7 @@ def _raise(exc):
596596
"""
597597

598598
# Delayed imports for avoiding overwriting of python builtins
599-
from .ctable import CTable, Column
599+
from .ctable import Column, CTable
600600
from .ndarray import (
601601
abs,
602602
acos,

src/blosc2/ctable.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -200,23 +200,20 @@ def __getitem__(self, key: int | slice | list | np.ndarray):
200200
pos_true = _find_physical_index(self._valid_rows, key)
201201
return self._raw_col[int(pos_true)]
202202

203-
204-
205203
elif isinstance(key, slice):
206204
real_pos = blosc2.where(self._valid_rows, np.arange(len(self._valid_rows))).compute()
207205
start, stop, step = key.indices(len(real_pos))
208206
mask = blosc2.zeros(len(self._table._valid_rows), dtype=np.bool_)
209207
if step == 1:
210208
phys_start = real_pos[start]
211209
phys_stop = real_pos[stop - 1]
212-
mask[phys_start: phys_stop + 1] = True
210+
mask[phys_start : phys_stop + 1] = True
213211
else:
214212
lindices = np.arange(start, stop, step)
215213
phys_indices = real_pos[lindices]
216214
mask[phys_indices[:]] = True
217215
return Column(self._table, self._col_name, mask=mask)
218216

219-
220217
elif isinstance(key, (list, tuple, np.ndarray)):
221218
real_pos = blosc2.where(self._valid_rows, np.arange(len(self._valid_rows))).compute()
222219
phys_indices = np.array([real_pos[i] for i in key], dtype=np.int64)
@@ -264,11 +261,11 @@ def __iter__(self):
264261
val = np.frombuffer(info.repeated_value, dtype=arr.dtype)[0]
265262
if not val:
266263
continue
267-
yield from self._raw_col[chunk_start: chunk_start + actual_size]
264+
yield from self._raw_col[chunk_start : chunk_start + actual_size]
268265
continue
269266

270-
mask_chunk = arr[chunk_start: chunk_start + actual_size]
271-
data_chunk = self._raw_col[chunk_start: chunk_start + actual_size]
267+
mask_chunk = arr[chunk_start : chunk_start + actual_size]
268+
data_chunk = self._raw_col[chunk_start : chunk_start + actual_size]
272269
yield from data_chunk[mask_chunk]
273270

274271
def __len__(self):
@@ -308,7 +305,9 @@ def to_numpy(self):
308305

309306

310307
class CTable(Generic[RowT]):
311-
def __init__(self, row_type: type[RowT], new_data=None, expected_size: int = 1_048_576, compact: bool = False) -> None:
308+
def __init__(
309+
self, row_type: type[RowT], new_data=None, expected_size: int = 1_048_576, compact: bool = False
310+
) -> None:
312311
self._row_type = row_type
313312
self._cols: dict[str, blosc2.NDArray] = {}
314313
self._n_rows: int = 0

tests/ctable/test_column.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
import numpy as np
1111
import pytest
1212
from pydantic import BaseModel, Field
13-
import blosc2
1413

14+
import blosc2
1515
from blosc2 import CTable
1616

1717

@@ -171,12 +171,14 @@ def test_column_iter():
171171

172172
tabla3 = CTable(RowModel, new_data=DATA20)
173173
tabla3.delete([0, 5, 10, 15])
174+
# fmt: off
174175
expected_score = [
175176
10.0, 20.0, 30.0, 40.0,
176177
60.0, 70.0, 80.0, 90.0,
177178
110.0, 120.0, 130.0, 140.0,
178179
160.0, 170.0, 180.0, 190.0,
179180
]
181+
# fmt: on
180182
assert list(tabla3.score) == expected_score
181183

182184

@@ -264,7 +266,7 @@ def test_to_array_full_column():
264266
col = tabla.id
265267

266268
expected = np.array([i for i in range(20) if i not in {0, 10, 19}], dtype=np.int64)
267-
np.testing.assert_array_equal(col[0:len(col)].to_numpy(), expected)
269+
np.testing.assert_array_equal(col[0 : len(col)].to_numpy(), expected)
268270

269271

270272
def test_to_array_mask_does_not_include_deleted():
@@ -289,6 +291,5 @@ def test_column_view_mask_is_independent():
289291
np.testing.assert_array_equal(view_a.to_numpy(), np.arange(0, 5, dtype=np.int64))
290292

291293

292-
293294
if __name__ == "__main__":
294295
pytest.main(["-v", __file__])

0 commit comments

Comments
 (0)