Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add pythonic aliases for comparison predicates. #553

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file.

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

### v0.17.6
* Add pythonic aliases for comparison predicates.

### v0.17.5
* Eliminated deprecation warnings involved arrays containing arrays/sequences.
* Changed the column type of a table after a remove operation back to a NumPy array, as written in the documentation.
Expand Down
43 changes: 43 additions & 0 deletions datascience/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,49 @@ def not_containing(substring):
def not_contained_in(superstring):
"""A string that is not contained within the superstring"""
return -(are.contained_in(superstring))

###############
# Aliases #
###############

@staticmethod
def less_than(y):
"""Less than y."""
return are.below(y)

@staticmethod
def greater_than(y):
"""Greater than y."""
return are.above(y)

@staticmethod
def greater_than_or_equal_to(y):
return are.above_or_equal_to(y)

@staticmethod
def less_than_or_equal_to(y):
return are.below_or_equal_to(y)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on: https://coveralls.io/builds/55559799/source?filename=datascience%2Fpredicates.py

We're missing test coverage on this method and a few others. The tests you've created are fantastic so far, if you could please add a few more for the missing test methods - this should be mergeable!


@staticmethod
def not_greater_than_or_equal_to(y):
"""Is neither above y nor equal to y"""
return are.not_above_or_equal_to(y)

@staticmethod
def not_less_than_or_equal_to(y):
"""Is neither below y nor equal to y"""
return are.not_below_or_equal_to(y)

@staticmethod
def not_greater_than(y):
"""Is not above y"""
return are.not_above(y)

@staticmethod
def not_less_than(y):
"""Is not below y"""
return are.not_below(y)

###############
# Combination #
###############
Expand Down