Skip to content

Commit

Permalink
Merge 1388abf into 630d3cb
Browse files Browse the repository at this point in the history
  • Loading branch information
jefftrull committed Sep 11, 2021
2 parents 630d3cb + 1388abf commit 007f4e2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions portion/dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,14 @@ def as_dict(self):

def __getitem__(self, key):
if isinstance(key, Interval):
# No need to consider intervals with left boundary > key.upper
max_key = (key.upper, True)

items = []
for i, v in self._storage.items():
for i in self._storage.irange_key(max_key=max_key):
intersection = key & i
if not intersection.empty:
items.append((intersection, v))
items.append((intersection, self._storage[i]))
return IntervalDict._from_items(items)
else:
for i, v in self._storage.items():
Expand Down

0 comments on commit 007f4e2

Please sign in to comment.