Comments (4)
IMO the result of span
on [x,)
, [x,∞)
and [x,∞]
should all be the same. I think the error on unbounded intervals is a reasonable choice for now if we don't have a good way to implement that.
from intervals.jl.
Originally the plan was to use nothing
to represent an interval that was unbounded. However, when implementing this design we ran into troubles when implementing span
(the distance between the endpoints) for an unbounded interval. In this particular case it make the most sense to return some kind of infinity value. The current approach is to try and integrate Infinity.jl and see if we can add an infinity value for TimeType
s.
from intervals.jl.
Some rules around unbounded intervals that were though of during an initial design:
- For unbounded intervals
span
should return infinity - If the lower bound of a interval is unbounded then all points less than the upper bound are included in the interval
- If the upper bound of an interval is unbounded then all points greater than the lower bound are included in the interval
- When considering unbounded range's inclusiveness we should consider if infinity should be considered contained within the interval. e.g.
∞ in [0,∞) == false
as infinity is not actually included in this interval. More specifically all positive finite values are included in the interval but infinity is not. - An
AnchoredInterval
uses one point and a span to calculate the other endpoint. Conversion from anInterval
that uses one finite endpoint and another non-finite endpoint is impossible if the non-finite endpoint is the one used for theAnchoredInterval
. This is because it would be impossible to calculate the other endpoint from the single non-finite endpoint.
from intervals.jl.
After a discussion with @iamed2 it should be mentioned that intervals using infinity as an endpoint are not necessarily unbounded intervals. As mentioned in the last post [0,∞)
is a good example of this.
Take note that PostgreSQL supports timestamp ranges with infinity (e.g. [today,infinity]
, [today,infinity)
) and supports unbounded ranges (e.g. [today,)
). The main advantage I see of not relying on infinity for unbounded interval support is that you don't require the element type of the interval to have a representation for infinity meaning we unbounded support will work for more types and not require special type extensions like Infinity.jl provides.
Furthermore, if we use as the [today,infinity]
unbounded interval what should LibPQ.jl do when inserting into PostgreSQL? Most likely [today,infinity]
should be inserted which leaves us no way to insert [today,)
without a special flag.
The problem with special unbounded interval approach gets back to the issue with span
. With unbounded intervals what should be returned when the element type is say: Int
, Char
, or Float64
? The first two examples don't have a representation of infinity for those types which leaves (I believe) three options:
-
Have a special type that represents +/- infinity. Effectively this is what Infinity.jl does but we could would probably only represent infinity without the extension support. Probably:
struct Infinity{T} sign::Bool end
-
Have a special type from 1 but use the infinity representation of the current type one is available. We'd need an
inf(::Type{T})
for general support -
Raise an exception when using
span
on unbounded ranges. To support generic interval coding we'd also supply anisunbounded
function which allows us to avoid raising the exception. This allows the user to supply their own representation of infinity if they require this behaviour. I'll note this approach also seems the safest as it will be easier to move away from this approach in the future
I am personally leaning towards 3 as the best option as it appears the simplest.
from intervals.jl.
Related Issues (20)
- Support converting between `DateTime` and `ZonedDateTime` interval types HOT 6
- Constructor of Interval inherently type unstable? HOT 1
- Multirange type HOT 1
- CI failure: display tests fail on julia v1.7
- Transitive dependencies on TimeZones.jl HOT 1
- How do I make an unbounded interval? HOT 1
- TagBot trigger issue HOT 6
- Phase out `intersect(::AbstractInterval, ::AbstractInterval) -> AbstractInterval` HOT 1
- Unconventional definitions of inequality
- StepRangeLen broken for AnchoredIntervals on Julia 1.8
- stackoverflow from recursive call in `find_intersections`
- `union` example in doc is wrong
- Storing open-ness as a type parameter makes Postgres parsing type unstable HOT 4
- bug in `intersect` HOT 3
- Drop all hardcoded reference to ZonedDateTime
- Link not formatted properly in documentation
- Reconsider explict bounds parameters for anchored intervals
- Use Infinity.jl for representing Bounded vs Unbounded intervals HOT 1
- 0.0 <= Interval{Float64, Closed, Closed}(0.0, 1.0) returns false HOT 1
- Iterator interface on IntervalSet HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from intervals.jl.