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

Interop with SymbolicUtils #64

Merged
merged 35 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
c2d64b5
symbolicutils interop
olynch Aug 14, 2024
c11d4dd
added spaces to the sorts of forms and vector fields
olynch Aug 16, 2024
7de10e8
integrated changes to ThDEC with DecaSymbolic
olynch Aug 17, 2024
5928cc7
added tests for decasymbolic, but needs wrinkles ironed out. musical …
quffaro Aug 18, 2024
d7d6a5b
reverted src/DiagX to restore exports and adding Project.toml
quffaro Aug 19, 2024
2f79b0c
Merge remote-tracking branch 'origin/space-sorts' into symbolicutilsi…
quffaro Aug 19, 2024
a438192
updated code and tests after merge from space-sorts
quffaro Aug 19, 2024
18a1585
review changes:
jpfairbanks Aug 21, 2024
090ddfe
resolving some comments from code review.
quffaro Aug 22, 2024
d8be4ae
adding @alias and @register macros to make DecaSymbolic function work…
quffaro Aug 27, 2024
77770e5
experimenting with a type-driven approach
quffaro Aug 28, 2024
1fa477b
adding promote_symtype and addressing some of the code review comment…
quffaro Aug 30, 2024
3b265ac
refactoring @operator to integrate with promote_symtype
quffaro Sep 4, 2024
7f8597a
operator macro parses @rule but need to write tests and iron out rela…
quffaro Sep 5, 2024
154e51f
rewriting just needs tests
quffaro Sep 6, 2024
18bb71f
TST: add some klausmeier rewrites
jpfairbanks Sep 9, 2024
4ba6dce
BUG: fix method shadowing for existing operators like +/-
jpfairbanks Sep 9, 2024
82f65ce
added more tests, @operator macro is more flexible
quffaro Sep 10, 2024
e23459f
Merge pull request #73 from AlgebraicJulia/jpf/symbolictypes
quffaro Sep 10, 2024
e82e826
almost round-tripping in klausmeier. equations are not currently pass…
quffaro Sep 10, 2024
f32b3c0
Merge branch 'cm/symbolictypes' of github.com:AlgebraicJulia/Diagramm…
quffaro Sep 10, 2024
ecfa931
added rules function which dispatches on function symbol and the Val(…
quffaro Sep 10, 2024
4603ed9
fixed docs for @operator, fixed Term
quffaro Sep 11, 2024
f2ef1d0
Merge pull request #71 from AlgebraicJulia/cm/symbolictypes
quffaro Sep 11, 2024
5324de3
Loosened aqua tests
GeorgeR227 Sep 12, 2024
0a314a8
fixing bug where (+) always returns Scalar
quffaro Sep 18, 2024
5d5c25d
Expression level rewriting (#69)
GeorgeR227 Oct 3, 2024
70a420d
added tests for errors and consolidated errors with George
quffaro Oct 3, 2024
85572a4
Fixed hodge nameof and more tests
GeorgeR227 Oct 4, 2024
df41b18
Many more tests
GeorgeR227 Oct 4, 2024
6d1edf0
Merge branch 'main' into symbolicutilsinterop
jpfairbanks Oct 4, 2024
ccf0a79
More tests
GeorgeR227 Oct 5, 2024
467a93c
Remove unused functions
GeorgeR227 Oct 9, 2024
7c5155d
Fixed test in acset2symbolics
GeorgeR227 Oct 9, 2024
4f1f327
Added some improvements to naming
GeorgeR227 Oct 10, 2024
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
1 change: 0 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Catlab = "134e5e36-593f-5add-ad60-77f754baafbe"
DataStructures = "864edb3b-99cc-5e75-8d2d-829cb0a9cfe8"
MLStyle = "d8e11817-5142-5d16-987a-aa16d5891078"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
StructEquality = "6ec83bb0-ed9f-11e9-3b4c-2b04cb4e219c"
SymbolicUtils = "d1185830-fcd6-423d-90d6-eec64667417b"
Unicode = "4ec0a83e-493e-50e2-b9ac-8f72acf5a8f5"
Expand Down
1 change: 1 addition & 0 deletions src/symbolictheoryutils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
function rules end
export rules

# TODO: Probable piracy here
function promote_symtype(f::ComposedFunction, args)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should upstream this method JuliaSymbolics/SymbolicUtils.jl#650

promote_symtype(f.outer, promote_symtype(f.inner, args))

Check warning on line 11 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L10-L11

Added lines #L10 - L11 were not covered by tests
end

@active PatBlock(e) begin
Expand Down Expand Up @@ -76,7 +77,7 @@
ph = @λ begin
Expr(:call, foo, Expr(:(::), vars..., theory)) => (foo, vars, theory)
Expr(:(::), Expr(:call, foo, vars...), theory) => (foo, vars, theory)
_ => error("$head")

Check warning on line 80 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L80

Added line #L80 was not covered by tests
end
(f, types, Theory) = ph(head)

Expand All @@ -102,9 +103,9 @@
argclaus = [:($a::Symbolic) for a in argnames]
push!(result.args, quote
@nospecialize
function $f($(argclaus...))
s = promote_symtype($f, $(argnames...))
SymbolicUtils.Term{s}($f, Any[$(argnames...)])

Check warning on line 108 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L106-L108

Added lines #L106 - L108 were not covered by tests
end
export $f
end)
Expand All @@ -112,20 +113,20 @@
# 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})
[($(rulecalls...))]

Check warning on line 117 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L116-L117

Added lines #L116 - L117 were not covered by tests
end
end)
end

# we want to feed symtype the generics
push!(result.args, quote
function SymbolicUtils.promote_symtype(::typeof($f),

Check warning on line 124 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L124

Added line #L124 was not covered by tests
$(sort_types...)) where {$(sort_constraints...)}
$block

Check warning on line 126 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L126

Added line #L126 was not covered by tests
end
function SymbolicUtils.promote_symtype(::typeof($f), args::Vararg{Symbolic, $arity})
promote_symtype($f, symtype.(args)...)

Check warning on line 129 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L128-L129

Added lines #L128 - L129 were not covered by tests
end
end)

Expand Down Expand Up @@ -157,10 +158,10 @@
Base.nameof(::typeof($alias), s) = Symbol("$alias")
end))
end
result

Check warning on line 161 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L161

Added line #L161 was not covered by tests
end
export @alias

alias(x) = error("$x has no aliases")

Check warning on line 165 in src/symbolictheoryutils.jl

View check run for this annotation

Codecov / codecov/patch

src/symbolictheoryutils.jl#L165

Added line #L165 was not covered by tests
export alias

2 changes: 1 addition & 1 deletion test/aqua.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Aqua, DiagrammaticEquations
@testset "Code quality (Aqua.jl)" begin
# TODO: fix ambiguities
Aqua.test_all(DiagrammaticEquations, ambiguities=false, undefined_exports=false)
Aqua.test_all(DiagrammaticEquations, ambiguities=false, undefined_exports=false, piracies=false)
end
Loading