-
Notifications
You must be signed in to change notification settings - Fork 28
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
Extend LinearAlgebra.copy_oftype
#134
base: master
Are you sure you want to change the base?
Conversation
# Catch issue #133 | ||
S = wrapdims(Symmetric(rand(Int8,3,3)), 'a':'c', 10:10:30) | ||
@test LinearAlgebra.copy_oftype(S, eltype(S)) == S |
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.
This test passes before the PR.
It's OK to test the exact internal function, but more important I think to test the high-level behaviour which needs it.
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.
Agreed, I will add a test of the high level problem.
Sorry, I think I misdiagnosed the problem, which seems to be with copyto!
(which my Julia version was calling) This errors on Julia 1.6
julia> versioninfo()
Julia Version 1.6.7
Commit 3b76b25b64 (2022-07-19 15:11 UTC)
Platform Info:
OS: macOS (x86_64-apple-darwin21.4.0)
CPU: Apple M1 Pro
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, westmere)
julia> S = wrapdims(Symmetric(rand(Int8,3,3)), 'a':'c', 10:10:30)
2-dimensional KeyedArray(...) with keys:
↓ 3-element StepRange{Char,...}
→ 3-element StepRange{Int64,...}
And data, 3×3 Symmetric{Int8, Matrix{Int8}}:
(10) (20) (30)
('a') -37 -122 -2
('b') -122 90 -117
('c') -2 -117 -12
julia> A = copy(S)
2-dimensional KeyedArray(...) with keys:
↓ 3-element StepRange{Char,...}
→ 3-element StepRange{Int64,...}
And data, 3×3 Symmetric{Int8, Matrix{Int8}}:
(10) (20) (30)
('a') -37 -122 -2
('b') -122 90 -117
('c') -2 -117 -12
julia> copyto!(A, S)
ERROR: ArgumentError: Cannot set a non-diagonal index in a symmetric matrix
Stacktrace:
[1] setindex!
@ /Users/julia/buildbot/worker/package_macos64/build/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/symmetric.jl:225 [inlined]
[2] setindex!
@ ~/.julia/packages/AxisKeys/DiXQB/src/struct.jl:132 [inlined]
[3] copyto_unaliased!(deststyle::IndexCartesian, dest::KeyedArray{Int8, 2, Symmetric{Int8, Matrix{Int8}}, Tuple{StepRange{Char, Int64}, StepRange{Int64, Int64}}}, srcstyle::IndexCartesian, src::KeyedArray{Int8, 2, Symmetric{Int8, Matrix{Int8}}, Tuple{StepRange{Char, Int64}, StepRange{Int64, Int64}}})
@ Base ./abstractarray.jl:984
[4] copyto!(dest::KeyedArray{Int8, 2, Symmetric{Int8, Matrix{Int8}}, Tuple{StepRange{Char, Int64}, StepRange{Int64, Int64}}}, src::KeyedArray{Int8, 2, Symmetric{Int8, Matrix{Int8}}, Tuple{StepRange{Char, Int64}, StepRange{Int64, Int64}}})
@ Base ./abstractarray.jl:950
[5] top-level scope
@ REPL[14]:1
julia> @which copyto!(A, S)
copyto!(dest::AbstractArray, src::AbstractArray) in Base at abstractarray.jl:947
Closes #133