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

Simplify display of colors and arrays of colors #206

Merged
merged 2 commits into from
May 14, 2021

Conversation

kimikage
Copy link
Collaborator

@kimikage kimikage commented Jul 6, 2020

Fixes #202, Fixes #191 (and #179 (comment))

This simplifies the display of array elements based on the :typeinfo property. This also simplifies the display of color components by setting the :typeinfo property.
This prints the elements of gray arrays as real numbers.

@codecov
Copy link

codecov bot commented Jul 6, 2020

Codecov Report

Merging #206 (06d9153) into master (55b720c) will increase coverage by 0.10%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #206      +/-   ##
==========================================
+ Coverage   82.52%   82.62%   +0.10%     
==========================================
  Files           8        8              
  Lines         738      754      +16     
==========================================
+ Hits          609      623      +14     
- Misses        129      131       +2     
Impacted Files Coverage Δ
src/traits.jl 98.86% <ø> (ø)
src/show.jl 95.00% <93.33%> (-2.73%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 55b720c...06d9153. Read the comment docs.

@kimikage kimikage marked this pull request as ready for review July 22, 2020 11:43
@kimikage
Copy link
Collaborator Author

Before (Julia v1.4.2)

julia> rand(RGB{Float32})
RGB{Float32}(0.010770321f0,0.30586517f0,0.20819986f0)

julia> rand(RGB{Float32}, 2, 2)
2×2 Array{RGB{Float32},2} with eltype RGB{Float32}:
 RGB{Float32}(0.405684,0.257278,0.958491)  RGB{Float32}(0.589914,0.38923,0.914833)
 RGB{Float32}(0.509395,0.950449,0.49083)   RGB{Float32}(0.428022,0.876569,0.0370699)

julia> RGB[rand(RGB{Float32}, 2, 2);]
2×2 Array{RGB,2} with eltype RGB:
 RGB{Float32}(0.251354,0.515818,0.796756)  RGB{Float32}(0.625089,0.364764,0.478725)
 RGB{Float32}(0.776938,0.891641,0.704014)  RGB{Float32}(0.770691,0.598743,0.283114)

After (Julia v1.4.2)

julia> rand(RGB{Float32})
RGB{Float32}(0.010770321,0.30586517,0.20819986)

julia> rand(RGB{Float32}, 2, 2)
2×2 Array{RGB{Float32},2}:
 RGB(0.405684,0.257278,0.958491)  RGB(0.589914,0.38923,0.914833)
 RGB(0.509395,0.950449,0.49083)   RGB(0.428022,0.876569,0.0370699)

julia> RGB[rand(RGB{Float32}, 2, 2);]
2×2 Array{RGB,2}:
 RGB{Float32}(0.251354,0.515818,0.796756)  RGB{Float32}(0.625089,0.364764,0.478725)
 RGB{Float32}(0.776938,0.891641,0.704014)  RGB{Float32}(0.770691,0.598743,0.283114)

@kimikage
Copy link
Collaborator Author

Before (Julia v1.4.2)

julia> Gray{Float32}[1 0; 0.2 0.5]
2×2 Array{Gray{Float32},2} with eltype Gray{Float32}:
 Gray{Float32}(1.0)  Gray{Float32}(0.0)
 Gray{Float32}(0.2)  Gray{Float32}(0.5)

julia> Gray24[1 0; 0.2 0.5]
2×2 Array{Gray24,2} with eltype Gray24:
 Gray24(1.0)  Gray24(0.0)
 Gray24(0.2)  Gray24(0.502)

julia> Gray{Bool}(1)
Gray{Bool}(true)

julia> Gray{Bool}[1 0; 0 1]
2×2 Array{Gray{Bool},2} with eltype Gray{Bool}:
 Gray{Bool}(true)   Gray{Bool}(false)
 Gray{Bool}(false)  Gray{Bool}(true)

After (Julia v1.4.2)

julia> Gray{Float32}[1 0; 0.2 0.5]
2×2 Array{Gray{Float32},2}:
 1.0  0.0
 0.2  0.5

julia> Gray24[1 0; 0.2 0.5]
2×2 Array{Gray24,2}:
 1.0  0.0
 0.2  0.502

julia> Gray{Bool}(1)
Gray{Bool}(1)

julia> Gray{Bool}[1 0; 0 1]
2×2 Array{Gray{Bool},2}:
 1  0
 0  1

src/show.jl Outdated Show resolved Hide resolved
src/show.jl Outdated Show resolved Hide resolved
@kimikage kimikage marked this pull request as draft July 24, 2020 17:31
@kimikage
Copy link
Collaborator Author

kimikage commented Jul 24, 2020

After merging PR #210 (i.e. releasing v0.10.8), I will run rebase.

Edit:
Done.

@kimikage kimikage marked this pull request as ready for review August 5, 2020 06:05
@kimikage
Copy link
Collaborator Author

A possible additional change would be to add a space after the component separator ",".

I prefer the spaced style for consistency with the rest of Julia, but that's not a sufficient motivation to break compatibility.

@kimikage
Copy link
Collaborator Author

Julia v1.6.0-beta1 is now available. Since Julia v1.6 introduces some breaking changes to printing, I think it's not a bad idea to put a space after the comma, "now".

@kimikage kimikage force-pushed the issue202 branch 2 times, most recently from a04cbd2 to 5e3158e Compare January 19, 2021 08:41
@kimikage
Copy link
Collaborator Author

I regret to say that this breaks the tests for some packages...

julia> RGB{Float32}(1.0,0.5,0.0)
RGB{Float32}(1.0, 0.5, 0.0)

julia> (1.0,0.5,0.0)
(1.0, 0.5, 0.0)

@timholy
Copy link
Member

timholy commented Feb 24, 2021

If it's released in a breaking version, that's not a problem. You have approval, so merge when ready.

@kimikage
Copy link
Collaborator Author

kimikage commented Feb 24, 2021

Oh, I thought you were trying to do the method migration from ColorVectorSpace first (without changing Colors.jl minor version).

I think it is better to separate the method migration from other breaking changes.

Of course, that doesn't mean I think it's a good idea to leave this behind, though.

Edit:
ColorVectorSpace no longer depends directly on Colors.jl, so the dependency problem has been mitigated.

@kimikage kimikage mentioned this pull request Feb 25, 2021
@kimikage kimikage added this to the 0.12 milestone Apr 8, 2021
@kimikage kimikage mentioned this pull request May 6, 2021
19 tasks
This simplifies the display of array elements based on the :typeinfo property.
This also simplifies the display of color components by setting the :typeinfo property.
This prints the elements of gray arrays as real numbers.
This makes consistent with Julia v1.6 the data and type printing.
@kimikage
Copy link
Collaborator Author

I apologize in advance that this may break your doctests.

@kimikage kimikage merged commit 213e0de into JuliaGraphics:master May 14, 2021
@kimikage kimikage deleted the issue202 branch May 14, 2021 15:55
johnnychen94 added a commit that referenced this pull request May 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RFC] Simplified display of colors and arrays of colors Display of gray arrays and Gray{Bool}
2 participants