raise TypeError("Cannot convert expression to float") when assigning SymPy expression to an array · Issue #481 · JuliaPy/SymPy.jl · GitHub
Skip to content

raise TypeError("Cannot convert expression to float") when assigning SymPy expression to an array #481

Description

@xiang-yu

julia> @syms x, y
julia> xx = zeros(2,2)
julia> xx[1, 1] = x*y
ERROR: PyError (ccall(#= /Users/lixi307/.julia/packages/PyCall/ygXW2/src/conversions.jl:59 =# @pysym(:PyFloat_AsDouble), Cdouble, (PyPtr,), po)) <class 'TypeError'>
TypeError('Cannot convert expression to float')

If I define "xx" in type "Any"
xx = Array{Any}(undef, 2,2)
julia> xx[1, 1] = x*y
x⋅y

However, I need a zeros instead of "undef". How to initialise a zero symbolic array using SymPy.jl?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions