Skip to content

adds vector syntax for ArrayPartitions and VectorOfArrays#546

Open
rokke-git wants to merge 3 commits intoSciML:masterfrom
rokke-git:vectors
Open

adds vector syntax for ArrayPartitions and VectorOfArrays#546
rokke-git wants to merge 3 commits intoSciML:masterfrom
rokke-git:vectors

Conversation

@rokke-git
Copy link

@rokke-git rokke-git commented Mar 19, 2026

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

tested everything in ./test locally; the CUDA one failed on using CUDA, and the utils_test had some failing tests which aren't affected by this pr.

I added a second commit showing all the things for ./test, if you don't want to use it there you can just cherrypick the first commit

fixes #544

@rokke-git rokke-git force-pushed the vectors branch 2 times, most recently from 810b005 to ad0fd90 Compare March 21, 2026 11:39
@rokke-git
Copy link
Author

rokke-git commented Mar 21, 2026

fixed typo; and I don't think it actually needed AbstractVecOrMat when it already has AbstractArray.

the typo I fixed shouldn't effect the test cases though, not sure why it was saying it was undefined in your CI? is there somewhere other than ./src/RecursiveArrayTools.jl that it has to be exported from to be used in test cases?

do we need to export Base.getindex since I've added methods to it? it looks like Base.show also has methods added to it but didn't have to be exported

edit: actually, some more thorough testing showed that the vcat had some unintuitive behavior and it also didn't always consistently use my definition (ie, some definitions from base are more specific and take priority), and the typed_vcat version isn't as nice anyways; so I took it out altogether

@ChrisRackauckas
Copy link
Member

Docs and ocstrings?

@rokke-git
Copy link
Author

the only docs I saw was the readme, so I added an example there. the docs folder is kinda empty so I didn't know where you'd even want it there

I hadn't thought about docstrings, can add some real quick

@rokke-git
Copy link
Author

rokke-git commented Mar 22, 2026

I tried adding a recursive example of the ArrayPartitions, but couldn't figure out what I was doing wrong. any idea why

func(u, p, t) = AP[u.x[1], AP[u.x[2].x[1], u.x[2].x[2]]]
ODEProblem(func, AP[ [1.,2.,3.], AP[[1. 2.;3. 4.], [4. 3.;2. 1.]] ], (0, 1)) |> solve

wouldn't work? it's equivalent to the more verbose

function func(u, p, t)
    return ArrayPartition(
        u.x[1],
        ArrayPartition(
            u.x[2].x[1],
            u.x[2].x[2],
        ),
    )
end
ODEProblem(
    func,
    ArrayPartition(
        [1., 2., 3.],
        ArrayPartition(
            [1. 2.;3. 4.],
            [4. 3.;2. 1.],
        ),
    ),
    (0, 1),
) |> solve

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.

Allow vector-like init for ArrayPartitions/VectorOfArrays

2 participants