Skip to content

Conversation

@nsajko
Copy link
Member

@nsajko nsajko commented Apr 20, 2024

Don't force returning Array, basically.

Also generalized to non-one-indexed arrays.

Fixes #54161

@nsajko nsajko added the arrays [a, r, r, a, y, s] label Apr 20, 2024
@LilithHafner
Copy link
Member

Don't force returning Array, basically.

Yep, sounds good to me

Also generalized to non-one-indexed arrays.

one must return a multiplicative identity, and afaict, non-one-based arrays have no multiplicative identities as of yet in Julia (JuliaArrays/OffsetArrays.jl#91).

Theoretically, I would say OffsetArray([1 0; 0 1], 0, 10) is a right multiplicative identity of OffsetArray([a b; c d], 0, 10), and OffsetArray([1 0; 0 1], 10, 0) is a left multiplicative identity of OffsetArray([a b; c d], 10, 0). But one is documented to return a two-sided multiplicative identity, so I think it is correct to throw on all non one-based-square-matrices.

@LilithHafner LilithHafner added the maths Mathematical functions label Apr 20, 2024
@nsajko nsajko force-pushed the abstractarray_one branch from 1bc0c28 to 45b6825 Compare April 20, 2024 16:27
Copy link
Member

@LilithHafner LilithHafner left a comment

Choose a reason for hiding this comment

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

There are some superfluous stylistic/error-check-order changes that I don't love, but are not regressions; and it would be easier (for me) to review if the moving code and the changing implementation changes were in two separate commits.

That said, LGTM. The PR improves the implementation and the new test fails on master but passes on the PR. Thanks!

@LilithHafner LilithHafner merged commit aad7245 into JuliaLang:master Apr 20, 2024
@nsajko nsajko deleted the abstractarray_one branch April 20, 2024 23:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arrays [a, r, r, a, y, s] maths Mathematical functions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

one(::AbstractMatrix) always returns Array

2 participants