Skip to content

Fix floattype() for non-concrete types - #354

Merged
kimikage merged 1 commit into
JuliaMath:masterfrom
kimikage:fix_floattype
Oct 12, 2026
Merged

kimikage merged 1 commit into
JuliaMath:masterfrom
kimikage:fix_floattype

Conversation

@kimikage

@kimikage kimikage commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

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.

@codecov

codecov Bot commented Oct 10, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.22%. Comparing base (206e68f) to head (c5c5a18).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/FixedPointNumbers.jl
"""
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

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread src/FixedPointNumbers.jl
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))

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

@kimikage
kimikage merged commit a26b6d8 into JuliaMath:master Oct 12, 2026
13 checks passed
@kimikage
kimikage deleted the fix_floattype branch October 12, 2026 16:59
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.

Fallback of floattype() for non-concrete types

1 participant