Skip to content

Operation times a sparse array errors #381

@caryan

Description

@caryan

Using ModelingToolkit v3.4.0 and julia 1.4.0 I'm trying to multiply an operation by a sparse array and not having any luck:

julia> using ModelingToolkit

julia> using SparseArrays: sparse

julia> @parameters ω
(ω,)

julia> X = Float64[[0 1]; [1 0]]
2×2 Array{Float64,2}:
 0.0  1.0
 1.0  0.0

julia> ω.*sparse(X)
ERROR: TypeError: non-boolean (Operation) used in boolean context
Stacktrace:
 [1] _map_notzeropres!(::SparseArrays.HigherOrderFns.var"#3#4"{typeof(*),SparseArrays.HigherOrderFns.var"#17#20"{Operation,SparseArrays.HigherOrderFns.var"#21#24"}}, ::Operation, ::SparseArrays.SparseMatrixCSC{Operation,Int64}, ::SparseArrays.SparseMatrixCSC{Float64,Int64}) at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:271
 [2] _noshapecheck_map(::SparseArrays.HigherOrderFns.var"#3#4"{typeof(*),SparseArrays.HigherOrderFns.var"#17#20"{Operation,SparseArrays.HigherOrderFns.var"#21#24"}}, ::SparseArrays.SparseMatrixCSC{Float64,Int64}) at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:165
 [3] _shapecheckbc at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:1025 [inlined]
 [4] _copy at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:1015 [inlined]
 [5] _copy at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:1020 [inlined]
 [6] copy at /home/cryan/repos/julia/usr/share/julia/stdlib/v1.4/SparseArrays/src/higherorderfns.jl:1011 [inlined]
 [7] materialize(::Base.Broadcast.Broadcasted{SparseArrays.HigherOrderFns.SparseMatStyle,Nothing,typeof(*),Tuple{Operation,SparseArrays.SparseMatrixCSC{Float64,Int64}}}) at ./broadcast.jl:820
 [8] top-level scope at REPL[12]:1

julia> 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions