Skip to content

Commit

Permalink
Merge pull request #274 from data-8/add_docs_for_predicates
Browse files Browse the repository at this point in the history
Add documentation reference for predicates module
  • Loading branch information
papajohn committed Feb 21, 2017
2 parents 550a9fc + 7b40469 commit 7a7ca82
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 10 deletions.
62 changes: 52 additions & 10 deletions datascience/predicates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

__all__ = ['are']


class are:
"""Predicate functions. The class is named "are" for calls to where.
Expand Down Expand Up @@ -149,6 +150,55 @@ def contained_in(superstring):
"""A string that is part of the given superstring."""
return _combinable(lambda x: x in superstring)

@staticmethod
def not_equal_to(y):
"""Is not equal to y"""
return -(are.equal_to(y))

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

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

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

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

@staticmethod
def not_strictly_between(y, z):
"""Is equal to y or equal to z or less than y or greater than z"""
return -(are.strictly_between(y,z))

@staticmethod
def not_between(y, z):
"""Is equal to y or less than y or greater than z"""
return -(are.between(y,z))

@staticmethod
def not_between_or_equal_to(y,z):
"""Is less than y or greater than z"""
return -(are.between_or_equal_to(y,z))

@staticmethod
def not_containing(substring):
"""A string that does not contain substring"""
return -(are.containing(substring))

@staticmethod
def not_contained_in(superstring):
"""A string that is not contained within the superstring"""
return -(are.contained_in(superstring))
###############
# Combination #
###############
Expand Down Expand Up @@ -187,13 +237,5 @@ def _equal_or_float_equal(x, y):
else:
return x == y

are.not_equal_to = _not(are.equal_to)
are.not_above = are.below_or_equal_to
are.not_below = are.above_or_equal_to
are.not_below_or_equal_to = are.above
are.not_above_or_equal_to = are.below
are.not_strictly_between = _not(are.strictly_between)
are.not_between = _not(are.between)
are.not_between_or_equal_to = _not(are.between_or_equal_to)
are.not_containing = _not(are.containing)
are.not_contained_in = _not(are.contained_in)


1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ Reference

tables
maps
predicates
formats
util
6 changes: 6 additions & 0 deletions docs/predicates.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Predicates (``datascience.predicates``)
=======================================

.. automodule:: datascience.predicates
:members:
:undoc-members:

0 comments on commit 7a7ca82

Please sign in to comment.