-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_constrain.py
29 lines (21 loc) · 905 Bytes
/
test_constrain.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import unittest
import numpy as np
from dapclient.handlers.lib import BaseHandler
from dapclient.parsers import parse_ce
from .datasets import D1
class TestConstrain(unittest.TestCase):
def test_no_ce(self):
data = np.rec.fromrecords(
D1.Drifters.data.tolist(), names=list(D1.Drifters.keys())
)
projection, selection = parse_ce("")
dataset = BaseHandler(D1).parse(projection, selection)
np.testing.assert_array_equal(data, dataset.Drifters.data)
def test_filtering(self):
data = np.rec.fromrecords(
D1.Drifters.data.tolist(), names=list(D1.Drifters.keys())
)
filtered = data[data["longitude"] < 999]
projection, selection = parse_ce("Drifters.longitude<999")
dataset = BaseHandler(D1).parse(projection, selection)
np.testing.assert_array_equal(filtered, dataset.Drifters.data)