Skip to content

Commit ea836eb

Browse files
Merge pull request #1388 from abhro/patch-1
Documentation updates
2 parents 26c4ff7 + 4a37ed9 commit ea836eb

File tree

12 files changed

+82
-84
lines changed

12 files changed

+82
-84
lines changed

docs/src/manual/functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Note that at this time array derivatives cannot be defined.
151151

152152
## Direct Registration API (Advanced, Experimental)
153153

154-
!!! warn
154+
!!! warning
155155

156156
This is a lower level API which is not as stable as the macro APIs.
157157

docs/src/manual/parsing.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ to convert from Julia expressions to Symbolics.jl expressions for further
77
manipulation. Towards this end is the `parse_expr_to_symbolic` which performs
88
the parsing.
99

10-
!!! warn
10+
!!! warning
1111
Take the limitations mentioned in the `parse_expr_to_symbolic` docstrings
1212
seriously! Because Julia expressions contain no symbolic metadata, there
13-
is limited information and thus the parsing requires heuristics to work.
13+
is limited information and thus the parsing requires heuristics to work.
1414

1515
```@docs
1616
parse_expr_to_symbolic

src/Symbolics.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ include("complex.jl")
6868
6969
Performs the substitution on `expr` according to rule(s) `s`.
7070
# Examples
71-
```julia
71+
```jldoctest
7272
julia> @variables t x y z(t)
7373
4-element Vector{Num}:
7474
t

src/arrays.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ end
426426
"""
427427
shape(s::Any)
428428
429-
Returns `axes(s)` or Unknown().
429+
Returns `axes(s)` or `Unknown()`.
430430
"""
431431
shape(s) = axes(s)
432432

src/build_function.jl

Lines changed: 54 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,14 @@ function throw_missing_specialization(n)
3434
end
3535

3636
"""
37-
`build_function`
37+
build_function(ex, args...;
38+
expression = Val{true},
39+
target = JuliaTarget(),
40+
parallel=nothing,
41+
kwargs...)
3842
3943
Generates a numerically-usable function from a Symbolics `Num`.
4044
41-
```julia
42-
build_function(ex, args...;
43-
expression = Val{true},
44-
target = JuliaTarget(),
45-
parallel=nothing,
46-
kwargs...)
47-
```
48-
4945
Arguments:
5046
5147
- `ex`: The `Num` to compile
@@ -220,16 +216,16 @@ end
220216
Build function target: `JuliaTarget`
221217
222218
```julia
223-
function _build_function(target::JuliaTarget, rhss, args...;
224-
conv = toexpr,
225-
expression = Val{true},
226-
checkbounds = false,
227-
linenumbers = false,
228-
headerfun = addheader, outputidxs=nothing,
229-
convert_oop = true, force_SA = false,
230-
skipzeros = outputidxs===nothing,
231-
fillzeros = skipzeros && !(typeof(rhss)<:SparseMatrixCSC),
232-
parallel=SerialForm(), kwargs...)
219+
_build_function(target::JuliaTarget, rhss, args...;
220+
conv = toexpr,
221+
expression = Val{true},
222+
checkbounds = false,
223+
linenumbers = false,
224+
headerfun = addheader, outputidxs=nothing,
225+
convert_oop = true, force_SA = false,
226+
skipzeros = outputidxs===nothing,
227+
fillzeros = skipzeros && !(typeof(rhss)<:SparseMatrixCSC),
228+
parallel=SerialForm(), kwargs...)
233229
```
234230
235231
Generates a Julia function which can then be utilized for further evaluations.
@@ -676,11 +672,11 @@ end
676672
Build function target: `CTarget`
677673
678674
```julia
679-
function _build_function(target::CTarget, eqs::Array{<:Equation}, args...;
680-
conv = toexpr, expression = Val{true},
681-
fname = :diffeqf,
682-
lhsname=:du,rhsnames=[Symbol("RHS\$i") for i in 1:length(args)],
683-
libpath=tempname(),compiler=:gcc)
675+
_build_function(target::CTarget, eqs::Array{<:Equation}, args...;
676+
conv = toexpr, expression = Val{true},
677+
fname = :diffeqf,
678+
lhsname=:du,rhsnames=[Symbol("RHS\$i") for i in 1:length(args)],
679+
libpath=tempname(), compiler=:gcc)
684680
```
685681
686682
This builds an in-place C function. Only works on arrays of equations. If
@@ -689,7 +685,7 @@ and returns a lambda to that compiled function. These special keyword arguments
689685
control the compilation:
690686
691687
- libpath: the path to store the binary. Defaults to a temporary path.
692-
- compiler: which C compiler to use. Defaults to :gcc, which is currently the
688+
- compiler: which C compiler to use. Defaults to `:gcc`, which is currently the
693689
only available option.
694690
"""
695691
function _build_function(target::CTarget, eqs::Array{<:Equation}, args...;
@@ -736,15 +732,15 @@ end
736732
Build function target: `CTarget`
737733
738734
```julia
739-
function _build_function(target::CTarget, ex::AbstractArray, args...;
740-
columnmajor = true,
741-
conv = toexpr,
742-
expression = Val{true},
743-
fname = :diffeqf,
744-
lhsname = :du,
745-
rhsnames = [Symbol("RHS\$i") for i in 1:length(args)],
746-
libpath = tempname(),
747-
compiler = :gcc)
735+
_build_function(target::CTarget, ex::AbstractArray, args...;
736+
columnmajor = true,
737+
conv = toexpr,
738+
expression = Val{true},
739+
fname = :diffeqf,
740+
lhsname = :du,
741+
rhsnames = [Symbol("RHS\$i") for i in 1:length(args)],
742+
libpath = tempname(),
743+
compiler = :gcc)
748744
```
749745
750746
This builds an in-place C function. Only works on expressions. If
@@ -823,14 +819,14 @@ _build_function(target::CTarget, ex::Num, args...; kwargs...) = _build_function(
823819
Build function target: `StanTarget`
824820
825821
```julia
826-
function _build_function(target::StanTarget, eqs::Array{<:Equation}, vs, ps, iv;
827-
conv = toexpr, expression = Val{true},
828-
fname = :diffeqf, lhsname=:internal_var___du,
829-
rhsnames=[:internal_var___u,:internal_var___p,:internal_var___t])
822+
_build_function(target::StanTarget, eqs::Array{<:Equation}, vs, ps, iv;
823+
conv = toexpr, expression = Val{true},
824+
fname = :diffeqf, lhsname=:internal_var___du,
825+
rhsnames=[:internal_var___u,:internal_var___p,:internal_var___t])
830826
```
831827
832828
This builds an in-place Stan function compatible with the Stan differential equation solvers.
833-
Unlike other build targets, this one requires (vs, ps, iv) as the function arguments.
829+
Unlike other build targets, this one requires `(vs, ps, iv)` as the function arguments.
834830
Only allowed on arrays of equations.
835831
"""
836832
function _build_function(target::StanTarget, eqs::Array{<:Equation}, vs, ps, iv;
@@ -862,16 +858,16 @@ end
862858
Build function target: `StanTarget`
863859
864860
```julia
865-
function _build_function(target::StanTarget, ex::AbstractArray, vs, ps, iv;
866-
columnmajor = true,
867-
conv = toexpr,
868-
expression = Val{true},
869-
fname = :diffeqf, lhsname=:internal_var___du,
870-
rhsnames = [:internal_var___u,:internal_var___p,:internal_var___t])
861+
_build_function(target::StanTarget, ex::AbstractArray, vs, ps, iv;
862+
columnmajor = true,
863+
conv = toexpr,
864+
expression = Val{true},
865+
fname = :diffeqf, lhsname=:internal_var___du,
866+
rhsnames = [:internal_var___u,:internal_var___p,:internal_var___t])
871867
```
872868
873869
This builds an in-place Stan function compatible with the Stan differential equation solvers.
874-
Unlike other build targets, this one requires (vs, ps, iv) as the function arguments.
870+
Unlike other build targets, this one requires `(vs, ps, iv)` as the function arguments.
875871
Only allowed on expressions, and arrays of expressions.
876872
"""
877873
function _build_function(target::StanTarget, ex::AbstractArray, vs, ps, iv;
@@ -920,13 +916,13 @@ _build_function(target::StanTarget, ex::Num, vs, ps, iv; kwargs...) = _build_fun
920916
Build function target: `MATLABTarget`
921917
922918
```julia
923-
function _build_function(target::MATLABTarget, eqs::Array{<:Equation}, args...;
924-
conv = toexpr, expression = Val{true},
925-
lhsname=:internal_var___du,
926-
rhsnames=[:internal_var___u,:internal_var___p,:internal_var___t])
919+
_build_function(target::MATLABTarget, eqs::Array{<:Equation}, args...;
920+
conv = toexpr, expression = Val{true},
921+
lhsname=:internal_var___du,
922+
rhsnames=[:internal_var___u,:internal_var___p,:internal_var___t])
927923
```
928924
929-
This builds an out of place anonymous function @(t,rhsnames[1]) to be used in MATLAB.
925+
This builds an out of place anonymous function `@(t,rhsnames[1])` to be used in MATLAB.
930926
Compatible with the MATLAB differential equation solvers. Only allowed on expressions,
931927
and arrays of expressions.
932928
"""
@@ -953,13 +949,13 @@ end
953949
Build function target: `MATLABTarget`
954950
955951
```julia
956-
function _build_function(target::MATLABTarget, ex::AbstractArray, args...;
957-
columnmajor = true,
958-
conv = toexpr,
959-
expression = Val{true},
960-
fname = :diffeqf,
961-
lhsname = :internal_var___du,
962-
rhsnames = [:internal_var___u,:internal_var___p,:internal_var___t])
952+
_build_function(target::MATLABTarget, ex::AbstractArray, args...;
953+
columnmajor = true,
954+
conv = toexpr,
955+
expression = Val{true},
956+
fname = :diffeqf,
957+
lhsname = :internal_var___du,
958+
rhsnames = [:internal_var___u,:internal_var___p,:internal_var___t])
963959
```
964960
965961
This builds an out of place anonymous function @(t,rhsnames[1]) to be used in MATLAB.

src/diff.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ and other derivative rules to expand any derivatives it encounters.
170170
```jldoctest
171171
julia> @variables x y z k;
172172
173-
julia> f=k*(abs(x-y)/y-z)^2
173+
julia> f = k*(abs(x-y)/y-z)^2
174174
k*((abs(x - y) / y - z)^2)
175175
176-
julia> Dx=Differential(x) # Differentiate wrt x
176+
julia> Dx = Differential(x) # Differentiate wrt x
177177
(::Differential) (generic function with 2 methods)
178178
179-
julia> dfx=expand_derivatives(Dx(f))
179+
julia> dfx = expand_derivatives(Dx(f))
180180
(k*((2abs(x - y)) / y - 2z)*IfElse.ifelse(signbit(x - y), -1, 1)) / y
181181
```
182182
"""

src/linear_algebra.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ Currently only works if all equations are linear. `check` if the expr is linear
8383
w.r.t `vars`.
8484
8585
# Examples
86-
```julia
86+
```jldoctest
8787
julia> @variables x y
8888
2-element Vector{Num}:
8989
x

src/operators.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ end
3232
Get the time (in seconds) spent in a state in a finite state machine.
3333
3434
When used to query the time spent in the enclosing state, the method without arguments is used, i.e.,
35-
```
35+
```julia
3636
@mtkmodel FSM begin
3737
...
3838
@equations begin
@@ -56,7 +56,7 @@ timeInState
5656
Get the number of ticks spent in a state in a finite state machine.
5757
5858
When used to query the number of ticks spent in the enclosing state, the method without arguments is used, i.e.,
59-
```
59+
```julia
6060
@mtkmodel FSM begin
6161
...
6262
@equations begin

src/rewrite-helpers.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
2-
replacenode(expr::Symbolic, rules...)
2+
replacenode(expr::Symbolic, rules...)
3+
34
Walk the expression and replacenode subexpressions according to `rules`. `rules`
45
could be rules constructed with `@rule`, a function, or a pair where the
56
left hand side is matched with equality (using `isequal`) and is replacenoded by the right hand side.
@@ -75,7 +76,8 @@ function _hasnode(r, y)
7576
end
7677

7778
"""
78-
filterchildren(c, x)
79+
filterchildren(c, x)
80+
7981
Returns all parts of `x` that fulfills the condition given in c. c can be a function or an expression.
8082
If it is a function, returns everything for which the function is `true`. If c is an expression, returns
8183
all expressions that matches it.

src/taylor.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Return the power series in `x` around `x0` to the powers `ns` with coefficients
1010
Examples
1111
========
1212
13-
```julia
13+
```jldoctest
1414
julia> @variables x y[0:3] z
1515
3-element Vector{Any}:
1616
x
@@ -47,7 +47,7 @@ Calculate the `n`-th order coefficient(s) in the Taylor series of `f` around `x
4747
4848
Examples
4949
========
50-
```julia
50+
```jldoctest
5151
julia> @variables x y
5252
2-element Vector{Num}:
5353
x
@@ -101,7 +101,7 @@ If `rationalize`, float coefficients are approximated as rational numbers (this
101101
102102
Examples
103103
========
104-
```julia
104+
```jldoctest
105105
julia> @variables x
106106
1-element Vector{Num}:
107107
x

0 commit comments

Comments
 (0)