Skip to content

Commit 05756fb

Browse files
committed
test exp round-trip
1 parent 5f7461f commit 05756fb

File tree

4 files changed

+55
-11
lines changed

4 files changed

+55
-11
lines changed

coverage.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@
22
platform darwin -- Python 3.6.9, pytest-5.0.1, py-1.8.0, pluggy-0.12.0
33
rootdir: /Users/johnmount/Documents/work/data_algebra
44
plugins: cov-2.7.1
5-
collected 17 items
5+
collected 18 items
66

77
tests/test_apply.py . [ 5%]
88
tests/test_cdata1.py . [ 11%]
9-
tests/test_dask.py .. [ 23%]
10-
tests/test_drop_columns.py . [ 29%]
11-
tests/test_example_data_ops.py . [ 35%]
12-
tests/test_natural_join.py . [ 41%]
13-
tests/test_neg.py . [ 47%]
14-
tests/test_null_bad.py . [ 52%]
15-
tests/test_parse.py . [ 58%]
16-
tests/test_poject.py . [ 64%]
17-
tests/test_scoring_example.py . [ 70%]
9+
tests/test_dask.py .. [ 22%]
10+
tests/test_drop_columns.py . [ 27%]
11+
tests/test_example_data_ops.py . [ 33%]
12+
tests/test_exp.py . [ 38%]
13+
tests/test_natural_join.py . [ 44%]
14+
tests/test_neg.py . [ 50%]
15+
tests/test_null_bad.py . [ 55%]
16+
tests/test_parse.py . [ 61%]
17+
tests/test_poject.py . [ 66%]
18+
tests/test_scoring_example.py . [ 72%]
1819
tests/test_simple.py .... [ 94%]
1920
tests/test_sqlite.py . [100%]
2021

@@ -42,4 +43,4 @@ data_algebra/yaml.py 76 11 86%
4243
TOTAL 2226 484 78%
4344

4445

45-
========================== 17 passed in 6.88 seconds ===========================
46+
========================== 18 passed in 6.57 seconds ===========================
0 Bytes
Binary file not shown.

dist/data_algebra-0.1.5.tar.gz

-7 Bytes
Binary file not shown.

tests/test_exp.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
2+
import numpy
3+
import pandas
4+
5+
import data_algebra
6+
import data_algebra.env
7+
import data_algebra.util
8+
import data_algebra.yaml
9+
from data_algebra.data_ops import *
10+
11+
12+
13+
def test_exp():
14+
# ask YAML to write simpler structures
15+
data_algebra.yaml.fix_ordered_dict_yaml_rep()
16+
17+
d_local = pandas.DataFrame({
18+
'subjectID': [1, 1, 2, 2],
19+
'surveyCategory': ["withdrawal behavior", "positive re-framing", "withdrawal behavior", "positive re-framing"],
20+
'assessmentTotal': [5, 2, 3, 4],
21+
})
22+
23+
scale = 0.237
24+
25+
with data_algebra.env.Env(locals()) as env:
26+
ops = TableDescription('d',
27+
['subjectID',
28+
'surveyCategory',
29+
'assessmentTotal']). \
30+
extend({'v': 'assessmentTotal.exp()'})
31+
32+
res_local = ops.transform(d_local)
33+
34+
expect = pandas.DataFrame({
35+
'subjectID': [1, 1, 2, 2],
36+
'surveyCategory': ["withdrawal behavior", "positive re-framing", "withdrawal behavior", "positive re-framing"],
37+
'assessmentTotal': [5, 2, 3, 4],
38+
'v': numpy.exp([5, 2, 3, 4]),
39+
})
40+
41+
assert data_algebra.util.equivalent_frames(res_local, expect, float_tol=1e-3)
42+
43+
data_algebra.yaml.check_op_round_trip(ops)

0 commit comments

Comments
 (0)