Skip to content

Math operations with explicit types #185

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

Merged

Conversation

nicolamos
Copy link
Contributor

When called with explicit type we should return a result of that type.

Discussion for this is in JuliaGraphics/ColorTypes.jl/issues/123.

This breaks existing behaviour as per #131 and #126.

For example, floor(Int, Gray(x)) should return an Int and the result should be the same as floor(Int, x), treating Grays as numbers.

When called with explicit type we should return a result of that type.
@codecov
Copy link

codecov bot commented Oct 9, 2022

Codecov Report

Base: 86.41% // Head: 85.66% // Decreases project coverage by -0.75% ⚠️

Coverage data is based on head (709ff14) compared to base (8ec1d35).
Patch coverage: 100.00% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #185      +/-   ##
==========================================
- Coverage   86.41%   85.66%   -0.76%     
==========================================
  Files           2        2              
  Lines         265      265              
==========================================
- Hits          229      227       -2     
- Misses         36       38       +2     
Impacted Files Coverage Δ
src/ColorVectorSpace.jl 90.07% <100.00%> (-0.80%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

Copy link
Member

@johnnychen94 johnnychen94 left a comment

Choose a reason for hiding this comment

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

I've commented on #131 (comment) before noticing this PR.

@nicolamos
Copy link
Contributor Author

Sorry I thought I should have created a new PR.

@nicolamos nicolamos marked this pull request as ready for review October 9, 2022 16:54
@nicolamos
Copy link
Contributor Author

nicolamos commented Oct 9, 2022

I am not sure about the code coverage. I also cannot reproduce the tests locally as I get an error in how Gray{N0f32}(0.5) is treated, I guess (runtests.jl:131).

[Edit]
I get @inferred(Gray{N0f32}(0.5) * Gray(0.5f0)) === Gray(Float64(N0f32(0.5)) * 0.5), evaluated to
Gray{Float64}(0.24999999994179234) === Gray{Float64}(0.25000000005820766)

@nicolamos nicolamos requested a review from johnnychen94 January 1, 2023 16:34
@johnnychen94
Copy link
Member

I was waiting to see if @timholy had the time to comment since he introduced the previous changes. But let's say make the release and test this in the field.

@johnnychen94 johnnychen94 merged commit 6527d67 into JuliaGraphics:master Jan 3, 2023
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