Skip to content

Commit 6bd13d5

Browse files
Merge pull request #303 from SciML/symbol
automatic symbol conversions
2 parents 8e671e2 + 497d10e commit 6bd13d5

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ p = [σ => 28.0,
5353
tspan = (0.0,100.0)
5454
prob = ODEProblem(sys,u0,tspan,p,jac=true)
5555
sol = solve(prob,Tsit5())
56-
using Plots; plot(sol,vars=(:x,:y))
56+
using Plots; plot(sol,vars=(x,y))
5757
```
5858

5959
![Lorenz2](https://user-images.githubusercontent.com/1814174/79118645-744eb580-7d5c-11ea-9c37-13c4efd585ca.png)
@@ -101,7 +101,7 @@ tspan = (0.0,100.0)
101101
prob = ODEProblem(connected,u0,tspan,p)
102102
sol = solve(prob,Rodas5())
103103

104-
using Plots; plot(sol,vars=(,Symbol(lorenz1.x),Symbol(lorenz2.y)))
104+
using Plots; plot(sol,vars=(α,lorenz1.x,lorenz2.y))
105105
```
106106

107-
![](https://user-images.githubusercontent.com/1814174/79122361-6fdaca80-7d65-11ea-87fd-0f6c4a85cd0d.png)
107+
![](https://user-images.githubusercontent.com/1814174/79222641-eb9c4c00-7e25-11ea-9a76-256f132ca7aa.png)

src/operations.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ Base.convert(::Type{Operation}, x::Number) = Operation(identity, Expression[Cons
6262
Base.convert(::Type{Operation}, x::Operation) = x
6363
Base.convert(::Type{Operation}, x::Expression) = Operation(identity, Expression[x])
6464
Operation(x) = convert(Operation, x)
65+
Base.Symbol(O::Operation) = Symbol(convert(Variable,O))
66+
Base.convert(::Type{Symbol},O::Operation) = Symbol(convert(Variable,O))
6567

6668
#convert to Expr
6769
Base.Expr(op::Operation) = simplified_expr(op)

0 commit comments

Comments
 (0)