Skip to content

Commit

Permalink
Issue 320 (#321)
Browse files Browse the repository at this point in the history
* change printing to work with Symbolics; close #320

* version bump [ci skip]
  • Loading branch information
jverzani authored Mar 24, 2021
1 parent 815ab1a commit e156428
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name = "Polynomials"
uuid = "f27b6e38-b328-58d1-80ce-0feddd5e7a45"
license = "MIT"
author = "JuliaMath"
version = "2.0.1"
version = "2.0.2"

[deps]
Intervals = "d8418881-c3e1-53bb-8760-2df7ec849ed5"
Expand Down
1 change: 1 addition & 0 deletions docs/src/extending.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ As always, if the default implementation does not work or there are more efficie
| `domain` | x | Should return an [`AbstractInterval`](https://invenia.github.io/Intervals.jl/stable/#Intervals-1) |
| `vander` | | Required for [`fit`](@ref) |
| `companion` | | Required for [`roots`](@ref) |
| `fromroots` | | By default, will form polynomials using `prod(variable(::P) - r)` for reach root `r`|
| `*(::P, ::P)` | | Multiplication of polynomials |
| `divrem` | | Required for [`gcd`](@ref)|
| `one`| | Convenience to find constant in new basis |
Expand Down
4 changes: 2 additions & 2 deletions src/polynomials/standard-basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ abstract type StandardBasisPolynomial{T,X} <: AbstractPolynomial{T,X} end

function showterm(io::IO, ::Type{<:StandardBasisPolynomial}, pj::T, var, j, first::Bool, mimetype) where {T}

if iszero(pj) return false end
if pj === zero(T) return false end

pj = printsign(io, pj, first, mimetype)

if !(pj == one(T) && !(showone(T) || j == 0))
if !(pj === one(T) && !(showone(T) || j == 0))
printcoefficient(io, pj, j, mimetype)
end

Expand Down
4 changes: 2 additions & 2 deletions src/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ hasneg(::Type{T}) where {T} = false
isneg(pj::T) where {T} = hasneg(T) && pj < zero(T)

"Make `pj` positive if it is negative. (Don't call `abs` as that may not be defined, or appropriate.)"
aspos(pj::T) where {T} = (hasneg(T) && isneg(pj)) ? -pj : pj
aspos(pj::T) where {T} = (hasneg(T) && isneg(pj)===true) ? -pj : pj

"Should a value of `one(T)` be shown as a coefficient of monomial `x^i`, `i >= 1`? (`1.0x^2` is shown, `1 x^2` is not)"
showone(::Type{T}) where {T} = true
Expand Down Expand Up @@ -163,7 +163,7 @@ function showterm(io::IO, ::Type{AbstractPolynomial}, pj::T, var, j, first::Bool
## print the sign
## returns aspos(pj)
function printsign(io::IO, pj::T, first, mimetype) where {T}
neg = isneg(pj)
neg = hasneg(T) && isneg(pj) === true
if first
neg && print(io, showop(mimetype, "l-")) #Prepend - if first and negative
else
Expand Down

2 comments on commit e156428

@jverzani
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/32737

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v2.0.2 -m "<description of version>" e15642889d1bd30b173ca8755c8d413b5237cc5f
git push origin v2.0.2

Please sign in to comment.