Repository navigation
Make RealNumbers parametric in its element type - #188
Open
dlfivefifty wants to merge 1 commit into
Open
dlfivefifty wants to merge 1 commit into
dlfivefifty wants to merge 1 commit into
Conversation
ℝ is a Domain{Float64} with no similardomain method, so it could not be
converted to another element type. This made e.g. UnitDisk{Float32}() × ℝ
or UnitDisk{Dual}() × ℝ (used with ForwardDiff) throw a MethodError.
RealNumbers{T<:Real} now subtypes Domain{T}, with RealNumbers() and ℝ
defaulting to Float64, as with FullSpace. Equality and hashing ignore T.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #188 +/- ##
==========================================
+ Coverage 94.04% 94.06% +0.01%
==========================================
Files 28 28
Lines 1865 1869 +4
==========================================
+ Hits 1754 1758 +4
Misses 111 111 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Member
Author
|
Actually not sure what the difference between RealNumbers and FullSpace is. I've changed my code to use FullSpace |
Member
|
One important difference is that FullSpace does not guard against conversion, but the sets of integers and numbers do. That leads to something possibly unexpected: julia> d1 = FullSpace{Int}()
{x} (full space)
julia> 2.1 ∈ d1
true
julia> d2 = Integers()
Integers()
julia> 2.1 ∈ d2
falseSo you may want to use the PR after all? |
This branch has not been deployed
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.
ℝis aDomain{Float64}and had nosimilardomainmethod, so it couldn't be converted to another element type. Products likeUnitDisk{Float32}() × ℝthrew aMethodError:This came up when differentiating a basis on
UnitDisk{T}() × ℝwith ForwardDiff, which evaluates atT = Dual.This PR follows the existing
FullSpace{T}pattern:RealNumbers{T<:Real} <: Domain{T}.RealNumbers()andℝdefault toFloat64, so their behaviour is unchanged.similardomain(::RealNumbers, ::Type{T}) where T<:Real = RealNumbers{T}().T, soℝ == RealNumbers{Float32}(). This matchesFullSpace.One visible change:
ℝnow prints asRealNumbers{Float64}()instead ofRealNumbers(). Code that dispatches on::RealNumbersis unaffected, sinceRealNumbersnow names theUnionAll.I bumped the version to 0.8.4. The full test suite passes.
🤖 Generated with Claude Code