Skip to content
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

Making VectorArrays iterable #1056

Closed
pmli opened this issue Aug 9, 2020 · 4 comments · Fixed by #1068
Closed

Making VectorArrays iterable #1056

pmli opened this issue Aug 9, 2020 · 4 comments · Fixed by #1068
Milestone

Comments

@pmli
Copy link
Member

pmli commented Aug 9, 2020

There is already some work done in the va_iteration branch, modifying __getitem__ to raise IndexError for illegal indices.

@pmli pmli added this to the 2020.2 milestone Aug 9, 2020
@sdrave
Copy link
Member

sdrave commented Aug 17, 2020

Yeah, somehow I never finished that. However, one should be aware that iterating over a VectorArray will always return VectorArray views of lenght 1, even if the array is a ListVectorArray. This might be counter-intuitive, so an alternative might be to just raise NotImplementedError in __iter__.

@pmli
Copy link
Member Author

pmli commented Aug 19, 2020

FWIW, I noticed this issue when trying to plot individual VectorArrays from solve.

I don't think that the iterator returning VectorArray views of length 1 is so counter-intuitive. The result of [v for v in U] should be the same as [U[i] for i in range(len(U))].

@sdrave
Copy link
Member

sdrave commented Aug 19, 2020

Ok, then let's make VectorArrays iterable.

@pmli
Copy link
Member Author

pmli commented Aug 19, 2020

Ok. Do you want to open a PR with va_iteration branch?

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 a pull request may close this issue.

2 participants