Fork me on GitHub
#juxt
<
2019-11-06
>
Andreas Edvardsson15:11:48

What are the semantics of tick intervals? Are they closed-closed , closed-open or something else in regards to the beginning and end instants?

(tick/relation
  (tick/new-interval #inst “2000” #inst “2010”)
  (tick/new-interval #inst “2010” #inst “2020”))
;; => :meets
Indicates that they are disjoint (closed-open or open-closed), but
(tick.core/coincident?
  (tick/new-interval #inst “2000” #inst “2010”)
  #inst “2000”))
;; => true
(tick.core/coincident?
  (tick/new-interval #inst “2000” #inst “2010”)
  #inst “2010”))
;; => true
Indicates that both the beginning and end instants are considered to belong to an interval.

jjttjj19:11:09

@andreas179 I could be wrong but I believe the concept of the interval alegbra (which the relation function uses) has no concept of closed/open, just of its 13 relations (https://en.wikipedia.org/wiki/Allen%27s_interval_algebra). I believe this allows you to decide whether your intervals will be open on either end in your code (it could depend on context)

jjttjj19:11:46

It's possible all of the tick code might not be consistent with this. I believe the preferred entry point for tick is tick.alpha.api and generally for working with intervals i think you'll mostly want to work with the stuff in tick.interval that is exposed there

jjttjj19:11:47

I do see now that this kind of breaks down when you're comparing a point to an event, as you are in your example

Andreas Edvardsson19:11:28

Allright, it’s mostly the functions that tick provides in its interval ns that i’m interested about :) disjoint may be a more appropriate example, whether two intervals are considered disjoint or not? What I’m ultimately trying to accomplish is to merge an interval on top of a collection of other intervals, and I was looking to see whether tick provides some suitable fns or not. There seems to be some interesting ones in the interval namespace, and whether intervals are treated as closed-closed or closed-open etc. (I believe) impacts the expected behaviour of the functions. I’m not entirely sure my thought are up to standards on this matter, so maybe this can serve as a hint that a note on the semantics would be great for documentation purposes, and possibly a check that the interval fns are consistent in this regard :) Many thanks for the work on the library, though!

jjttjj19:11:12

I didn't make the library, just a fan 🙂

jjttjj19:11:40

It was useful to me to look at the tick.interval namespace a bunch when working with intervals

jjttjj19:11:22

for instance you can see here https://github.com/juxt/tick/blob/master/src/tick/interval.cljc#L272 the relations satisfy disjoint

jjttjj19:11:20

Also if you haven't seen it yet, I've used this little javascript demo of the relations a lot: https://juxt.pro/tick/docs/index.html#_comparison_4

jjttjj19:11:17

thinking about it more, i think you're right that the tick intervals would be open at both ends when you put it into that context, but I believe you can get more leverage out of using the algebra terms instead in a lot of situations

Andreas Edvardsson19:11:44

Ye, looking at the src is a requirement when working with this, since the docs are a bit sparse on much of the fns. Just knowing the intended semantics would not only make it possible to verify that the behaviour is the intended, but also help with the initial on boarding. Anyhow, I guess I will make things work :)