Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
test suite for np.datetime64 fetchwhere functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
apalepu23 committed Mar 29, 2018
1 parent dcb286b commit 1b4b5e3
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions bcolz/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,25 @@ def test05(self):
self.assertEqual(l, N - 1)
self.assertEqual(s, (N - 1) * (N / 2)) # Gauss summation formula

def test06(self):
"""Testing `fetchwhere` method off of a timestamp (pd.datetime64)"""
N = self.N
ra = np.fromiter(((i, i * 2., i * 3)
for i in xrange(N)), dtype='i4,f8,i8')
t = bcolz.ctable(ra)
ct = t.fetchwhere('f1 < f2')
l, s = len(ct), ct['f0'].sum()
self.assertEqual(l, N - 1)
self.assertEqual(s, (N - 1) * (N / 2)) # Gauss summation formula

query_idx = np.random.randint(0, self.N)
t = bcolz.fromiter(((i, np.datetime64('2018-03-01') + i) for i in range(N)), dtype="i4,M8[D]", count=N)
threshold = t[query_idx][1]
result = t.fetchwhere('(f1 > threshold)', user_dict={'threshold': threshold})
t_fin = bcolz.fromiter(((i + query_idx, threshold + i) for i in range(1, N - query_idx)), dtype="i4,M8[D]",
count=N)
np.testing.assert_array_equal(result[:], t_fin[:])


class small_fetchwhereTest(fetchwhereTest, TestCase):
N = 120
Expand Down

0 comments on commit 1b4b5e3

Please sign in to comment.