Skip to content

Commit 501bfe3

Browse files
committed
rows property now return -1
1 parent 08d9eab commit 501bfe3

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/_arraykit.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5423,16 +5423,14 @@ BlockIndex_setstate(BlockIndexObject *self, PyObject *state)
54235423
//------------------------------------------------------------------------------
54245424
// getters
54255425

5426-
// Never expose a negative row value to the caller
5427-
#define AK_BI_ROWS(rows) ((rows) < 0 ? 0 : (rows))
5428-
5426+
// In a shape tuple, rows will never be negative.
54295427
static PyObject *
54305428
BlockIndex_shape_getter(BlockIndexObject *self, void* Py_UNUSED(closure))
54315429
{
54325430
if (self->shape == NULL || self->shape_recache) {
54335431
Py_XDECREF(self->shape); // get rid of old if it exists
54345432
self->shape = AK_build_pair_ssize_t(
5435-
AK_BI_ROWS(self->row_count),
5433+
self->row_count < 0 ? 0 : self->row_count,
54365434
self->bir_count);
54375435
}
54385436
// shape is not null and shape_recache is false
@@ -5441,9 +5439,11 @@ BlockIndex_shape_getter(BlockIndexObject *self, void* Py_UNUSED(closure))
54415439
return self->shape;
54425440
}
54435441

5442+
5443+
// Unset rows will be -1.
54445444
static PyObject *
54455445
BlockIndex_rows_getter(BlockIndexObject *self, void* Py_UNUSED(closure)){
5446-
return PyLong_FromSsize_t(AK_BI_ROWS(self->row_count));
5446+
return PyLong_FromSsize_t(self->row_count);
54475447
}
54485448

54495449
static PyObject *

test/test_block_index.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,7 @@ def test_block_index_iter_block_c(self) -> None:
854854
def test_block_index_shape_a(self) -> None:
855855
bi1 = BlockIndex()
856856
self.assertEqual(bi1.shape, (0, 0))
857-
self.assertEqual(bi1.rows, 0)
857+
self.assertEqual(bi1.rows, -1) # kept to show no assignemt
858858

859859
bi1.register(np.array(()).reshape(2,0))
860860
self.assertEqual(bi1.shape, (2, 0))

0 commit comments

Comments
 (0)