Skip to content

NaNs are not showable #469

Description

@johnnychen94

Gray(NaN) and RGB(NaN) are not showable:

julia> Gray(NaN)
Error showing value of type Gray{Float64}:
ERROR: ArgumentError: element type N0f8 is an 8-bit type representing 256 values from 0.0 to 1.0,
  but the values (NaN, 1.0) do not lie within this range.
  See the READMEs for FixedPointNumbers and ColorTypes for more information.

The error message is a bit misleading, too.

ImageShow uses ImageCore.clamp01nan to handle this, I think we can perhaps move clamp01 and clamp01nan to Colors.

https://github.com/JuliaImages/ImageCore.jl/blob/a8f3d2c52070d9c166e1657ba25e72c8df00c742/src/map.jl#L3-L39

Activity

  1. kimikage commented on Apr 10, 2021

    @kimikage
    Collaborator

    At least Colors.jl does not implement the text display feature. So, this seems to be a side effect of other packages.

    pkg> st --manifest
          Status `Manifest.toml`
      [3da002f7] ColorTypes v0.10.12
      [5ae59095] Colors v0.12.7
      [53c48c17] FixedPointNumbers v0.8.4
      [189a3867] Reexport v1.0.0
      [8f399da3] Libdl
      [37e2e46d] LinearAlgebra
      [9a3f8284] Random
      [9e88b42a] Serialization
      [2f01184e] SparseArrays
      [10745b16] Statistics
    
    julia> using Colors
    
    julia> Gray(NaN)
    Gray{Float64}(NaN)
  2. johnnychen94 commented on Apr 10, 2021

    @johnnychen94
    MemberAuthor

    Ah yes! Sorry I didn't describe it clearly; the error message I get shows when I use vscode.

  3. kimikage commented on Apr 10, 2021

    @kimikage
    Collaborator

    Colors, unlike ImageShow, displays a color or color arrays as "swatches" rather than an "image". So, it seems appropriate to return false in showable(). In fact, Jupyter implicitly fall back when an error occurs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions