Skip to content

Commit 79b8772

Browse files
Merge pull request #95 from JuliaDiffEq/hg/rm/const
Remove Constant export and @const
2 parents ebf08cd + 76d841f commit 79b8772

File tree

6 files changed

+6
-35
lines changed

6 files changed

+6
-35
lines changed

src/variables.jl

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
export Variable, Unknown, Parameter, @Unknown, @Param
2+
3+
14
struct Variable <: Expression
25
name::Symbol
36
subtype::Symbol
@@ -7,8 +10,6 @@ end
710
Parameter(name; dependents = Variable[]) = Variable(name, :Parameter, dependents)
811
Unknown(name; dependents = Variable[]) = Variable(name, :Unknown, dependents)
912

10-
export Variable, Unknown, Parameter, Constant, @Unknown, @Param, @Const
11-
1213

1314
struct Constant <: Expression
1415
value::Number
@@ -76,23 +77,3 @@ end
7677
macro Param(xs...)
7778
esc(_parse_vars(:Param, Parameter, xs))
7879
end
79-
80-
function _const_assign(x)
81-
ex = Expr(:block)
82-
lhss = Symbol[]
83-
x = flatten_expr!(x)
84-
for eq in x
85-
@assert eq isa Expr && eq.head == :(=) "@Const expects a tuple of assignments!\nE.g. `@Const D=t W=g`"
86-
lhs = eq.args[1]
87-
push!(lhss, lhs)
88-
rhs = eq.args[2]
89-
expr = :($lhs = Constant($rhs))
90-
push!(ex.args, expr)
91-
end
92-
push!(ex.args, Expr(:tuple, lhss...))
93-
ex
94-
end
95-
96-
macro Const(x...)
97-
esc(_const_assign(x))
98-
end

test/basic_variables_and_operations.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ using Test
44
@Param t σ ρ β
55
@Unknown x(t) y(t) z(t)
66
@Deriv D'~t
7-
@Const c=0
87

98
# Default values
109
p = Parameter(:p)
@@ -15,4 +14,4 @@ D(x)
1514
D(x) ~ -σ*(y-x)
1615
D(y) ~ x*-z)-sin(y)
1716

18-
@test D(t) == Constant(1)
17+
@test D(t) == 1

test/derivatives.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jac = ModelingToolkit.calculate_jacobian(sys)
3838

3939
# Variable dependence checking in differentiation
4040
@Unknown a(t) b(a)
41-
@test D(b) Constant(0)
41+
@test D(b) 0
4242

4343
@test expand_derivatives(D(x * y)) == simplify_constants(y*D(x) + x*D(y))
4444
@test_broken expand_derivatives(D(x * y)) == simplify_constants(D(x)*y + x*D(y))

test/simplify.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ using Test
55
@Unknown x(t) y(t) z(t)
66

77
null_op = 0*t
8-
@test simplify_constants(null_op) == Constant(0)
8+
@test simplify_constants(null_op) == 0
99

1010
one_op = 1*t
1111
@test simplify_constants(one_op) == t

test/system_construction.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ using Test
55
@Param t σ ρ β
66
@Unknown x(t) y(t) z(t)
77
@Deriv D'~t
8-
@Const c=0
98

109
# Define a differential equation
1110
eqs = [D(x) ~ σ*(y-x),

test/variable_parsing.jl

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,3 @@ s1 = Parameter(:s)
3131
D1 = Differential(t, 2)
3232
@test D1 == D
3333
@test convert(Expr, D) == D
34-
35-
@Const c=0 v=2
36-
c1 = Constant(0)
37-
v1 = Constant(2)
38-
@test c1 == c
39-
@test v1 == v
40-
@test convert(Expr, c) == 0
41-
@test convert(Expr, v) == 2

0 commit comments

Comments
 (0)