File tree Expand file tree Collapse file tree
src/pyuncertainnumber/pba/intervals Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -124,6 +124,18 @@ def __iter__(self): # https://realpython.com/introduction-to-python-generators/
124124 break
125125 pass
126126
127+ def __contains__ (self , item ):
128+ """Check if an item is enclosed within the interval.
129+
130+ example:
131+ >>> i = Interval(1,3)
132+ >>> 2 in i
133+ True
134+ >>> 4 in i
135+ False
136+ """
137+ return np .all ((item >= self .lo ) & (item <= self .hi ))
138+
127139 def __next__ (self ):
128140 pass
129141
Original file line number Diff line number Diff line change @@ -42,6 +42,16 @@ def test_env_pbox():
4242 assert b in t
4343
4444
45+ def test_env_intervals ():
46+ a = pba .I (2 , 6 )
47+ b = pba .I (- 2 , 9 )
48+ t = pba .envelope (a , b )
49+
50+ assert isinstance (t , pba .Interval )
51+ # assert a in t
52+ # assert b in t
53+
54+
4555# * ----------------------- imposition operation
4656
4757
You can’t perform that action at this time.
0 commit comments