-
Notifications
You must be signed in to change notification settings - Fork 27
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
Deprecate methods for eltype
and add boundstype
#150
base: master
Are you sure you want to change the base?
Conversation
eltype
and adds boundstype
eltype
and add boundstype
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #150 +/- ##
==========================================
+ Coverage 99.17% 99.18% +0.01%
==========================================
Files 4 4
Lines 242 245 +3
==========================================
+ Hits 240 243 +3
Misses 2 2
☔ View full report in Codecov by Sentry. |
Does this mean that the endpoints will always need to be the same type? Might someone want to have a 1.3 to pi interval where they do not want pi converted to Float64? |
Sorry, but want to raise the same point again :) Please consider the option to simply deprecate |
Yes, at least for now.
Yeah, I thought we should not separate the types of endpoints when I created this PR, but this should be done in another PR if someone wants that feature. (I personally would like to avoid that feature, but this should be discussed in other issues or PRs.)
EDIT: Sorry, I got screwed up, I will update this PR and release the next |
I will merge this PR in a few days if there are no objections. |
Warnings basically break all downstream packages, so this should be treated as a breaking change. Leaving in the deprecation for the next version is fine as it helps debug. |
@daanhb This will have a big impact on DomainSets.jl. Speak now or forever hold your peace. |
Isn't the whole purpose of deprecation warnings to be non-breaking? Lots of packages use depwarns exactly for this. |
eltype
and add boundstype
eltype
and add boundstype
b358f7f
to
dc49a75
Compare
@dlfivefifty I am curious what you mean by this. Deprecation warnings are turned off by default except in tests, so deprecating should be treated as a warning that something will happen in the future, not that it is already breaking. https://stackoverflow.com/questions/56135768/which-part-of-semver-should-i-bump-when-deprecating-supported-python-version (Edit: Ah, I see that @aplavin already responded to this) |
I don't like deadlines on vacation :-) If this PR does have a big impact on DomainSets.jl, then I hope it does not happen this way. I think everybody agreed that we should move the definition of Domain{T} to a new package such as DomainSetsCore.jl, a very related topic, and I strongly feel that should happen first. I'd be happy to propose something in a few weeks. I'm not sure this change will be very breaking for now, though one has to check. As things stand, DomainSets.jl defines the eltype of any domain anyway, including intervals. For the record, I do not intend to change that. If something truly incompatible happens in IntervalSets, I'm more inclined to diverge away, as for the purposes of computations (perhaps less relevant in JuliaMath than in JuliaApproximation) having an |
I agree with having DomainSetsCore.jl. I don't have practical usage of
Is it okay to rename |
The combination This argument only holds for the abstract supertype. A concrete domain could always do
The simplest examples arise from taking cartesian products: julia> using IntervalSets, DomainSets
julia> using DomainSets: ×
julia> d1 = (1..2) × (3..4.0)
(1.0 .. 2.0) × (3.0 .. 4.0)
julia> eltype(d1)
SVector{2, Float64} (alias for StaticArraysCore.SArray{Tuple{2}, Float64, 1, 2})
julia> d2 = (1.0..2.0) × UnitCircle()
(1.0 .. 2.0) × UnitCircle()
julia> eltype(d2)
SVector{3, Float64} (alias for StaticArraysCore.SArray{Tuple{3}, Float64, 1, 3})
julia> d3 = (1.0..2.0) × UnitBall(5)
(1.0 .. 2.0) × UnitBall(5)
julia> eltype(d3)
Tuple{Float64, Vector{Float64}} There is a lot going on here, but these are the sort of things on my mind when I say that
I feel like |
I took a stab at The first iteration has
In the long run I'd say the third option may be the preferred one. It is also closest to what @dlfivefifty has been pushing for, namely domains as an interface. Ideally, we could get DomainSets.jl to work with Intervals like that, regardless of inheritance of any supertype. Because that would mean that DomainSets could also work with other packages defining domains, with all packages able to evolve independently. To me, in this design I've added an |
@daanhb , I was about to log on and suggest this! I think DomainSets would be more powerful if it relies as little as possible on things being a subtype of |
There was already an issue for DomainSetsCore.jl with some discussion: #136. I'll move there. |
Coming back to the issue at hand: so far I've sticked to Conceptually, its meaning comes from answering the question: if you were to sample the domain, what would the type of a point be? (Currently, I was looking at other packages, such as GeometryBasics. There you have: julia> rect = Rect(Vec(0.0, 0.0), Vec(1.0, 1.0))
Rect2{Float64}([0.0, 0.0], [1.0, 1.0])
julia> eltype(ans)
Any In order to combine those rectangles with other domains, one would have to define So I guess I'm changing my mind here. I don't know what best to do yet with intervals inheriting from |
Meanwhile, a lot of changes happened over in DomainSets (unmerged, but in this PR), which are beneficial independently. Three possibilities to move forward are:
I think that, if there is a common Domain supertype, it should be in a separate package. I think that it is not worth pursuing convincing types from other packages to inherit from Domain: making the interface easier to work with is clearly the way to go. I've found that few other domain-like types implement Based on this, for now I prefer the second option above: we register DomainSetsCore, move the definition of Domain{T} there, and make no other changes. That allows to experiment with domains as an interface, hopefully fix and improve things, and then move on. As for IntervalSets, I believe the goal should be that the simplest possible sensible definition of an interval, namely struct Interval{T}
a::T
b::T
end should "just work". That won't work yet with option 2 above. For anyone wishing to do computations with such intervals as a continuous set, a good question to ask is: how does one (i) discover and (ii) control the type being returned by |
Regarding discovery, there is I think that if we adopt the struct proposed above, we should just convert every sampled type to the For controlling the type returned, one option would be struct Interval{T, A, B}
a::A
b::B
end This has the added benefit of allowing different endpoint types, which could be useful for, e.g. |
Sorry for the late response.
I think the following definitions would be acceptable. Base.eltype(::Type{<:Interval}) # This is not defined
Random.gentype(::Type{Interval{L,R,T}}) where {L,R,T} = float(T)
Base.boundstype(::Type{Interval{L,R,T}}) where {L,R,T} = T
DomainSetsCore.domaineltype(::Type{Interval{L,R,T}} = float(T) # I don't have usecases of this method currently, but this would be useful in DomainSets.jl, right? |
Closes #115
and #122.We had a long discussion about
eltype
, and I believe removing them is the best. (#115 (comment))eltype
should not be defined for non-iterable object