Skip to content

Commit

Permalink
adjust printing tohandle symbolic values (#324)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverzani authored Mar 25, 2021
1 parent 685a691 commit 079bccb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/polynomials/standard-basis.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ abstract type StandardBasisPolynomial{T} <: AbstractPolynomial{T} 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 @@ -10,10 +10,10 @@ export printpoly
hasneg(::Type{T}) where {T} = false

"Could value possibly be negative and if so, is it?"
isneg(pj::T) where {T} = hasneg(T) && pj < zero(T)
isneg(pj::T) where {T} = hasneg(T) && sign(pj) === -one(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

2 comments on commit 079bccb

@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/32815

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 v1.2.1 -m "<description of version>" 079bccb73a04985275d081a881414a12d40e6109
git push origin v1.2.1

Please sign in to comment.