From 4a37ed9826dcd5a2a18cc09cfa43c99a7ee6864a Mon Sep 17 00:00:00 2001 From: Abhro R <5664668+abhro@users.noreply.github.com> Date: Sun, 15 Dec 2024 11:28:16 -0500 Subject: [PATCH] Add doctests --- src/Symbolics.jl | 2 +- src/linear_algebra.jl | 2 +- src/taylor.jl | 6 +++--- src/utils.jl | 10 +++++----- src/variable.jl | 10 +++++----- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Symbolics.jl b/src/Symbolics.jl index c34c33d40..5f1b8a35f 100644 --- a/src/Symbolics.jl +++ b/src/Symbolics.jl @@ -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 diff --git a/src/linear_algebra.jl b/src/linear_algebra.jl index 2b37a9b9a..821a77322 100644 --- a/src/linear_algebra.jl +++ b/src/linear_algebra.jl @@ -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 diff --git a/src/taylor.jl b/src/taylor.jl index cbb95dc4e..242a27d71 100644 --- a/src/taylor.jl +++ b/src/taylor.jl @@ -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 @@ -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 @@ -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 diff --git a/src/utils.jl b/src/utils.jl index 17d91a971..e625062a1 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -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) @@ -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)))) @@ -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 @@ -251,7 +251,7 @@ Extract the degree of `p` with respect to `sym`. # Examples -```julia +```jldoctest julia> @variables x; julia> Symbolics.degree(x^0) @@ -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) diff --git a/src/variable.jl b/src/variable.jl index 489a072de..1760724ed 100644 --- a/src/variable.jl +++ b/src/variable.jl @@ -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] @@ -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] @@ -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) @@ -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₁ˏ₆ @@ -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₄ˏ₂ˏ₀