Skip to content

Commit d28bf14

Browse files
authored
Merge 2c833a0 into 8d3fb1e
2 parents 8d3fb1e + 2c833a0 commit d28bf14

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44

55
This project adheres to [Semantic Versioning](http://semver.org/).
66

7+
### v0.17.7
8+
* Add pythonic aliases for comparison predicates.
9+
* Add alias tests to test_predicates.py
10+
711
### v0.17.6
812
* Removed a deprecated function which allowed calling non-table attributes on a table.
913
* Removed a deprecated function which created an empty table.

datascience/predicates.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,49 @@ def not_containing(substring):
211211
def not_contained_in(superstring):
212212
"""A string that is not contained within the superstring"""
213213
return -(are.contained_in(superstring))
214+
215+
###############
216+
# Aliases #
217+
###############
218+
219+
@staticmethod
220+
def less_than(y):
221+
"""Less than y."""
222+
return are.below(y)
223+
224+
@staticmethod
225+
def greater_than(y):
226+
"""Greater than y."""
227+
return are.above(y)
228+
229+
@staticmethod
230+
def greater_than_or_equal_to(y):
231+
return are.above_or_equal_to(y)
232+
233+
@staticmethod
234+
def less_than_or_equal_to(y):
235+
return are.below_or_equal_to(y)
236+
237+
@staticmethod
238+
def not_greater_than_or_equal_to(y):
239+
"""Is neither above y nor equal to y"""
240+
return are.not_above_or_equal_to(y)
241+
242+
@staticmethod
243+
def not_less_than_or_equal_to(y):
244+
"""Is neither below y nor equal to y"""
245+
return are.not_below_or_equal_to(y)
246+
247+
@staticmethod
248+
def not_greater_than(y):
249+
"""Is not above y"""
250+
return are.not_above(y)
251+
252+
@staticmethod
253+
def not_less_than(y):
254+
"""Is not below y"""
255+
return are.not_below(y)
256+
214257
###############
215258
# Combination #
216259
###############

tests/test_predicates.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,46 @@ def test_between_or_equal_to():
6363
ps = [p(x) for x in range(1, 6)]
6464
assert ps == [False, False, True, False, False]
6565

66+
#############
67+
# Aliases #
68+
#############
69+
70+
def test_greater_than_and_less_than():
71+
"""Both f and g."""
72+
p = are.greater_than(2) & are.less_than(4)
73+
ps = [p(x) for x in range(1, 6)]
74+
assert ps == [False, False, True, False, False]
75+
76+
def test_greater_than_or_less_than():
77+
"""Either f or g."""
78+
p = are.greater_than(3) | are.less_than(2)
79+
ps = [p(x) for x in range(1, 6)]
80+
assert ps == [True, False, False, True, True]
81+
82+
def test_greater_than():
83+
"""Greater than y."""
84+
p = are.greater_than(3)
85+
ps = [p(x) for x in range(1, 6)]
86+
assert ps == [False, False, False, True, True]
87+
88+
def test_less_than():
89+
"""Less than y."""
90+
p = are.not_less_than(4)
91+
ps = [p(x) for x in range(1, 6)]
92+
assert ps == [False, False, False, True, True]
93+
94+
def test_greater_than_or_equal_to():
95+
"""Greater than or equal to y."""
96+
p = are.greater_than_or_equal_to(4)
97+
ps = [p(x) for x in range(1, 6)]
98+
assert ps == [False, False, False, True, True]
99+
100+
def test_less_than_or_equal_to():
101+
"""Less than or equal to y."""
102+
p = are.not_less_than_or_equal_to(3)
103+
ps = [p(x) for x in range(1, 6)]
104+
assert ps == [False, False, False, True, True]
105+
66106

67107
############
68108
# Doctests #

0 commit comments

Comments
 (0)