Skip to content

Commit

Permalink
Add doctests
Browse files Browse the repository at this point in the history
  • Loading branch information
abhro committed Dec 15, 2024
1 parent 30c80db commit 4a37ed9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Symbolics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ include("complex.jl")
Performs the substitution on `expr` according to rule(s) `s`.
# Examples
```julia
```jldoctest
julia> @variables t x y z(t)
4-element Vector{Num}:
t
Expand Down
2 changes: 1 addition & 1 deletion src/linear_algebra.jl
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Currently only works if all equations are linear. `check` if the expr is linear
w.r.t `vars`.
# Examples
```julia
```jldoctest
julia> @variables x y
2-element Vector{Num}:
x
Expand Down
6 changes: 3 additions & 3 deletions src/taylor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Return the power series in `x` around `x0` to the powers `ns` with coefficients
Examples
========
```julia
```jldoctest
julia> @variables x y[0:3] z
3-element Vector{Any}:
x
Expand Down Expand Up @@ -47,7 +47,7 @@ Calculate the `n`-th order coefficient(s) in the Taylor series of `f` around `x
Examples
========
```julia
```jldoctest
julia> @variables x y
2-element Vector{Num}:
x
Expand Down Expand Up @@ -101,7 +101,7 @@ If `rationalize`, float coefficients are approximated as rational numbers (this
Examples
========
```julia
```jldoctest
julia> @variables x
1-element Vector{Num}:
x
Expand Down
10 changes: 5 additions & 5 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ Return a vector of variables appearing in `e`, optionally restricting to variabl
Note that the returned variables are not wrapped in the `Num` type.
# Examples
```julia
```jldoctest
julia> @variables t x y z(t);
julia> Symbolics.get_variables(x + y + sin(z); sort = true)
Expand Down Expand Up @@ -97,7 +97,7 @@ Convert a differential variable to a `Term`. Note that it only takes a `Term`
not a `Num`.
Any upstream metadata can be passed via `x_metadata`
```julia
```jldoctest
julia> @variables x t u(x, t) z(t)[1:2]; Dt = Differential(t); Dx = Differential(x);
julia> Symbolics.diff2term(Symbolics.value(Dx(Dt(u))))
Expand Down Expand Up @@ -156,7 +156,7 @@ it will only output `y` instead of `y(t)`.
# Examples
```julia
```jldoctest
julia> @variables t z(t)
2-element Vector{Num}:
t
Expand Down Expand Up @@ -251,7 +251,7 @@ Extract the degree of `p` with respect to `sym`.
# Examples
```julia
```jldoctest
julia> @variables x;
julia> Symbolics.degree(x^0)
Expand Down Expand Up @@ -305,7 +305,7 @@ Note that `p` might need to be expanded and/or simplified with `expand` and/or `
# Examples
```julia
```jldoctest
julia> @variables a x y;
julia> Symbolics.coeff(2a, x)
Expand Down
10 changes: 5 additions & 5 deletions src/variable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ expr = β[1]* x + y^α + σ(3) * (z - t) - β[2] * w(t - 1)
Symbolics supports creating variables that denote an array of some size.
```julia
```jldoctest
julia> @variables x[1:3]
1-element Vector{Symbolics.Arr{Num, 1}}:
x[1:3]
Expand All @@ -436,7 +436,7 @@ julia> @variables t z(t)[1:3] # also works for dependent variables
A symbol or expression that represents an array can be turned into an array of
symbols or expressions using the `scalarize` function.
```julia
```jldoctest
julia> Symbolics.scalarize(z)
3-element Vector{Num}:
(z(t))[1]
Expand All @@ -451,7 +451,7 @@ operator, and in this case, `@variables` doesn't automatically assign the value,
instead, it only returns a vector of symbolic variables. All the rest of the
syntax also applies here.
```julia
```jldoctest
julia> a, b, c = :runtime_symbol_value, :value_b, :value_c
(:runtime_symbol_value, :value_b, :value_c)
Expand Down Expand Up @@ -676,7 +676,7 @@ notation. Use `@variables` instead to create symbolic array variables (as
opposed to array of variables). See `variable` to create one variable with
subscripts.
```julia-repl
```jldoctest
julia> Symbolics.variables(:x, 1:3, 3:6)
3×4 Matrix{Num}:
x₁ˏ₃ x₁ˏ₄ x₁ˏ₅ x₁ˏ₆
Expand All @@ -694,7 +694,7 @@ end
Create a variable with the given name along with subscripted indices with the
`symtype=T`. When `T=FnType`, it creates a symbolic function.
```julia-repl
```jldoctest
julia> Symbolics.variable(:x, 4, 2, 0)
x₄ˏ₂ˏ₀
Expand Down

0 comments on commit 4a37ed9

Please sign in to comment.