Repository navigation
Fix floattype() for non-concrete types - #354
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #354 +/- ##
==========================================
+ Coverage 96.85% 97.22% +0.36%
==========================================
Files 7 7
Lines 796 792 -4
==========================================
- Hits 771 770 -1
+ Misses 25 22 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
kimikage
force-pushed
the
fix_floattype
branch
from
October 12, 2026 14:57
ac2b7de to
5856b43
Compare
kimikage
force-pushed
the
fix_floattype
branch
from
October 12, 2026 16:00
5856b43 to
c5c5a18
Compare
kimikage
commented
Oct 12, 2026
| """ | ||
| floattype(::Type{T}) where {T <: AbstractFloat} = T # fallback (we want a MethodError if no method producing AbstractFloat is defined) | ||
| floattype(::Type{T}) where {T <: Union{ShortInts, Bool}} = Float32 | ||
| floattype(::Type{T}) where {T <: Integer} = Float64 |
Collaborator
Author
There was a problem hiding this comment.
Regarding this as well, BigFloat should ideally be returned for non-concrete types. However, I'm leaving it as is to minimize the impact of the change.
kimikage
commented
Oct 12, 2026
| floattype(::Type{T}) where {T <: Union{ShortInts, Bool}} = Float32 | ||
| floattype(::Type{T}) where {T <: Integer} = Float64 | ||
| floattype(::Type{T}) where {T <: LongInts} = BigFloat | ||
| floattype(::Type{T}) where {I <: Integer, T <: Rational{I}} = typeof(zero(I)/oneunit(I)) |
Collaborator
Author
There was a problem hiding this comment.
While there are doubts regarding the guarantee that this returns an AbstractFloat, that is an issue to be addressed by the package that defined the type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #342
Since ColorTypes does not yet support FPN v0.9, FPN v0.8 remains widely used. However, as six years have passed since PR #177 was merged, this PR removes the deprecated fallback. Strictly speaking, this is a breaking change; however, given that this was originally intended for v0.9.0, I do not see any practical issue with removing the fallback in v0.9.