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

feat: Preserve Indices When Copying Tracked Arrays #263

Merged
merged 4 commits into from
Jun 28, 2024

Conversation

DhairyaLGandhi
Copy link
Contributor

@DhairyaLGandhi DhairyaLGandhi changed the title feat: preserve indices when copying tracked arrays feat: Preserve Indices When Copying Tracked Arrays Jun 26, 2024
@DhairyaLGandhi
Copy link
Contributor Author

Bumping :)

@@ -55,6 +55,9 @@ end
function Base.convert(::Type{ComponentArray{T1,N,A1,Ax1}}, x::ComponentArray{T2,N,A2,Ax2}) where {T1,T2,N,A1,A2,Ax1,Ax2}
return T1.(x)
end
function Base.convert(::Type{ComponentArray{T,N,A1,Ax1}}, x::ComponentArray{T,N,A2,Ax2}) where {T,N,A1,A2,Ax1,Ax2}
return x
Copy link
Owner

Choose a reason for hiding this comment

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

Wouldn't we want the axes to be from the type we're converting to? I think part of the contract of convert is that the output needs to be of the type you're converting to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It follows the same pattern as some of the other dispatches

function Base.convert(::Type{ComponentArray{T,N,A,Ax1}}, x::ComponentArray{T,N,A,Ax2}) where {T,N,A,Ax1,Ax2}

Copy link
Contributor

Choose a reason for hiding this comment

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

I think in those dispatches we'd want to just have Ax instead of Ax1 and Ax2 too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed! I do not know if there are downstream packages relying on that behaviour, so I will not touch those dispatches in this PR. For now, I have matched the axes for this dispatch

Copy link
Owner

Choose a reason for hiding this comment

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

Oh, I definitely need to change those, then. But that doesn't block this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have also had to add another trivial dispatch to avoid ambiguities.

@jonniedie
Copy link
Owner

Sorry, I commented this morning but forgot to hit "Submit Review"

@DhairyaLGandhi
Copy link
Contributor Author

Bump :)

@jonniedie jonniedie merged commit 5aaf060 into jonniedie:main Jun 28, 2024
6 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.

3 participants