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
Fix spacing
  • Loading branch information
abhro committed May 18, 2024
commit caa3cd459a7dea8f0da8cbdb9595a5e09686813b
2 changes: 1 addition & 1 deletion src/legacy/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ polyint(p::Poly, a, b) = integrate(p, a, b)
polyint(p::AbstractPolynomial, args...) = error("`polyint` is a legacy name for use with `Poly` objects only. Use `integrate(p,...)`.")

polyder(p::Poly, ord = 1) = derivative(p, ord)
polyder(p::AbstractPolynomial, args...) = error("`polyder` is a legacy name for use with `Poly` objects only. Use `derivative(p,[order=1])`.")
polyder(p::AbstractPolynomial, args...) = error("`polyder` is a legacy name for use with `Poly` objects only. Use `derivative(p,[order=1])`.")

polyfit(x, y, n = length(x) - 1, sym=:x) = fit(Poly, x, y, n; var = sym)
polyfit(x, y, sym::Symbol) = fit(Poly, x, y, var = sym)
Expand Down
2 changes: 1 addition & 1 deletion src/polynomial-container-types/mutable-dense-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
MutableDensePolynomial{B,T,X}

"""
struct MutableDensePolynomial{B,T,X} <: AbstractDenseUnivariatePolynomial{B,T, X}
struct MutableDensePolynomial{B,T,X} <: AbstractDenseUnivariatePolynomial{B,T,X}
coeffs::Vector{T}
function MutableDensePolynomial{B,T,X}(::Val{true}, cs::AbstractVector{S}, order::Int=0) where {B,T,X,S}
if Base.has_offset_axes(cs)
Expand Down
4 changes: 3 additions & 1 deletion src/polynomials/standard-basis/immutable-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ ImmutablePolynomial(1.0)
```

!!! note
This was modeled after [StaticUnivariatePolynomials](https://github.com/tkoolen/StaticUnivariatePolynomials.jl) by `@tkoolen`.
This was modeled after
[StaticUnivariatePolynomials](https://github.com/tkoolen/StaticUnivariatePolynomials.jl)
by `@tkoolen`.

"""
const ImmutablePolynomial = ImmutableDensePolynomial{StandardBasis}
Expand Down
4 changes: 1 addition & 3 deletions src/polynomials/standard-basis/sparse-polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ advantageous.
# Examples:

```jldoctest
julia> using Polynomials

julia> P = SparsePolynomial;
julia> P = SparsePolynomial;

julia> p, q = P([1,2,3]), P([4,3,2,1])
(SparsePolynomial(1 + 2*x + 3*x^2), SparsePolynomial(4 + 3*x + 2*x^2 + x^3))
Expand Down
3 changes: 1 addition & 2 deletions src/rational-functions/plot-recipes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function rational_function_trim(pq, a, b, xlims, ylims)

a = isnothing(a) ? xlims[1] : a
b = isnothing(b) ? xlims[2] : b

if isnothing(a) && isnothing(b)
u= poly_interval(p)
v= poly_interval(q)
Expand Down Expand Up @@ -64,4 +64,3 @@ function rational_function_trim(pq, a, b, xlims, ylims)
xs, ys′

end

20 changes: 10 additions & 10 deletions src/rational-functions/rational-transfer-function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ struct RationalTransferFunction{T,X,P<:AbstractPolynomial{T,X},Ts} <: AbstractRa
new{T,X,P,Ts}(num,den)
end
function RationalTransferFunction{T,X,P,Ts}(num::P, den::P,ts::Union{Real,Nothing}) where{T,X,P<:AbstractPolynomial{T,X}, Ts}
check_den(den)
check_Ts(Ts,ts)
check_den(den)
check_Ts(Ts,ts)
new{T,X,P,Ts}(num,den)
end
# can promote constants to polynomials too
function RationalTransferFunction{T,X,P,Ts}(num::S, den::P, ts::Union{Real,Nothing}) where{S, T,X,P<:AbstractPolynomial{T,X}, Ts}
check_den(den)
check_Ts(Ts,ts)
check_Ts(Ts,ts)
new{T,X,P,Ts}(convert(P,num),den)
end
function RationalTransferFunction{T,X,P,Ts}(num::P,den::S, ts::Union{Real,Nothing}) where{S, T,X,P<:AbstractPolynomial{T,X}, Ts}
Expand Down Expand Up @@ -69,7 +69,7 @@ end
## helpers for constructors
# standardize Ts or throw error
function standardize_Ts(Ts)
isnothing(Ts) || Ts >= 0 || Ts == -1 ||
isnothing(Ts) || Ts >= 0 || Ts == -1 ||
throw(ArgumentError("Ts must be either a positive number, 0 (continuous system), or -1 (unspecified)"))
Ts′ = isnothing(Ts) ? Ts : Float64(Ts)
end
Expand Down Expand Up @@ -103,7 +103,7 @@ end
function promote_Ts(Ts1::Union{Float64,Nothing}, Ts2::Union{Float64,Nothing})
isnothing(Ts1) && (return Ts2)
isnothing(Ts2) && (return Ts1)
Ts1 == Ts2 && (return Ts1)
Ts1 == Ts2 && (return Ts1)
Ts1 == -1 && (Ts2 > 0 ? (return Ts2) : error("Sampling time mismatch"))
Ts2 == -1 && (Ts1 > 0 ? (return Ts1) : error("Sampling time mismatch"))
error("Sampling time mismatch")
Expand All @@ -119,8 +119,8 @@ function Base.promote_rule(::Type{PQ}, ::Type{PQ′}) where {T,X,P,Ts,PQ <: Rati
ts = promote_Ts(PQ, PQ′)
RationalTransferFunction{S,Y,Q,Val(ts)}
end





Expand All @@ -135,12 +135,12 @@ function gain(pq::PQ) where {PQ <: RationalTransferFunction}
p[end]/q[end]
end


# need to check here
#
"""
rt = adjoint(r)
Compute the adjoint `rt(λ)` of the rational transfer function `r(λ)` such that for
rt = adjoint(r)
Compute the adjoint `rt(λ)` of the rational transfer function `r(λ)` such that for
`r(λ) = num(λ)/den(λ)` we have:
(1) `rt(λ) = conj(num(-λ))/conj(num(-λ))`, if `r.Ts = 0`;
(2) `rt(λ) = conj(num(1/λ))/conj(num(1/λ))`, if `r.Ts = -1` or `r.Ts > 0`.
Expand Down