Skip to content

Commit

Permalink
fixed docs for @operator, fixed Term
Browse files Browse the repository at this point in the history
  • Loading branch information
quffaro committed Sep 11, 2024
1 parent ecfa931 commit 4603ed9
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/SymbolicUtilsInterop.jl
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ function decapodes.Term(t::SymbolicUtils.BasicSymbolic)
elseif op == ∂ₜ
decapodes.Tan(only(termargs))
elseif length(args) == 1
decapodes.App1(nameof(op, args...), termargs...)
decapodes.App1(nameof(op, symtype.(args)...), termargs...)
elseif length(args) == 2
decapodes.App2(nameof(op, args...), termargs...)
decapodes.App2(nameof(op, symtype.(args)...), termargs...)
else
error("was unable to convert $t into a Term")
end
Expand Down
3 changes: 2 additions & 1 deletion src/symbolictheoryutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ end
```
as well as
```
foo(S1, S2, ...) where {T1<:ThDEC, ...}
foo(S1, S2, ...) where {S1<:DECQuantity, ...}
s = promote_symtype(f, S1, S2, ...)
SymbolicUtils.Term{s}(foo, [S1, S2, ...])
end
Expand Down Expand Up @@ -109,6 +109,7 @@ macro operator(head, body)
export $f
end)

# if there are rewriting rules, add a method which accepts the function symbol and its arity (to prevent shadowing on operators like `-`)
if !isempty(rulecalls)
push!(result.args, quote
function rules(::typeof($f), ::Val{$arity})
Expand Down
6 changes: 1 addition & 5 deletions test/decasymbolic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ u, v = @syms u::PrimalForm{0, :X, 2} du::PrimalForm{1, :X, 2}
@test Term(1) == Lit(Symbol("1"))
@test Term(a) == Var(:a)
@test Term(∂ₜ(u)) == Tan(Var(:u))
@test_broken Term((ω)) == App1(:₁, Var())
# @test_broken Term(ThDEC.♭(ψ)) == App1(:♭s, Var(:ψ))
# @test Term(DiagrammaticEquations.ThDEC.♯(du))

# @test_throws ThDEC.SortError ThDEC.⋆(ϕ)
@test Term((ω)) == App1(:★₁, Var())

# test binary operator conversion to decaexpr
@test Term(a + b) == Plus(Term[Var(:a), Var(:b)])
Expand Down

0 comments on commit 4603ed9

Please sign in to comment.