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

Julia 1.7.3 breaks Gradient and RF hcat #71

Closed
cncastillo opened this issue Jun 3, 2022 · 2 comments
Closed

Julia 1.7.3 breaks Gradient and RF hcat #71

cncastillo opened this issue Jun 3, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@cncastillo
Copy link
Member

When running a function that uses ;; to concatenate, like:

RF_hard(B1, T, sys::Scanner; G=[0,0,0]) = begin
	ζ = sum(G) / sys.Smax
	EX = Sequence([	Grad(G[1],T,ζ);	 #Gx
					Grad(G[2],T,ζ);  #Gy
					Grad(G[3],T,ζ);;], #Gz
					 [RF(B1,T,0,ζ)]	 #RF
					)
	EX
end

Julia 1.7.3 throws an error:

julia> PulseDesigner.RF_hard(1.,1.,Scanner())
ERROR: MethodError: no method matching size(::Grad, ::Int64)
Closest candidates are:
  size(::Union{LinearAlgebra.QR, LinearAlgebra.QRCompactWY, LinearAlgebra.QRPivoted}, ::Integer) at /opt/julia-1.7.3/share/julia/stdlib/v1.7/LinearAlgebra/src/qr.jl:566
  size(::Union{LinearAlgebra.Cholesky, LinearAlgebra.CholeskyPivoted}, ::Integer) at /opt/julia-1.7.3/share/julia/stdlib/v1.7/LinearAlgebra/src/cholesky.jl:495
  size(::Union{LinearOperators.AdjointLinearOperator, LinearOperators.TransposeLinearOperator}, ::Int64) at ~/.julia/packages/LinearOperators/58FwN/src/adjtrans.jl:63
  ...
Stacktrace:
 [1] _typed_hvncat_dims(#unused#::Type{Grad}, dims::Tuple{Int64, Int64}, row_first::Bool, as::Tuple{Grad, Grad, Grad})
   @ Base ./abstractarray.jl:2328
 [2] _typed_hvncat
   @ ./abstractarray.jl:2304 [inlined]
 [3] _hvncat
   @ ./abstractarray.jl:2133 [inlined]
 [4] hvncat
   @ ./abstractarray.jl:2129 [inlined]
 [5] RF_hard(B1::Float64, T::Float64, sys::Scanner; G::Vector{Int64})
   @ Koma.PulseDesigner ~/Documents/Koma.jl/src/sequences/PulseDesigner.jl:11
 [6] RF_hard(B1::Float64, T::Float64, sys::Scanner)
   @ Koma.PulseDesigner ~/Documents/Koma.jl/src/sequences/PulseDesigner.jl:10
 [7] top-level scope
   @ REPL[3]:1
@cncastillo cncastillo added the bug Something isn't working label Jun 3, 2022
@cncastillo cncastillo changed the title Julia 1.7.3 breaks Gradient hcat Julia 1.7.3 breaks Gradient and RF hcat Jun 3, 2022
@cncastillo
Copy link
Member Author

cncastillo commented Jun 3, 2022

Defining the size of a Grad and RF as 1 fixes the problem:

size(g::Grad, i::Int64) = 1 #In src/datatypes/sequence/Grad.jl
size(r::RF, i::Int64) = 1 #In src/datatypes/sequence/RF.jl

Examples:

julia> [RF(1,1);RF(1,1);;]
2×1 Matrix{RF}:
 RF(1.0e6 uT, 1000.0 ms, 0.0 Hz)
 RF(1.0e6 uT, 1000.0 ms, 0.0 Hz)

julia> [Grad(1,1);Grad(1,1);Grad(1,1);;]
3×1 Matrix{Grad}:
 Grad(1000.0 mT, 1000.0 ms)
 Grad(1000.0 mT, 1000.0 ms)
 Grad(1000.0 mT, 1000.0 ms)

Committing soon.

@cncastillo
Copy link
Member Author

Fixed in aaf1c6e.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant