Skip to content

Commit c044ea1

Browse files
Remove unused fields from Variable
1 parent 0097578 commit c044ea1

File tree

2 files changed

+4
-24
lines changed

2 files changed

+4
-24
lines changed

src/differentials.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@ function (D::Differential)(x::Variable)
1616
end
1717
Base.:(==)(D1::Differential, D2::Differential) = D1.order == D2.order && D1.x == D2.x
1818

19-
Variable(x::Variable, D::Differential) = Variable(x.name,x.value_type,
20-
x.subtype,D,x.dependents,x.description,x.flow,x.domain,
21-
x.size,x.context)
19+
Variable(x::Variable, D::Differential) = Variable(x.name, x.subtype, D, x.dependents)
2220

2321
function expand_derivatives(O::Operation)
2422
@. O.args = expand_derivatives(O.args)

src/variables.jl

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,12 @@
11
mutable struct Variable <: Expression
22
name::Symbol
3-
value_type::DataType
43
subtype::Symbol
54
diff::Union{Function,Nothing} # FIXME
65
dependents::Vector{Variable}
7-
description::String
8-
flow::Bool
9-
domain::AbstractDomain
10-
size
11-
context
126
end
137

14-
Variable(name,
15-
value_type = Any;
16-
subtype::Symbol=:Variable,
17-
dependents::Vector{Variable} = Variable[],
18-
flow::Bool = false,
19-
description::String = "",
20-
domain = Reals(),
21-
size = nothing,
22-
context = nothing) =
23-
Variable(name,value_type,subtype,nothing,
24-
dependents,description,flow,domain,size,context)
8+
Variable(name; subtype::Symbol=:Variable, dependents::Vector{Variable} = Variable[]) =
9+
Variable(name, subtype, nothing, dependents)
2510
Variable(name,args...;kwargs...) = Variable(name,args...;subtype=:Variable,kwargs...)
2611

2712
Variable(name,x::Variable) = Variable(name,x.value_type,
@@ -71,10 +56,7 @@ Base.isone(ex::Expression) = isa(ex, Constant) && isone(ex.value)
7156

7257

7358
# Variables use isequal for equality since == is an Operation
74-
function Base.:(==)(x::Variable, y::Variable)
75-
x.name == y.name && x.subtype == y.subtype &&
76-
x.value_type == y.value_type && x.diff == y.diff
77-
end
59+
Base.:(==)(x::Variable, y::Variable) = (x.name, x.subtype, x.diff) == (y.name, y.subtype, y.diff)
7860
Base.:(==)(::Variable, ::Number) = false
7961
Base.:(==)(::Number, ::Variable) = false
8062
Base.:(==)(::Variable, ::Constant) = false

0 commit comments

Comments
 (0)