Skip to content

Commit 8100c87

Browse files
committed
test some expression shortening
1 parent ebda205 commit 8100c87

File tree

4 files changed

+57
-28
lines changed

4 files changed

+57
-28
lines changed

coverage.txt

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,41 @@
22
platform darwin -- Python 3.6.9, pytest-5.2.2, py-1.8.0, pluggy-0.13.0
33
rootdir: /Users/johnmount/Documents/work/data_algebra
44
plugins: cov-2.8.1
5-
collected 60 items
5+
collected 61 items
66

77
tests/test_R_yaml.py . [ 1%]
88
tests/test_apply.py . [ 3%]
9-
tests/test_arrow1.py . [ 5%]
9+
tests/test_arrow1.py . [ 4%]
1010
tests/test_calc_warnings_errors.py . [ 6%]
1111
tests/test_cc.py ...... [ 16%]
1212
tests/test_cdata1.py . [ 18%]
13-
tests/test_cdata_example.py .... [ 25%]
13+
tests/test_cdata_example.py .... [ 24%]
1414
tests/test_cols_used.py . [ 26%]
15-
tests/test_concat_rows.py . [ 28%]
16-
tests/test_degenerate_project.py . [ 30%]
15+
tests/test_concat_rows.py . [ 27%]
16+
tests/test_degenerate_project.py . [ 29%]
1717
tests/test_drop_columns.py . [ 31%]
1818
tests/test_exampe1.py ... [ 36%]
19-
tests/test_example_data_ops.py . [ 38%]
20-
tests/test_exp.py . [ 40%]
21-
tests/test_export_neg.py . [ 41%]
22-
tests/test_expr_parse.py . [ 43%]
23-
tests/test_extend.py ... [ 48%]
24-
tests/test_flow_text.py . [ 50%]
25-
tests/test_free_expr.py . [ 51%]
26-
tests/test_ghost_col_issue.py . [ 53%]
27-
tests/test_if_else.py . [ 55%]
28-
tests/test_join_check.py . [ 56%]
29-
tests/test_join_effects.py .. [ 60%]
30-
tests/test_math.py . [ 61%]
31-
tests/test_natural_join.py . [ 63%]
32-
tests/test_neg.py . [ 65%]
33-
tests/test_null_bad.py . [ 66%]
34-
tests/test_parse.py . [ 68%]
35-
tests/test_project.py ..... [ 76%]
36-
tests/test_scatter_example.py . [ 78%]
37-
tests/test_scoring_example.py . [ 80%]
38-
tests/test_select_stacking.py . [ 81%]
19+
tests/test_example_data_ops.py . [ 37%]
20+
tests/test_exp.py . [ 39%]
21+
tests/test_export_neg.py . [ 40%]
22+
tests/test_expr_parse.py . [ 42%]
23+
tests/test_extend.py ... [ 47%]
24+
tests/test_flow_text.py . [ 49%]
25+
tests/test_free_expr.py . [ 50%]
26+
tests/test_ghost_col_issue.py . [ 52%]
27+
tests/test_if_else.py . [ 54%]
28+
tests/test_join_check.py . [ 55%]
29+
tests/test_join_effects.py .. [ 59%]
30+
tests/test_math.py . [ 60%]
31+
tests/test_natural_join.py . [ 62%]
32+
tests/test_neg.py . [ 63%]
33+
tests/test_null_bad.py . [ 65%]
34+
tests/test_parse.py . [ 67%]
35+
tests/test_project.py ..... [ 75%]
36+
tests/test_scatter_example.py . [ 77%]
37+
tests/test_scoring_example.py . [ 78%]
38+
tests/test_select_stacking.py . [ 80%]
39+
tests/test_shorten.py . [ 81%]
3940
tests/test_simple.py ..... [ 90%]
4041
tests/test_spark_sql.py . [ 91%]
4142
tests/test_sqlite.py . [ 93%]
@@ -56,7 +57,7 @@ data_algebra/cdata.py 228 77 66%
5657
data_algebra/cdata_impl.py 13 1 92%
5758
data_algebra/connected_components.py 49 1 98%
5859
data_algebra/data_model.py 44 16 64%
59-
data_algebra/data_ops.py 1242 278 78%
60+
data_algebra/data_ops.py 1242 275 78%
6061
data_algebra/db_model.py 389 76 80%
6162
data_algebra/diagram.py 56 43 23%
6263
data_algebra/env.py 52 7 87%
@@ -68,7 +69,7 @@ data_algebra/test_util.py 6 0 100%
6869
data_algebra/util.py 93 13 86%
6970
data_algebra/yaml.py 123 15 88%
7071
----------------------------------------------------------
71-
TOTAL 3404 821 76%
72+
TOTAL 3404 818 76%
7273

7374

74-
============================== 60 passed in 6.29s ==============================
75+
============================== 61 passed in 7.36s ==============================
0 Bytes
Binary file not shown.

dist/data_algebra-0.3.4.tar.gz

0 Bytes
Binary file not shown.

tests/test_shorten.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
import pandas
3+
4+
from data_algebra.data_ops import *
5+
6+
7+
def test_shorten():
8+
d = pandas.DataFrame({
9+
'x_s': ['s_03', 's_04', 's_02', 's_01', 's_03', 's_01'],
10+
'x_n': ['n_13', 'n_48', 'n_77', 'n_29', 'n_91', 'n_93'],
11+
'y': [1.0312223, -1.3374379, -1.9347144, 1.2772708, -0.1238039, 0.3058670],
12+
})
13+
table_desc = describe_table(d, table_name='d')
14+
15+
ops1 = table_desc. \
16+
order_rows(['x_s'])
17+
assert isinstance(ops1, OrderRowsNode)
18+
19+
ops2 = ops1 .\
20+
extend({
21+
'y_mean': 'y.mean()'
22+
})
23+
assert not isinstance(ops2.sources[0], OrderRowsNode)
24+
25+
ops3 = ops1 .\
26+
select_columns(['x_s', 'y']) .\
27+
select_columns(['y'])
28+
assert not isinstance(ops2.sources[0], SelectColumnsNode)

0 commit comments

Comments
 (0)