Skip to content

Update vector_of_array.jl - #355

Merged
ChrisRackauckas merged 4 commits into
SciML:masterfrom
lxvm:patch-1
Feb 27, 2024
Merged

ChrisRackauckas merged 4 commits into
SciML:masterfrom
lxvm:patch-1

Conversation

@lxvm

@lxvm lxvm commented Feb 19, 2024

Copy link
Copy Markdown
Contributor

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

lxvm commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

Oops this might violate the copying semantics of getindex

@AayushSabharwal AayushSabharwal left a comment

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.

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

lxvm commented Feb 20, 2024

Copy link
Copy Markdown
Contributor Author

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

@AayushSabharwal

Copy link
Copy Markdown
Member

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

@lxvm

lxvm commented Feb 23, 2024

Copy link
Copy Markdown
Contributor Author

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

lxvm commented Feb 27, 2024

Copy link
Copy Markdown
Contributor Author

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
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