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

support symbolic arrays #264

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Symbolics_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ end
"Return the name of a variable (excluding independent variables)"
function var_name(x::Num)
var = Symbolics._toexpr(x)
return var isa Expr ? String(var.args[1]) : String(var)
while var isa Expr
try
var = var.args[1]
catch
break
end
end
return String(var)
end
# var_name(x::Term) = String(Symbolics._toexpr(x).args[1])
var_name(x::Sym) = String(x.name)
Expand Down
1 change: 1 addition & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ end
include("powers.jl")
include("harmonics.jl")
include("fourier.jl")
include("symbolic_utils.jl")
end

@testset "IO" begin
Expand Down
6 changes: 6 additions & 0 deletions test/symbolic_utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@testset "Symbolics arrays" begin
using Symbolics, HarmonicBalance
@variables x[1:2]
vars = Symbolics.scalarize(x)
HarmonicBalance.var_name(vars[1])
end
Loading