Skip to content

Commit

Permalink
variable(.., T=FnType) and at variables should be consistent
Browse files Browse the repository at this point in the history
  • Loading branch information
YingboMa committed Jan 17, 2024
1 parent 493e276 commit 2b70992
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -471,11 +471,11 @@ Also see `variables`.
"""
function variable(name, idx...; T=Real)
name_ij = Symbol(name, join(map_subscripts.(idx), "ˏ"))
v = Sym{T}(name_ij)
if T <: FnType
first(@variables $name_ij(..))
else
first(@variables $name_ij::T)
v = CallWithMetadata(v)
end
Num(setmetadata(v, VariableSource, (:variables, name_ij)))
end

##### Renaming #####
Expand Down
7 changes: 7 additions & 0 deletions test/macro.jl
Original file line number Diff line number Diff line change
Expand Up @@ -158,3 +158,10 @@ let
@test foo(x) isa Num
@test foo(unwrap(x)) isa BasicSymbolic
end

@variables t y(t)
yy = Symbolics.variable(:y, T = Symbolics.FnType{Tuple{Any}, Real})
yyy = yy(Symbolics.value(t))
@test isequal(yyy, y)
@test yyy isa Num
@test y isa Num

0 comments on commit 2b70992

Please sign in to comment.