Skip to content

Commit 965a13e

Browse files
committed
more expression expectation confirm tests
1 parent e735921 commit 965a13e

File tree

4 files changed

+67
-19
lines changed

4 files changed

+67
-19
lines changed

coverage.txt

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
platform darwin -- Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
33
rootdir: /Users/johnmount/Documents/work/data_algebra
44
plugins: cov-2.12.1, anyio-2.2.0, typeguard-2.13.0
5-
collected 264 items
5+
collected 265 items
66

77
tests/test_OrderedSet.py .... [ 1%]
88
tests/test_agg.py . [ 1%]
@@ -27,37 +27,37 @@ tests/test_data_model_isolation.py . [ 15%]
2727
tests/test_db_handle.py .. [ 15%]
2828
tests/test_db_model.py . [ 16%]
2929
tests/test_degenerate_project.py . [ 16%]
30-
tests/test_drop_columns.py . [ 17%]
30+
tests/test_drop_columns.py . [ 16%]
3131
tests/test_ex_examples.py ............ [ 21%]
3232
tests/test_example1.py .... [ 23%]
3333
tests/test_exp.py . [ 23%]
3434
tests/test_exp_parens.py . [ 23%]
3535
tests/test_expr_parse.py . [ 24%]
36-
tests/test_expression_expectations.py . [ 24%]
37-
tests/test_extend.py ...... [ 26%]
36+
tests/test_expression_expectations.py .. [ 24%]
37+
tests/test_extend.py ...... [ 27%]
3838
tests/test_extend_order.py . [ 27%]
3939
tests/test_flow_text.py . [ 27%]
4040
tests/test_forbidden_calculation.py .. [ 28%]
41-
tests/test_free_fn.py . [ 28%]
41+
tests/test_free_fn.py . [ 29%]
4242
tests/test_get_methods_used.py . [ 29%]
4343
tests/test_ghost_col_issue.py . [ 29%]
44-
tests/test_idioms.py ................. [ 35%]
44+
tests/test_idioms.py ................. [ 36%]
4545
tests/test_if_else.py .... [ 37%]
46-
tests/test_incomplete_agg.py . [ 37%]
46+
tests/test_incomplete_agg.py . [ 38%]
4747
tests/test_join_check.py . [ 38%]
4848
tests/test_join_effects.py . [ 38%]
4949
tests/test_join_multi_key.py . [ 39%]
5050
tests/test_join_opt.py . [ 39%]
51-
tests/test_join_variations.py . [ 39%]
51+
tests/test_join_variations.py . [ 40%]
5252
tests/test_lark_parser.py ..... [ 41%]
5353
tests/test_logistic_example.py . [ 42%]
54-
tests/test_mapv.py .. [ 42%]
54+
tests/test_mapv.py .. [ 43%]
5555
tests/test_math.py . [ 43%]
56-
tests/test_method_catalog_issues.py .. [ 43%]
56+
tests/test_method_catalog_issues.py .. [ 44%]
5757
tests/test_minimum.py . [ 44%]
5858
tests/test_mod_fns.py .. [ 45%]
5959
tests/test_multi_map.py . [ 45%]
60-
tests/test_narrow.py . [ 45%]
60+
tests/test_narrow.py . [ 46%]
6161
tests/test_natural_join.py . [ 46%]
6262
tests/test_neg.py . [ 46%]
6363
tests/test_null_bad.py .. [ 47%]
@@ -67,21 +67,21 @@ tests/test_ops_eq.py . [ 48%]
6767
tests/test_or.py ..... [ 50%]
6868
tests/test_order_limit.py . [ 50%]
6969
tests/test_ordered_agg_group.py . [ 51%]
70-
tests/test_parse.py .......................... [ 60%]
71-
tests/test_project.py ..... [ 62%]
70+
tests/test_parse.py .......................... [ 61%]
71+
tests/test_project.py ..... [ 63%]
7272
tests/test_ranked_example.py . [ 63%]
7373
tests/test_readme_example.py . [ 63%]
7474
tests/test_ref_detect.py .. [ 64%]
7575
tests/test_rename.py . [ 64%]
76-
tests/test_round.py ... [ 65%]
76+
tests/test_round.py ... [ 66%]
7777
tests/test_scalar_columns.py . [ 66%]
7878
tests/test_scatter_example.py . [ 66%]
7979
tests/test_scoring_example.py . [ 67%]
8080
tests/test_select.py ... [ 68%]
8181
tests/test_select_stacking.py . [ 68%]
8282
tests/test_select_values.py .. [ 69%]
8383
tests/test_set_quoting.py ...... [ 71%]
84-
tests/test_shorten.py . [ 71%]
84+
tests/test_shorten.py . [ 72%]
8585
tests/test_sign_parse.py .. [ 72%]
8686
tests/test_simple.py .... [ 74%]
8787
tests/test_simple_expr.py . [ 74%]
@@ -93,7 +93,7 @@ tests/test_sqlite_joins.py ... [ 83%]
9393
tests/test_std_var.py ... [ 84%]
9494
tests/test_strat_example.py .. [ 85%]
9595
tests/test_sum_cumsum.py . [ 85%]
96-
tests/test_sum_one.py . [ 85%]
96+
tests/test_sum_one.py . [ 86%]
9797
tests/test_t_test_example.py .. [ 86%]
9898
tests/test_table_is_key_by_columns.py . [ 87%]
9999
tests/test_table_q.py . [ 87%]
@@ -116,7 +116,7 @@ data_algebra/MySQL.py 31 3 90% 16-17, 79
116116
data_algebra/OrderedSet.py 73 9 88% 32, 44, 47, 53, 56, 59, 62, 65, 68
117117
data_algebra/PostgreSQL.py 23 2 91% 15-16
118118
data_algebra/SQLite.py 167 16 90% 81, 97-98, 119, 127, 159, 196, 217, 237-241, 371, 410, 415
119-
data_algebra/SparkSQL.py 85 12 86% 17-18, 22-24, 84, 88-89, 187, 198-199, 211
119+
data_algebra/SparkSQL.py 85 7 92% 17-18, 84, 187, 198-199, 211
120120
data_algebra/__init__.py 5 0 100%
121121
data_algebra/arrow.py 142 27 81% 42, 49, 53-54, 63, 66, 70, 89, 93, 99, 110-113, 118, 126, 133, 154, 157, 170-171, 198, 207, 252, 254, 256, 260
122122
data_algebra/cdata.py 364 66 82% 42, 44, 48, 50, 58, 60-61, 67, 71, 74, 79, 81-84, 92, 100, 104-105, 137, 195, 197, 203, 208, 237, 259, 284, 288, 291-294, 298, 308, 373, 377, 383, 386, 403, 405, 407, 410, 413, 420-422, 439-444, 463, 495, 501-504, 513, 536-541, 552, 587, 608, 613, 618, 623, 627
@@ -140,7 +140,7 @@ data_algebra/solutions.py 64 1 98% 59
140140
data_algebra/test_util.py 294 39 87% 87, 107, 117, 120, 124, 147, 150, 154, 157, 166, 240-241, 252-257, 261, 273, 275-283, 329, 332, 340, 351, 358, 362, 373, 384, 557-562, 568-569, 572
141141
data_algebra/util.py 140 29 79% 26, 51, 56, 61, 84-85, 88-89, 92-93, 96-97, 100-101, 104-105, 108-109, 112-113, 116-117, 120-121, 192, 207, 248, 252, 254
142142
--------------------------------------------------------------------
143-
TOTAL 5445 712 87%
143+
TOTAL 5445 707 87%
144144

145145

146-
======================= 264 passed in 2480.23s (0:41:20) =======================
146+
======================= 265 passed in 2626.72s (0:43:46) =======================
0 Bytes
Binary file not shown.

dist/data_algebra-1.3.0.tar.gz

12 Bytes
Binary file not shown.

tests/test_expression_expectations.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11

2+
"""direct tests from op catalog"""
3+
24
import os
35
import pickle
46
import gzip
@@ -44,6 +46,7 @@ def test_expression_expectations_1():
4446
for c in too_expensive_to_include_in_rechecks:
4547
to_skip.add(c)
4648
if len(to_skip) < len(to_test):
49+
# goes into cache
4750
data_algebra.test_util.check_transform(
4851
ops=ops,
4952
data=d,
@@ -56,3 +59,48 @@ def test_expression_expectations_1():
5659
# re-run, but don't check value
5760
res = ops.transform(d)
5861
assert data_algebra.default_data_model.is_appropriate_data_instance(res)
62+
63+
64+
def test_expression_expectations_direct():
65+
dir_path = os.path.dirname(os.path.realpath(__file__))
66+
# https://github.com/WinVector/data_algebra/blob/main/Examples/Methods/data_algebra_catalog.ipynb
67+
# includes not cached tests
68+
expectation_path = os.path.join(dir_path, "expr_expectations.pkl.gz")
69+
with gzip.open(expectation_path, 'rb') as in_f:
70+
expectation_map = pickle.load(in_f)
71+
d = expectation_map['d']
72+
e_expectations = expectation_map['e_expectations']
73+
g_expectations = expectation_map['g_expectations']
74+
w_expectations = expectation_map['w_expectations']
75+
u_results = expectation_map['u_results']
76+
ops_list = e_expectations + g_expectations + w_expectations
77+
db_handles = data_algebra.test_util.get_test_dbs()
78+
for h in db_handles:
79+
h.insert_table(d, table_name='d', allow_overwrite=True)
80+
for op, op_class, exp, ops, expect in ops_list:
81+
if data_algebra.default_data_model.is_appropriate_data_instance(expect):
82+
res = ops.transform(d)
83+
assert data_algebra.test_util.equivalent_frames(res, expect)
84+
matching = methods_table.loc[methods_table['expression'] == exp, :]
85+
if matching.shape[0] == 1:
86+
to_test = {c for c in matching.columns if 'Model' in c}
87+
for h in db_handles:
88+
model_name = str(h.db_model)
89+
if (model_name in to_test) and (matching[model_name].values[0] == 'y'):
90+
res_db = h.read_query(ops)
91+
assert data_algebra.test_util.equivalent_frames(res_db, expect)
92+
for op, op_class, exp, ops, expect in u_results:
93+
if data_algebra.default_data_model.is_appropriate_data_instance(expect):
94+
res = ops.transform(d)
95+
assert data_algebra.default_data_model.is_appropriate_data_instance(res)
96+
matching = methods_table.loc[methods_table['expression'] == exp, :]
97+
if matching.shape[0] == 1:
98+
to_test = {c for c in matching.columns if 'Model' in c}
99+
for h in db_handles:
100+
model_name = str(h.db_model)
101+
if (model_name in to_test) and (matching[model_name].values[0] == 'y'):
102+
res_db = h.read_query(ops)
103+
assert data_algebra.default_data_model.is_appropriate_data_instance(res_db)
104+
for h in db_handles:
105+
h.drop_table('d')
106+
h.close()

0 commit comments

Comments
 (0)