Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
57dc9d0
refactor: remove trivial usages of `Symbolic{T}`
AayushSabharwal Sep 15, 2025
48299c5
refactor: remove `ComplexTerm`
AayushSabharwal Sep 15, 2025
da22d7c
refactor: remove `CallWithMetadata`
AayushSabharwal Sep 15, 2025
b0336cf
refactor: remove array variants
AayushSabharwal Sep 15, 2025
dde5ad0
refactor: remove redundant `symbolic_type` methods
AayushSabharwal Sep 15, 2025
1cc3fd6
refactor: remove usages of `Polyform`
AayushSabharwal Sep 15, 2025
7950e98
feat: make `vartype` of variables a preference
AayushSabharwal Sep 16, 2025
741c711
refactor: use `@syms` parsing for `@variables`
AayushSabharwal Sep 16, 2025
e49881f
refactor: update `@wrapped` macro
AayushSabharwal Sep 16, 2025
a50ad29
refactor: update `@register_symbolic`
AayushSabharwal Sep 16, 2025
9120aa6
refactor: update `@register_array_symbolic`
AayushSabharwal Sep 16, 2025
54cb468
fix: use `SymbolicUtils.unwrap`
AayushSabharwal Sep 16, 2025
667f2d9
fix: validate default size in `setdefaultval`
AayushSabharwal Sep 16, 2025
563a84d
refactor: remove old `_getname`, implement `SII.getname` properly
AayushSabharwal Sep 16, 2025
3af56f5
fix: handle indexed symbolics in `getdefaultval`
AayushSabharwal Sep 16, 2025
949e9e7
fix: fix `Symbolics.variable`
AayushSabharwal Sep 16, 2025
9caff1b
refactor: remove `get_variables!` implementations
AayushSabharwal Sep 16, 2025
986bb09
feat: implement `SymbolicUtils.search_variables!`
AayushSabharwal Sep 16, 2025
73e4461
refactor: make `Arr` store `BasicSymbolic{T}`
AayushSabharwal Sep 18, 2025
a0e9fd3
fix: fix `build_function` codegen for arrayop
AayushSabharwal Sep 18, 2025
44080e8
fix: fix `scalarize` for `Equation`
AayushSabharwal Sep 18, 2025
45b25ab
fix: fix `scalarize` for `Inequality`
AayushSabharwal Sep 18, 2025
2df0100
fix: store `BasicSymbolic{T}` in `Num`
AayushSabharwal Sep 18, 2025
588b038
refactor: do not pirate `Base.Symbol(::BasicSymbolic)`
AayushSabharwal Sep 18, 2025
8150ecf
fix: remove use of deprecated `children`
AayushSabharwal Sep 18, 2025
531c294
refactor: remove `Symbolics.Unknown`
AayushSabharwal Sep 18, 2025
376a8fa
refactor: move `Operator` to `SymbolicUtils`
AayushSabharwal Sep 18, 2025
e79bdfa
refactor: fix `scalarize` for `Num`, `Complex{Num}`
AayushSabharwal Sep 18, 2025
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
4 changes: 4 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LogExpFunctions = "2ab3a3ac-af41-5b50-aa03-7779005ae688"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Moshi = "2e0e35c7-a2e4-4343-998d-7ef72827ed2d"
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
OffsetArrays = "6fe1bfb0-de20-5000-8ca7-80f57d26f881"
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Primes = "27ebfcd6-29c5-5fa9-bf4b-fb8fc14df3ae"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
Expand Down Expand Up @@ -84,12 +86,14 @@ Latexify = "0.16"
LogExpFunctions = "0.3"
Lux = "1"
MacroTools = "0.5"
Moshi = "0.3.7"
NaNMath = "1"
Nemo = "0.46, 0.47, 0.48, 0.49, 0.52"
OffsetArrays = "1.15.0"
PkgBenchmark = "0.2"
PreallocationTools = "0.4"
PrecompileTools = "1"
Preferences = "1.5.0"
Primes = "0.5"
RecipesBase = "1.1"
Reexport = "1"
Expand Down
32 changes: 24 additions & 8 deletions src/Symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ import DomainSets: Domain, DomainSets
using TermInterface
import TermInterface: maketerm, iscall, operation, arguments, metadata

import SymbolicUtils: Term, Add, Mul, Pow, Sym, Div, BasicSymbolic,
FnType, @rule, Rewriters, substitute, symtype,
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv
import SymbolicUtils: Term, Add, Mul, Sym, Div, BasicSymbolic, Const,
FnType, @rule, Rewriters, substitute, symtype, shape, unwrap, unwrap_const,
promote_symtype, isadd, ismul, ispow, isterm, issym, isdiv, BSImpl, scalarize,
Operator

using SymbolicUtils.Code

Expand All @@ -54,6 +55,23 @@ RuntimeGeneratedFunctions.init(@__MODULE__)

import SciMLPublic: @public

using Moshi.Match: @match

import Preferences: @load_preference

const DEFAULT_VARTYPE_PREF = @load_preference("vartype", "SymReal")
const VartypeT = @static if DEFAULT_VARTYPE_PREF == "SymReal"
SymReal
elseif DEFAULT_VARTYPE_PREF == "SafeReal"
SafeReal
elseif DEFAULT_VARTYPE_PREF == "TreeReal"
TreeReal
else
error("""
Invalid vartype preference: $DEFAULT_VARTYPE_PREF. Must be one of "SymReal", \
"SafeReal" or "TreeReal".
""")
end
# re-export

export simplify, substitute
Expand Down Expand Up @@ -177,7 +195,7 @@ export limit

# Hacks to make wrappers "nicer"
const NumberTypes = Union{AbstractFloat,Integer,Complex{<:AbstractFloat},Complex{<:Integer}}
(::Type{T})(x::SymbolicUtils.Symbolic) where {T<:NumberTypes} = throw(ArgumentError("Cannot convert Sym to $T since Sym is symbolic and $T is concrete. Use `substitute` to replace the symbolic unwraps."))
(::Type{T})(x::SymbolicUtils.BasicSymbolic) where {T<:NumberTypes} = throw(ArgumentError("Cannot convert Sym to $T since Sym is symbolic and $T is concrete. Use `substitute` to replace the symbolic unwraps."))
for T in [Num, Complex{Num}]
@eval begin
#(::Type{S})(x::$T) where {S<:Union{NumberTypes,AbstractArray}} = S(Symbolics.unwrap(x))::S
Expand All @@ -196,9 +214,7 @@ for T in [Num, Complex{Num}]
SymbolicUtils.hasmetadata(x::$T, t) = SymbolicUtils.hasmetadata(unwrap(x), t)

Broadcast.broadcastable(x::$T) = x
end
for S in [:(Symbolic{<:FnType}), :CallWithMetadata]
@eval (f::$S)(x::$T, y...) = wrap(f(unwrap(x), unwrap.(y)...))
SymbolicUtils.scalarize(x::$T) = scalarize(unwrap(x))
end
end

Expand Down Expand Up @@ -545,7 +561,7 @@ include("inverse.jl")
export rootfunction, left_continuous_function, right_continuous_function, @register_discontinuity
include("discontinuities.jl")

@public Arr, CallWithMetadata, NAMESPACE_SEPARATOR, Unknown, VariableDefaultValue, VariableSource
@public Arr, NAMESPACE_SEPARATOR, Unknown, VariableDefaultValue, VariableSource
@public _parse_vars, derivative, gradient, jacobian, sparsejacobian, hessian, sparsehessian
@public get_variables, get_variables!, get_differential_vars, getparent, option_to_metadata_type, scalarize, shape
@public unwrap, variable, wrap
Expand Down
Loading
Loading