Skip to content

Commit 212027c

Browse files
authored
fix: Symbolics Differential(::Number) (#28)
1 parent 4a4ce7d commit 212027c

File tree

4 files changed

+26
-9
lines changed

4 files changed

+26
-9
lines changed

.github/workflows/Downstream.yml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
name: IntegrationTest
22
on:
33
push:
4-
branches: [main]
5-
tags: [v*]
4+
tags:
5+
- '*'
6+
branches:
7+
- 'main'
68
pull_request:
7-
9+
branches:
10+
- 'main'
11+
concurrency:
12+
# Skip intermediate builds: always.
13+
# Cancel intermediate builds: only if it is a pull request build.
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}
16+
817
jobs:
918
test:
1019
name: ${{ matrix.package.repo }}/${{ matrix.julia-version }}

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
1313
[compat]
1414
DocStringExtensions = "0.9.4"
1515
SymbolicUtils = "3.25"
16-
Symbolics = "~6.34"
16+
Symbolics = "6.34"
1717
julia = "1.10"
1818
Random = "1.10"
1919
LinearAlgebra = "1.10"

src/Symbolics/Symbolics_utils.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,14 @@ Perform substitutions in `rules` on `x`.
4949
Subtype = Union{Num,Equation,BasicSymbolic}
5050
function substitute_all(x::Subtype, rules::Dict; include_derivatives=true)
5151
if include_derivatives
52-
rules = merge(
53-
rules,
54-
Dict([Differential(var) => Differential(rules[var]) for var in keys(rules)]),
55-
)
52+
drules = Pair[]
53+
for var in keys(rules)
54+
if !isa(rules[var], Union{AbstractFloat,Integer})
55+
pair = Differential(var) => Differential(rules[var])
56+
push!(drules, pair)
57+
end
58+
end
59+
rules = merge(rules, Dict(drules))
5660
end
5761
return substitute(x, rules)
5862
end

test/HarmonicVariable.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,11 @@ end
6969
result = substitute_all(eq, rules)
7070
@eqtest result == new_var^2 + ω
7171

72-
# Test variable substitution
72+
# Test number substitution
7373
new_hv = substitute_all(hv, Dict(ω => 2))
7474
@test new_hv.ω == 2
75+
76+
# Test variable substitution
77+
new_hv = substitute_all(hv, Dict(ω => new_var))
78+
@test isequal(new_hv.ω, new_var)
7579
end

0 commit comments

Comments
 (0)