Skip to content

Commit

Permalink
remove query manager, which is never used
Browse files Browse the repository at this point in the history
  • Loading branch information
papajohn committed Feb 7, 2016
1 parent 4762baf commit 26786a9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 51 deletions.
19 changes: 1 addition & 18 deletions datascience/tables.py
@@ -1,6 +1,6 @@
"""Tables are sequences of labeled columns."""

__all__ = ['Table', 'Q']
__all__ = ['Table']

import abc
import collections
Expand Down Expand Up @@ -1789,23 +1789,6 @@ def __repr__(self):
return '{0}({1})'.format(type(self).__name__, repr(self._table))



class Q:
"""Query manager for Tables."""
array = None

def __init__(self, array):
"""save numpy array"""
self.array = array

def __and__(self, other):
"""allows bitwise & operations"""
return np.logical_and(self.array, other.array)

def __or__(self, other):
return np.logical_or(self.array, other.array)


def _zero_on_type_error(column_fn):
"""Wrap a function on an np.ndarray to return 0 on a type error."""
if not column_fn:
Expand Down
33 changes: 0 additions & 33 deletions tests/test_tables.py
Expand Up @@ -962,39 +962,6 @@ def test_scatter_error(table):
with pytest.raises(ValueError):
table.scatter('letter')

###########
# Queries #
###########


def test_q_and(table):
"""Test that Q performs logical AND correctly"""
test = table.where(Q(table['letter'] < 'c') & Q(table['points'] > 1))
assert_equal(test, """
letter | count | points
b | 3 | 2
""")


def test_q_or(table):
"""Test that Q performs logical OR correctly"""
test = table.where(Q(table['letter'] < 'b') | Q(table['points'] > 2))
assert_equal(test, """
letter | count | points
a | 9 | 1
z | 1 | 10
""")


def test_q_chaining(table):
"""Tests that successive Qs can be added"""
test_q_or_filter = Q(table['letter'] < 'b') | Q(table['points'] > 2)
test = table.where(Q(test_q_or_filter) & Q(table['count'] > 2))
assert_equal(test, """
letter | count | points
a | 9 | 1
""")

def test_df_roundtrip(table):
df = table.to_df()
assert isinstance(df, pd.DataFrame)
Expand Down

0 comments on commit 26786a9

Please sign in to comment.