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

Convert to parametric types. #51

Merged
merged 4 commits into from
Aug 11, 2014
Merged

Convert to parametric types. #51

merged 4 commits into from
Aug 11, 2014

Conversation

timholy
Copy link
Contributor

@timholy timholy commented Jul 27, 2014

DO NOT MERGE YET: waiting on JuliaMath/FixedPointNumbers.jl#2.

This implements #42. Tedious but hopefully well worth it. I also added lots of conversion tests, and this caught at least one missing method.

I'm pretty excited about what this will allow in Images!

@timholy
Copy link
Contributor Author

timholy commented Aug 9, 2014

OK, I do believe we can merge this.

This is (mildly) breaking. A few situations will likely trigger an error:

  • A = Array(RGB, sz) change to A = Array(RGB{T}, sz) where T is a Fractional (FloatingPoint or FixedPoint) type (formerly it would hve been RGB{Float64}.
  • Poorly-typed comprehensions. For example, rgb = [RGB(g, g, g) for g in gray] might need to change to rgb = [RGB{Float64}(g, g, g) etc], for example.

Here are the packages that depend on Color.jl, together with what I know about them:

  • "Cairo" passes
  • "Compose" has no independent tests
  • "Gadfly" passes (remarkably!)
  • "Images" fails, will take care of it myself
  • "ImageView" passes
  • "ProfileView" passes
  • "PyPlot" has no tests
  • "Winston" passes (I just submitted a PR to improve the tests)

I was intending to submit PRs or at least raise issues in most of these, but it looks like it may not be necessary. Perhaps a brief public service announcement on julia-users would make sense, though.

dcjones added a commit that referenced this pull request Aug 11, 2014
Convert to parametric types.
@dcjones dcjones merged commit 9f796c9 into master Aug 11, 2014
@dcjones
Copy link
Contributor

dcjones commented Aug 11, 2014

This code makes me happy. I love that we're not forced to either make compromises or implement multiple versions of everything, as we would be in many other languages.

end
AlphaColorValue(c::T, alpha=1.0) = new(c, alpha)
AlphaColorValue(c::C, alpha::T) = new(c, alpha)
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you lose the default value here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it should be covered by the outer constructor?

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, missed that.

@timholy
Copy link
Contributor Author

timholy commented Aug 11, 2014

Agreed, Julia is very nice that way.

Thanks for merging!

@timholy
Copy link
Contributor Author

timholy commented Aug 11, 2014

OK if I tag a new version in the next 24 hrs? I'll try to coordinate a new release of Images to go with it, since that's the one clearly-broken package.

@dcjones
Copy link
Contributor

dcjones commented Aug 11, 2014

Gadfly tests look good, so it's fine with me.

@timholy
Copy link
Contributor Author

timholy commented Aug 11, 2014

OK. Since this is breaking, should we increment the minor version?

@kmsquire
Copy link
Contributor

Might want to look closer at PyPlot. Even though there aren't any tests, it does use ColorValues extensively. Cc: @stevengj

@stevengj
Copy link
Contributor

Probably PyPlot will now need to use convert(RGB{Float64}, c::ColorValue) instead of convert(RGB, c). I don't see any other obvious changes that are required, but I will update PyPlot as needed once this is merged.

@timholy
Copy link
Contributor Author

timholy commented Aug 11, 2014

Thanks, @stevengj

@stevengj
Copy link
Contributor

Actually, it looks like it works as-is, because your fallback convert method is to the Float64 type.

@timholy
Copy link
Contributor Author

timholy commented Aug 12, 2014

That was the plan, glad to hear it actually worked.

@dcjones
Copy link
Contributor

dcjones commented Aug 12, 2014

Tagged 0.3.0

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.

4 participants