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


Groups > comp.lang.python > #106425

ANN: intervalset Was: Set type for datetime intervals

Path csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail
From Nagy László Zsolt <gandalf@shopzeus.com>
Newsgroups comp.lang.python
Subject ANN: intervalset Was: Set type for datetime intervals
Date Mon, 4 Apr 2016 09:12:11 +0200
Lines 54
Message-ID <mailman.3.1459753937.32530.python-list@python.org> (permalink)
References <56FE0625.5030901@shopzeus.com> <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com> <570213CB.8040101@shopzeus.com>
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding quoted-printable
X-Trace news.uni-berlin.de GJ5LwDcyUp5mfAbWI29bqQUUFNRbJjs0zYWRS4ovxG+Q==
Return-Path <gandalf@shopzeus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'url:pypi': 0.03; 'url:bitbucket': 0.05; 'smallest': 0.07; 'subject:ANN': 0.07; 'tests,': 0.07; 'welcome.': 0.07; 'closed.': 0.09; '::=': 0.16; 'bitbucket.': 0.16; 'comparison.': 0.16; 'correctly,': 0.16; 'dependent.': 0.16; 'element2,': 0.16; 'increment': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'singleton': 0.16; 'subject:Was': 0.16; 'subject:type': 0.16; 'element': 0.18; 'implementing': 0.18; 'thoughts': 0.18; 'all,': 0.20; '(the': 0.22; 'correctly.': 0.22; 'sets': 0.23; 'this:': 0.23; 'implemented': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; 'compare': 0.27; 'right.': 0.27; 'skip:( 20': 0.28; 'relies': 0.29; 'comments': 0.30; 'operations': 0.31; 'anyone': 0.32; 'maybe': 0.33; 'useful': 0.33; 'url:python': 0.33; 'instances': 0.33; 'open': 0.33; 'handle': 0.34; 'best,': 0.35; 'could': 0.35; 'unit': 0.35; 'but': 0.36; 'there': 0.36; 'url:org': 0.36; 'possible': 0.36; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'two': 0.37; 'being': 0.37; 'sources': 0.37; 'starting': 0.37; 'difference': 0.38; 'version': 0.38; 'rather': 0.39; 'to:addr:python.org': 0.40; 'hello,': 0.40; 'some': 0.40; 'skip:n 10': 0.62; 'ending': 0.63; 'more': 0.63; 'url:0': 0.63; 'below.': 0.66; 'interested,': 0.69; 'testers': 0.84; 'union,': 0.84; 'difficult,': 0.91; 'subject:Set': 0.91
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=shopzeus.com; s=shopzeus_com; t=1459753929; bh=JrwiCvv1DbcO/0P2I7TSSW9+32cxJsI/qhreIRVV9Eg=; h=Subject:To:References:From:Date:In-Reply-To:From; b=FpTPkIJw18Y0hg7+nza2Y55Zbv52ATiohK8VmRx495amndWoEP0aop/OFucqSFrj+ rW9UIh3XtX6P7eDZ0moF0YKT38BjgpEx/BGxVRgJQ3rKvCDRQdHA75GhPAqa290P8G SPMSWr3pAZJKphgSR62MKtqgQza8lCic/yYwvMeMl2MwHE3qlyWOQvjzcDYKXhe/M0 Qm103tno8rYqJjBiVRKbyBaqCsuyCGffFndDK9kO05mR18nFQsruZI5MhI1sBvDdmK VbRtaxKkbsJRw7l47E/Wum9qIZgfdv1byI7ZTGJg3AgcfiJC+T2L3JIoUNsmDhJfu1 yy8NMHTKs9K9A==
In-Reply-To <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.21
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID <570213CB.8040101@shopzeus.com>
X-Mailman-Original-References <56FE0625.5030901@shopzeus.com> <1459523394.2611014.565840994.593DD99A@webmail.messagingengine.com>
Xref csiph.com comp.lang.python:106425

Show key headers only | View raw


  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 have some unit tests, but testers and comments are welcome.

Also see below.

>>  
>>   Hello,
>>
>> I need to compare sets of datetime intervals, and make set operations on
>> them: intersect, union, difference etc. One element of a set would be an
>> interval like this:
> Two thoughts on this: Such an object is not precisely a set* of
> datetimes, rather it is a set of nonintersecting intervals. 

Yes, you are right. It is a set of non-intersecting intervals.

> It could
> also be useful to have one for numbers (the datetime version could even
> maybe be implemented in terms of it)
Well, please check sources on bitbucket. You are more than welcome to
join the project.
>
>> element ::= (start_point_in_time, end_point_in_time)
>> intervalset ::= { element1, element2, .... }
> Are these open intervals or closed intervals?
Closed. In my particular implementation, there is a singleton for all
empty intervals. It is not possible to create an arbitrary interval with
the same starting and ending time (the singleton being the only
exception). I think that implementing open intervals would be much more
difficult, and we would have to know and use the smallest possible
increment (resolution) of the date/time type. Which may be platform
dependent.
>
> Also, how are you going to handle daylight savings?
Well, this little module only uses datetime instances and relies on the
datetime module for comparison. As far as datetime instances compare
correctly, this module will also work correctly.

Best,

   Laszlo


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


Thread

ANN: intervalset Was: Set type for datetime intervals Nagy László Zsolt <gandalf@shopzeus.com> - 2016-04-04 09:12 +0200

csiph-web