Skip to content

Conversation

@Cody-G
Copy link

@Cody-G Cody-G commented Mar 3, 2017

This fixes a problem mentioned in JuliaGraphics/ColorTypes#76. Adds a new isfinite definition for ColorTypes.Gray{Bool} instances, which complements the existing definitions for float-based grays.

Copy link
Member

@timholy timholy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. If you don't want to go the more ambitious route I outlined, that's fine. No matter what, this needs a test, and it would be better if isinf and isnan were also supported.

min(a::AbstractGray, b::Number) = min(promote(a,b)...)

isfinite{T<:AbstractFloat}(c::AbstractGray{T}) = isfinite(gray(c))
isfinite{T<:Bool}(c::AbstractGray{T}) = isfinite(gray(c))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we could just define two methods,

isfinite{T<:Normed}(c::Colorant{T}) = true
isfinite(c::Colorant) = reducec(&, isfinite, c)

where reducec would be defined similarly to mapc. Obviously the same would apply for isnan, isinf.

@timholy
Copy link
Member

timholy commented Mar 30, 2017

I decided to go with the more general solution in #73. Thanks for reporting the problem!

@timholy timholy closed this Mar 30, 2017
@Cody-G
Copy link
Author

Cody-G commented Mar 30, 2017

Sure, and your solution looks much better!

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 this pull request may close these issues.

2 participants