You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should implement floor, ceil, and round for intervals. Unfortunately there are some open questions around how to support rounding on intervals:
Which endpoint should be rounded? Left, right, both?
Should the span between the endpoints remain consistent?
Let's look at some examples of possible implementations. Let's start with rounding both endpoints:
julia>round(Interval(0.6, 1.6)) # Rounds both endpoints up, span remains the sameInterval{Float64,Closed,Closed}(1.0, 2.0)
julia>round(Interval(0.4, 1.4)) # Rounds both endpoints down, span remains the sameInterval{Float64,Closed,Closed}(0.0, 1.0)
julia>round(Interval(0.6, 1.4)) # Rounds left up and right down, span differsInterval{Float64,Closed,Closed}(1.0, 1.0)
julia>round(Interval(0.5, 1.5)) # Note: Behaviour due to default of `RoundNearest`Interval{Float64,Closed,Closed}(0.0, 2.0)
julia>round(Interval(1.5, 2.5))
Interval{Float64,Closed,Closed}(2.0, 2.0)
From looking at these examples rounding one endpoint up and one down definitely doesn't seem right.
Now let's take a look at some other where we floor both endpoints:
julia>floor(Interval(0.6, 1.4)) # Span was 0.8, after flooring is 1.0Interval{Float64,Closed,Closed}(0.0, 1.0)
julia>floor(Interval(0.1, 1.9)) # Span was 1.8, after flooring is 1.0Interval{Float64,Closed,Closed}(0.0, 1.0)
After seeing flooring both endpoints in practice I think that the span should probably remain the same after the operation.
This would mean that we should probably only perform round, floor, and ceil on a specified endpoint. Effectively, this just shifts the interval and the span always remains the same. Such an implementation also seems to work well for AnchoredInterval however we may want to have the option to round based on the anchor (which may be the left or right endpoint).
The text was updated successfully, but these errors were encountered:
For unbounded intervals if you attempt to floor/ceil/round the unbounded endpoint I would expect the interval to remain unchanged. Operating on the bounded endpoint would modify the bounded endpoint but leave the unbounded endpoint as unbounded. This would be consistent with how scalar arithmetic works with intervals.
We should implement
floor
,ceil
, andround
for intervals. Unfortunately there are some open questions around how to support rounding on intervals:Let's look at some examples of possible implementations. Let's start with rounding both endpoints:
From looking at these examples rounding one endpoint up and one down definitely doesn't seem right.
Now let's take a look at some other where we floor both endpoints:
After seeing flooring both endpoints in practice I think that the span should probably remain the same after the operation.
This would mean that we should probably only perform round, floor, and ceil on a specified endpoint. Effectively, this just shifts the interval and the span always remains the same. Such an implementation also seems to work well for
AnchoredInterval
however we may want to have the option to round based on the anchor (which may be the left or right endpoint).The text was updated successfully, but these errors were encountered: