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

NaNs are not showable #469

Closed
johnnychen94 opened this issue Apr 10, 2021 · 3 comments · Fixed by #470
Closed

NaNs are not showable #469

johnnychen94 opened this issue Apr 10, 2021 · 3 comments · Fixed by #470

Comments

@johnnychen94
Copy link
Member

johnnychen94 commented Apr 10, 2021

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

@kimikage
Copy link
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)

@johnnychen94
Copy link
Member Author

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

@kimikage
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants