Skip to content

MAINT: IntpFromSequence cannot return a wrong length here. #13405

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

seberg
Copy link
Member

@seberg seberg commented Apr 26, 2019

As per Matti's comment, removing the path and adding an assert instead,
since it is clearer to read.

Closes gh-10813

As per Matti's comment, removing the path and adding an assert instead,
since it is clearer to read.

Closes numpygh-10813
Copy link
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.

Doesn't look right

@eric-wieser
Copy link
Member

eric-wieser commented Apr 26, 2019

Are you sure this can't return a different value? How does the following behave?

class Evil:
    _len = 10
    def __getitem__(self, x):
        if 0 <= x < self._len: return 1
        raise IndexError  # needed to make list(Evil()) work
    def __len__(self, x):
        self._len -= 1
        return self._len

@eric-wieser
Copy link
Member

eric-wieser commented Apr 26, 2019

I went down a rabbit hole here and ended up at gh-13407. As an interesting side effect, this allows iterators to be passed as a shape:

np.zeros(i*i for i in range(5))

@seberg
Copy link
Member Author

seberg commented Apr 26, 2019

Hehe, there you think something is easy. But yeah, I had somehow forgotten to think length might change :). I will check your changes today, seems like it doubles as nice maintenance at least. Closing this, as we will probably end up with that.

@seberg seberg closed this Apr 26, 2019
@seberg seberg deleted the issue-10813 branch May 18, 2019 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No exception set while conversion failure in PyArray_IntpConverter
2 participants