Skip to content

Making indexing more strict? #188

Closed
@seberg

Description

@seberg

As per my comment here

Beyond "why not", I wonder if there is even a point in allowing arr[boolean_index,] as opposed to just arr[boolean_index].

I admit, since it does not preclude arr_nd[boolean_index_1d, ...] it probably doesn't matter. On the other hand, it seems unnecessary to force arra-likes to implement it. It seems fine for an object to define arr_nd[boolean_index_1d, ...], but regard arr_nd[boolean_index_nd,] as malformed (because it indexes dimension 1 with an N-D index, rather than a 1-D one).

And here about SymPy's way of indexing a Matrix

I don't really agree that SymPy matrices are super weird. I quite like the way they think about elements rather than dimensional indexing. And I think especially with respect to __len__ and __iter__ it would make sense to only strictly define arr_1d[integer] and but not arr_2d[integer]. The latter can be spelled explicitly using arr_2d[integer, ...] or arr_2d[integer, :] which is much more clear and unambiguous. (even arr_2d[integer,] is fine in theory.)

The "downside" is that you don't try to copy the python lists-of-lists analogy. But I am not sure its a particularly good one in any case?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions