Skip to content

Split between basic and advanced indexing cannot handle all cases #465

@arcondello

Description

@arcondello

Consider

from dwave.optimization import Model

model = Model()

arr = np.arange(2*3*4*5).reshape(2, 3, 4, 5)
sym = model.constant(arr)


print(arr[:, 0, :, [2]].shape)
print(sym[:, 0, :, [2]].shape())
(1, 2, 4)
(2, 4, 1)

this is because we distribute the 0 index to basic indexing and [2] to advanced indexing. Basic indexing does not have a notion of what we call type 2 indexing. I.e.,

  • The advanced indices are separated by a slice, Ellipsis or newaxis. For example x[arr1, :, arr2].
  • The advanced indices are all next to each other. For example x[..., arr1, arr2, :] but not x[arr1, :, 1] since 1 is an advanced index in this regard.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions