Skip to content

Subtype ArrayPartition and NamedArrayPartition #443

Open

Description

@htsnowden

We want to use a NamedArrayPartition as our u0 in a problem to replace a DEDataArray which we used (for not much good reason) and NamedArrayPartitions have the functionality we really want. However we need to be able to multiple dispatch on the 'type' of u0 we build (aka the fields we have assigned) and therefore want to use NamedArrayPartition as a supertype to subtype from. Something like the below:

mutable struct test_struct <: NamedArrayPartition
    x :: Vector{Real}
    y :: Matrix{Real}
    z :: AnyothersupportedtypebyNamedArrayPartition
end 

Activity

  1. ChrisRackauckas commented on May 2, 2025

    @ChrisRackauckas
    Member

    It's not clear how this would work, since the interface only expects x and x should be a tuple. We can write up what the AbstractArrayPartition interface should be but this type doesn't seem like it would match it.

  2. htsnowden commented on May 2, 2025

    @htsnowden
    ContributorAuthor

    I could possibly change the need so that it has one field instead of 3 but our main need is the NamedTuple type character of NamedArrayPartitions, in a type that is both multiple dispatchable and usable as an initial condition of an ODEProblem. I don't think NamedTuple's or similar work

  3. ChrisRackauckas commented on May 3, 2025

    @ChrisRackauckas
    Member

    Step one would be to do a code overhaul to make a bunch of functions that use an abstract type. Right now it wouldn't do much because all of the dispatches are on the concrete types.

  4. htsnowden commented on May 6, 2025

    @htsnowden
    ContributorAuthor

    I could try to make a new type similar to ArrayPartitions, and somewhat copy the code and then if it works provide it as a pull request directly into RecursiveArrayTools if that is considered acceptable by yourselves.

  5. ChrisRackauckas commented on May 6, 2025

    @ChrisRackauckas
    Member

    yes

  6. added a commit that references this issue on May 15, 2025
    b7d264c
  7. htsnowden commented on May 15, 2025

    @htsnowden
    ContributorAuthor

    I have a fork with the corrections to the ArrayInterface.zeromatrix within it as well as a new type structure for NamedArrayPartitions which adds an abstract type to allow for subtyping with the same structure as NamedArrayPartition. I was wondering if I could create a pull request for this onto here so someone can review the changes but I can't create a branch here to do so.

  8. ChrisRackauckas commented on May 15, 2025

    @ChrisRackauckas
    Member

    If you create a pull request from your fork then it can be reviewed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions