Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctests and documentation patch #571

Merged
merged 9 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Remove names from doctest blocks
The named doctest blocks don't share scope and don't need to have the same environment
  • Loading branch information
abhro committed May 18, 2024
commit 82802cb28104b32f0e45632cc6da0df59f5ee530
22 changes: 5 additions & 17 deletions src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ export fromroots,
Construct a polynomial of the given type given the roots. If no type is given, defaults to `Polynomial`.

# Examples
```jldoctest common
julia> using Polynomials

```jldoctest
julia> r = [3, 2]; # (x - 3)(x - 2)

julia> fromroots(r)
Expand All @@ -49,9 +47,7 @@ fromroots(r::AbstractVector{<:Number}; var::SymbolLike = :x) =
Construct a polynomial of the given type using the eigenvalues of the given matrix as the roots. If no type is given, defaults to `Polynomial`.

# Examples
```jldoctest common
julia> using Polynomials

```jldoctest
julia> A = [1 2; 3 4]; # (x - 5.37228)(x + 0.37228)

julia> fromroots(A)
Expand Down Expand Up @@ -722,9 +718,7 @@ domain(::P) where {P <: AbstractPolynomial} = domain(P)
Given values of x that are assumed to be unbounded (-∞, ∞), return values rescaled to the domain of the given polynomial.

# Examples
```jldoctest common
julia> using Polynomials

```jldoctest
julia> x = -10:10
-10:10

Expand Down Expand Up @@ -946,9 +940,7 @@ Base.oneunit(p::P, args...) where {P <: AbstractPolynomial} = one(p, args...)
Return the monomial `x` in the indicated polynomial basis. If no type is give, will default to [`Polynomial`](@ref). Equivalent to `P(var)`.

# Examples
```jldoctest common
julia> using Polynomials

```jldoctest
julia> x = variable()
Polynomial(x)

Expand All @@ -959,7 +951,6 @@ julia> roots((x - 3) * (x + 2))
2-element Vector{Float64}:
-2.0
3.0

```
"""
variable(::Type{P}) where {P <: AbstractPolynomial} = variable(⟒(P){eltype(P), indeterminate(P)})
Expand Down Expand Up @@ -1210,12 +1201,9 @@ Find the greatest common denominator of two polynomials recursively using

# Examples

```jldoctest common
julia> using Polynomials

```jldoctest
julia> gcd(fromroots([1, 1, 2]), fromroots([1, 2, 3]))
Polynomial(4.0 - 6.0*x + 2.0*x^2)

```
"""
function Base.gcd(p1::AbstractPolynomial{T}, p2::AbstractPolynomial{S}; kwargs...) where {T,S}
Expand Down
5 changes: 1 addition & 4 deletions src/legacy/pade.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ end
Evaluate the Pade approximant at the given point.

# Examples
```jldoctest pade
```jldoctest
julia> using Polynomials, Polynomials.PolyCompat, SpecialFunctions


julia> p = Polynomial(@.(1 // BigInt(gamma(1:17))));

julia> pade = Pade(p, 8, 8);
Expand All @@ -108,6 +107,4 @@ true
padeval(PQ::Pade, x::Number) = PQ(x)
padeval(PQ::Pade, x) = PQ.(x)



end
4 changes: 1 addition & 3 deletions src/polynomials/standard-basis/immutable-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ are precluded from use in rational functions.

# Examples

```jldoctest immutable_polynomials
julia> using Polynomials

```jldoctest
julia> ImmutablePolynomial((1, 0, 3, 4))
ImmutablePolynomial(1 + 3*x^2 + 4*x^3)

Expand Down
12 changes: 3 additions & 9 deletions src/polynomials/standard-basis/laurent-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ Integration will fail if there is a `x⁻¹` term in the polynomial.
`LaurentPolynomial` is axis-aware, unlike the other polynomial types in this package.

# Examples:
```jldoctest laurent
julia> using Polynomials

```jldoctest
julia> P = LaurentPolynomial;

julia> p = P([1,1,1], -1)
Expand Down Expand Up @@ -185,9 +183,7 @@ Call `p̂ = paraconj(p)` and `p̄` = conj(p)`, then this satisfies

Examples:

```jldoctest laurent
julia> using Polynomials;

```jldoctest
julia> z = variable(LaurentPolynomial, :z)
LaurentPolynomial(z)

Expand Down Expand Up @@ -226,9 +222,7 @@ This satisfies for *imaginary* `s`: `conj(p(s)) = p̃(s) = (conj ∘ p)(s) = cco
[reference](https://github.com/hurak/PolynomialEquations.jl#symmetrix-conjugate-equation-continuous-time-case)

Examples:
```jldoctest laurent
julia> using Polynomials;

```jldoctest
julia> s = 2im
0 + 2im

Expand Down
7 changes: 0 additions & 7 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -222,18 +222,13 @@ parentheses.
```jldoctest
julia> using Polynomials, DualNumbers




julia> Polynomial([Dual(1,2), Dual(3,4)])
Polynomial(1 + 2ɛ + 3 + 4ɛ*x)
```

```jldoctest
julia> using DualNumbers, Polynomials



julia> function Base.show_unquoted(io::IO, pj::Dual, indent::Int, prec::Int)
if Base.operator_precedence(:+) <= prec
print(io, "(")
Expand All @@ -244,8 +239,6 @@ julia> function Base.show_unquoted(io::IO, pj::Dual, indent::Int, prec::Int)
end
end



julia> Polynomial([Dual(1,2), Dual(3,4)])
Polynomial((1 + 2ɛ) + (3 + 4ɛ)*x)
```
Expand Down