Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #106448

Re: ANN: intervalset Was: Set type for datetime intervals

From Oscar Benjamin <oscar.j.benjamin@gmail.com>
Newsgroups comp.lang.python
Subject Re: ANN: intervalset Was: Set type for datetime intervals
Date 2016-04-04 16:32 +0100
Message-ID <mailman.23.1459783974.32530.python-list@python.org> (permalink)
References <56FE0625.5030901@shopzeus.com> <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com> <570213CB.8040101@shopzeus.com> <1459782597.3444051.568344234.048046C6@webmail.messagingengine.com> <CAHVvXxRRmJKHq-H8xotY9yF+pzG+7NOSMhOwTbL4qF-N4XjTfQ@mail.gmail.com>

Show all headers | View raw


On 4 April 2016 at 16:09, Random832 <random832@fastmail.com> wrote:
> On Mon, Apr 4, 2016, at 03:12, Nagy László Zsolt wrote:
>>
>>   Hi All,
>>
>> If anyone is interested, a module was born:
>>
>> https://bitbucket.org/nagylzs/intervalset
>> https://pypi.python.org/pypi/intervalset/0.1.1
>
> I don't know if I like it being immutable. Maybe have separate mutable
> and immutable versions.
>
> Like I said before, I don't think the set-like operations on Intervals
> are useful - what can you accomplish with them rather than by making a
> set consisting of only one interval and doing operations on that?

I guess it depends what your application is but sympy has interval
sets and can do computation on them to represent the solutions of
equations/inequalities (many other types of set are also included).
For example:

In [1]: from sympy import Interval

In [2]: Interval
Out[2]: sympy.core.sets.Interval

In [3]: Interval(1, 2)
Out[3]: [1, 2]

In [4]: help(Interval)


In [5]: Interval(1, 2) & Interval(3, 4)
Out[5]: ∅

In [6]: Interval(1, 2) | Interval(3, 4)
Out[6]: [1, 2] ∪ [3, 4]

There is some discussion about why it's good to do this stuff with
sets (for sympy's purposes here):
http://docs.sympy.org/latest/modules/solvers/solveset.html#why-do-we-use-sets-as-an-output-type

--
Oscar

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: ANN: intervalset Was: Set type for datetime intervals Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-04-04 16:32 +0100

csiph-web