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

Update vector_of_array.jl #355

Merged
merged 4 commits into from
Feb 27, 2024
Merged

Update vector_of_array.jl #355

merged 4 commits into from
Feb 27, 2024

Conversation

lxvm
Copy link
Contributor

@lxvm lxvm commented Feb 19, 2024

Fix #354

Checklist

  • Appropriate tests were added
  • Any code changes were done in a way that does not break public API
  • All documentation related to code changes were updated
  • The new code follows the
    contributor guidelines, in particular the SciML Style Guide and
    COLPRAC.
  • Any new documentation only uses public API

Additional context

Add any other context about the problem here.

@lxvm
Copy link
Contributor Author

lxvm commented Feb 20, 2024

Oops this might violate the copying semantics of getindex

Copy link
Member

@AayushSabharwal AayushSabharwal left a comment

Choose a reason for hiding this comment

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

Copying isn't really an issue here, since we can't avoid it. However, I'd recommend using the Adapt.adapt(...) wrapper instead of Array. That way the output type matches the type of the contained arrays.

@lxvm
Copy link
Contributor Author

lxvm commented Feb 20, 2024

I meant to say that getindex must copy, but Array may not. Is Adapt.adapt required to copy?

@AayushSabharwal
Copy link
Member

I think it copies, and anyway Array(::VectorOfArray) will copy anyway?

@lxvm
Copy link
Contributor Author

lxvm commented Feb 23, 2024

The following method of Array doesn't copy:


I'll probably keep the original method and add one with numeric elements that forwards the indices to the inner array.

@lxvm
Copy link
Contributor Author

lxvm commented Feb 27, 2024

I updated my pr to just add a new method which will fix the broken case. I also rebased onto the main branch. I hope this looks good.

@ChrisRackauckas ChrisRackauckas merged commit 8b7627f into SciML:master Feb 27, 2024
22 of 24 checks passed
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.

getindex with slice breaks on size 1 arrays
3 participants