EelcoHoogendoorn / Numpy_arraysetops_EP

Numpy group_by and set-operations
MIT License
207 stars 18 forks source link

npi.indexes does not seem to work as expected #19

Closed AlbertoSinigaglia closed 1 year ago

AlbertoSinigaglia commented 1 year ago

by the doc, it should be that this[indexes] == that, however:

items = np.array([[1,2,3], [2,3,4], [4,5,6]])
to_search = np.array([[1,2,4], [2,3,4]])
npi.indices(items, to_search, missing="ignore")

returns [1,1]

Any explanation?

Edit:
same changing the axis... I would expect to treat each subvector as "item to search from/into", thus in this case there should be just 1 returned... however, even stranger, using to_search = np.array([[1,2,4]) returns something.. which does not makes sense, as there are no element that matches it

EelcoHoogendoorn commented 1 year ago

From the docstring;

if missing is 'ignore', all elements of that are assumed to be present in this, and output is undefined otherwise

[1,2,4] isnt to be found in the zeroth axis of items; hence you get undefined output.

Maybe you meant to pass in an axis=1 arg?

AlbertoSinigaglia commented 1 year ago

From the docstring;

if missing is 'ignore', all elements of that are assumed to be present in this, and output is undefined otherwise

[1,2,4] isnt to be found in the zeroth axis of items; hence you get undefined output.

Maybe you meant to pass in an axis=1 arg?

What's the point of having a undefined behavior in a case where there is a obvious intuitive behavior?... wouldn't it be so nice to remove the "undefineteness"?

EelcoHoogendoorn commented 1 year ago

What 'obvious intuitive behavior' do you have in mind, for a nonexisting lookup, whos error message you chose to suppress?