Skip to content

DEP: Ensure indexing errors will be raised even on empty results#15900

Merged
mattip merged 1 commit intonumpy:masterfrom
seberg:deprecate-empty-indexing-error
May 27, 2020
Merged

DEP: Ensure indexing errors will be raised even on empty results#15900
mattip merged 1 commit intonumpy:masterfrom
seberg:deprecate-empty-indexing-error

Conversation

@seberg
Copy link
Copy Markdown
Member

@seberg seberg commented Apr 2, 2020

Previously, when the indexing result was empty, no check was done
for backward compatibility with pre 1.9 (assumingly).
This may have been only necessary when the outer iteration is empty
as opposed to when just the inner iteration is empty, though.

In any case, it is arguably buggy to ignore indexing errors in this
case. Since there may have been a reason back in the day, and this
is probably extremely rare, optiming for a brief deprecation period
for now.

Closes gh-15898


This opts for a deprecation, but we could decide to skip the deprecation, I suppose we could also decide to make it a VisibleDeprecationWarning. I am a bit surprised there are no test for this, since I obviously was aware of this behaviour when I wrote the indexing code... Although it is possible that it was part of those "Automated" tests, and then got revised away accidentally.

@seberg seberg force-pushed the deprecate-empty-indexing-error branch from 3ca3d64 to b0b7fd0 Compare April 10, 2020 18:39
@seberg
Copy link
Copy Markdown
Member Author

seberg commented May 2, 2020

Unless we do not want to skip the deprecation, I guess is not quite trivial, but I think it should be ready.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"Invalid index into empty indexing result found. "
"Invalid index into empty array found. "

The indexing is into the input, not the result, isn't it?

Copy link
Copy Markdown
Member

@eric-wieser eric-wieser left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change looks fine, wording of the release note and error message could maybe be improved, currently it confuses me a little.

@seberg seberg force-pushed the deprecate-empty-indexing-error branch from b0b7fd0 to cba6f64 Compare May 3, 2020 21:28
@seberg
Copy link
Copy Markdown
Member Author

seberg commented May 3, 2020

Yeah, tricky, tried to rephrase both.

@seberg seberg closed this May 18, 2020
@seberg seberg reopened this May 18, 2020
@seberg seberg force-pushed the deprecate-empty-indexing-error branch from cba6f64 to 79bbe76 Compare May 18, 2020 13:46
@seberg
Copy link
Copy Markdown
Member Author

seberg commented May 18, 2020

Just noticed this, tests should run through now (forgot to modify the message in the test), maybe you can have a second look @eric-wieser .

@seberg seberg force-pushed the deprecate-empty-indexing-error branch 2 times, most recently from 5e7386f to bdc6f69 Compare May 18, 2020 17:01
@eric-wieser
Copy link
Copy Markdown
Member

Would you mind adding a test that the case we were discussing before is now not deprecated? I think the DeprecationTestCase class has an assert_not_deprecated or something, although frankly just calling it outside of assert_deprecated would work fine too.

@seberg
Copy link
Copy Markdown
Member Author

seberg commented May 18, 2020

@eric-wieser I changed the old test from testing that its deprecated to testing that its not deprecated.

Copy link
Copy Markdown
Member

@mattip mattip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small tweaks to the release note, otherwise LGTM.

@seberg seberg force-pushed the deprecate-empty-indexing-error branch from e1c1b33 to 07f17a7 Compare May 26, 2020 20:38
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use warnings.simplefilter('error') to raise the warning

Which warning does "the warning" refer to, this DeprecationWarning or some other?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

expanded the "the" to "this DeprecationWarning" and squashed the commits.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So now I am confused. This message is the DeprecationWarning. It seems redundant, or am I missing something?

Also, your rebase caught a change in a submodule ...

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahh, maybe you meant "to turn this warning into an error and get more details ..."

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, dang, yes and thanks for noticing the submodule change, commit -a is dangerous right now :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yes, adopted... I could just delete the whole thing as well.

@seberg seberg force-pushed the deprecate-empty-indexing-error branch 2 times, most recently from 1ee64f8 to b095232 Compare May 27, 2020 15:49
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: 1.19 or 1.20 ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, 1.20 I guess...

Previously, when the indexing result was empty, no check was done
for backward compatibility with pre 1.9 (assumingly).
This may have been only necessary when the outer iteration is empty
as opposed to when just the inner iteration is empty, though.

In any case, it is arguably buggy to ignore indexing errors in this
case. Since there may have been a reason back in the day, and this
is probably extremely rare, optiming for a brief deprecation period
for now.

Closes numpygh-15898

Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Co-authored-by: Matti Picus <matti.picus@gmail.com>
@seberg seberg force-pushed the deprecate-empty-indexing-error branch from b095232 to 381a2f5 Compare May 27, 2020 15:58
@mattip mattip merged commit 6718040 into numpy:master May 27, 2020
@mattip
Copy link
Copy Markdown
Member

mattip commented May 27, 2020

Thanks @seberg

@seberg seberg deleted the deprecate-empty-indexing-error branch February 5, 2022 02:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DEP: Check integer array indices when result/subspace is empty

5 participants