Giter Club home page Giter Club logo

Comments (3)

milankl avatar milankl commented on June 10, 2024 1

Yes, but it doesn't help if the entire field is NaN/Infs

julia> A = rand(2,2)
julia> A[1] = NaN
julia> NaNMath.extrema(A)
(0.18783010303710246, 0.9637507750862072)

julia> NaNMath.extrema(A*NaN)
(NaN, NaN)

I'm coming from a perspective where I run a simulation, hopefully everthing works fine and heatmap gives me a quick look that things look reasonable. However, when the simulation blows up I just see white stripes on the heatmap (which is good because then I know I did something wrong). But in that case I can't use the colorbar at the moment.

from unicodeplots.jl.

milankl avatar milankl commented on June 10, 2024

I suggest to change that function to

function ceil_neg_log10(x)
    val = -log10(x)
    isfinite(val) || return typemin(Int)
    roundable(val) ? ceil(Int, val) : floor(Int, val)
end

such that

julia> ceil_neg_log10(Inf)
-9223372036854775808

julia> ceil_neg_log10(1e300)
-300

the output is of the same type (Int) and the smallest representable to match the -log10(x) idea as best as possible. In the end it seems to be used here

float_round_log10(x::T, m) where {T<:AbstractFloat} = T(x == 0 ? 0 : if x > 0
+round(+x, digits = ceil_neg_log10(m) + 1)
else
-round(-x, digits = ceil_neg_log10(m) + 1)
end)

where this works fine now

julia> round(Inf,digits=typemin(Int)+1)
Inf

julia> round(-Inf,digits=typemin(Int)+1)
-Inf

julia> round(NaN,digits=typemin(Int)+1)
NaN

If there are no objections, I'll create a pull request replacing the ceil_neg_log10 function

from unicodeplots.jl.

t-bltg avatar t-bltg commented on June 10, 2024

Thanks for reporting.

First, I think the colorbar limits should not take NaNs into account. That is an easy fix replacing

mi, ma = extrema(A)
with NaNMath.extrema(A).

Then, I think we should ignore those NaN values when printing Crayons.

from unicodeplots.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.