GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adds an abstract type to NamedArrayPartition by htsnowden · Pull Request #447 · SciML/RecursiveArrayTools.jl

Conversation

@htsnowden

@htsnowden htsnowden commented May 15, 2025

Copy link
Copy Markdown
Contributor

In order to resolve #443 where I would like to be able to subtype from NamedArrayPartition. This is a large restructuring of NamedArrayPartition but all tests within RecursiveArrayTools do pass. I'm not sure of other tests that I would need to run to ensure further compatibility. This maintains all current functionality but allows a user to create a new subtype of AbstractNamedArrayPartition as long as it maintains the same structure. I am pulling into this branch as this is where my previous fix to the ArrayInterface.zeromatrix lives.

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

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@htsnowden
Adds an abstract type to NamedArrayPartition
b7d264c
In order to resolve SciML#443 where I would like to be able to subtype from NamedArrayPartition. This is a large restructuring of NamedArrayPartition but all tests within RecursiveArrayTools do pass. I'm not sure of other tests that I would need to run to ensure further compatibility. This maintains all current functionality but allows a user to create a new subtype of AbstractNamedArrayPartition as long as it maintains the same structure
ChrisRackauckas
ChrisRackauckas reviewed May 15, 2025
View reviewed changes
Comment thread src/named_array_partition.jl Outdated
@@ -1,3 +1,5 @@
abstract type AbstractNamedArrayPartition{T, A, NT} <: AbstractVector{T} end

@ChrisRackauckas ChrisRackauckas May 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I think this should have an AbstractArrayPartition, and that needs a docstring to describe its interface?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@ChrisRackauckas ChrisRackauckas May 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Or is ArrayPartition an AbstractNamedArrayPartition with x being its only names?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@htsnowden htsnowden May 15, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I can add a higher level called AbstractArrayPartition{T} if you want and apply the same level of abstraction to the ArrayPartition interface as well (either or both) such that the same subtyping can be performed there also. I will add to the documentation, a docstring about how you can subtype from the AbstractNamedArrayPartition

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ChrisRackauckas
ChrisRackauckas reviewed May 15, 2025
View reviewed changes
Comment thread src/named_array_partition.jl

function Base.similar(A::NamedArrayPartition)
NamedArrayPartition(
# With new type structure this function does the same as Base.similar(x::AbstractNamedArrayPartition{T, S, NT}) where {T, S, NT}

@ChrisRackauckas ChrisRackauckas May 15, 2025

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Why is this one commented?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@htsnowden htsnowden May 15, 2025

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Because I couldn't manage in either the old or the new method to call the less specific function as providing an NamedArrayPartition will have the type structure X{N, A, NT} and therefore a later version would have instead been called. In the original code the two functions are:

function Base.similar(A::NamedArrayPartition)
    NamedArrayPartition(
        similar(getfield(A, :array_partition)), getfield(A, :names_to_indices))
end

function Base.similar(x::NamedArrayPartition{T, S, NT}) where {T, S, NT}
    NamedArrayPartition{T, S, NT}(
        similar(ArrayPartition(x)), getfield(x, :names_to_indices))
end

But in all cases I tested the second always overwrites the first as any NamedArrayPartition has the structure of the second

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@htsnowden
Added docstrings and AbstractArrayPartition type
d2823c0
After @ChrisRackauckas comments I have documented how to subtype from AbstractNamedArrayPartition as well as added an AbstractArrayPartition type which both AbstractNamedArrayPartition and ArrayPartition subtype from
@ChrisRackauckas

ChrisRackauckas commented May 15, 2025

Copy link
Copy Markdown
Member

It's still missing what is meant by the interface. See for example https://github.com/SciML/RecursiveArrayTools.jl/blob/master/src/RecursiveArrayTools.jl#L16-L110. The questions that have to be answered are:

  1. What does it mean to be an AbstractNamedArrayPartition / AbstractArrayPartition? What things must be true about the definition in order to satisfy the interface? For example, is there a allowednames function or something that everything should assume exists for AbstractNamedArrayPartition
  2. What are the functions and allowed operations on any member of this group?
  3. What is the relation to any other interface (for example AbstractArray)?

Then we need to make sure the abstract library implementations actually match this. For example, for ArrayPartition, the code currently always assumes A.x. See a chunk like https://github.com/SciML/RecursiveArrayTools.jl/blob/master/src/array_partition.jl#L127-L177. So there's a few decisions that have to be made here:

  1. Is ArrayPartition <: AbstractNamedArrayPartition where the names are just x?
    • If that's the case, then we probably need to generalize those functions I linked to so that they match the interface, rather than being specific to ArrayPartition. Seems like a lot of code code could be deleted.
  2. Are AbstractNamedArrayPartition expected to be non-allocating if they .=?
  3. How is AbstractNamedArrayPartition expected to interact with LinearAlgebra?
All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ChrisRackauckas-Claude ChrisRackauckas-Claude mentioned this pull request Oct 8, 2026
Instantiate per-partition Broadcasted in NamedArrayPartition copyto! #677
Merged

This branch has not been deployed

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

Reviewers

@ChrisRackauckas ChrisRackauckas ChrisRackauckas left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

2 participants

@htsnowden @ChrisRackauckas
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.