Skip to content

Commit

Permalink
Refactored Range.left_of to a simple one liner
Browse files Browse the repository at this point in the history
  • Loading branch information
runfalk committed Mar 23, 2017
1 parent 004a38c commit 638adea
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions spans/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,6 @@ def empty(cls):
def is_valid_range(cls, obj):
return isinstance(obj, cls)


@classmethod
def is_valid_scalar(cls, obj):
return isinstance(obj, cls.type)
Expand Down Expand Up @@ -688,17 +687,7 @@ def left_of(self, other):
:return: ``True`` if this range is completely to the left of ``other``.
"""

if not self or not other:
# Handle empty ranges
return False
elif self.upper_inf or other.lower_inf:
return False
elif self.upper < other.lower:
return True
elif self.upper == other.lower:
return not self.upper_inc or not other.lower_inc
else:
return False
return self < other and not self.overlap(other)

def right_of(self, other):
"""
Expand Down

0 comments on commit 638adea

Please sign in to comment.