taschini / pyinterval

PyInterval — Interval arithmetic in Python
http://pyinterval.readthedocs.io
Other
83 stars 25 forks source link

contains() not working for components? #19

Open nzqo opened 6 years ago

nzqo commented 6 years ago

I need to write a method that tells me if a set of intervals is contained in another. When trying on a single interval like such:

import interval as itv
tst = itv.interval([0,1],[-7,-1],[2,3])
def contains(itvset_a, itvset_b):
    for x,y in zip(itvset_a,itvset_b):
        if not x.__contains__(y):
            return False
    return True 
print(contains(tst,tst))

it returns False. However, it correctly zips up the components of the interval, meaning that for a component a.__contains__(a) is evaluated to False. Why is that? Note that changing the call to print(contains([tst5],[tst5])) works perfectly fine.