Skip to content

Commit 7c744a8

Browse files
committed
rebuid and retest
1 parent 302a3f5 commit 7c744a8

File tree

8 files changed

+7390
-7175
lines changed

8 files changed

+7390
-7175
lines changed

build/lib/data_algebra/cdata.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import data_algebra.data_model
1111
import data_algebra.util
12+
import data_algebra.data_ops
1213

1314

1415
def _str_list_to_html(lst: Iterable[str]) -> str:
@@ -425,6 +426,10 @@ def transform(
425426
blocks_out=self.blocks_out,
426427
)
427428
return X
429+
430+
def act_on(self, X):
431+
assert isinstance(X, data_algebra.data_ops.ViewRepresentation)
432+
return X.convert_records(self)
428433

429434
def compose(self, other):
430435
"""
@@ -487,6 +492,40 @@ def compose(self, other):
487492
),
488493
strict=strict,
489494
)
495+
496+
def as_pipeline(self,
497+
*,
498+
table_name: Optional[str] = None,
499+
local_data_model=None,
500+
value_suffix: str = " value",
501+
record_key_suffix: str = " record key",
502+
):
503+
"""
504+
Build into processing pipeline.
505+
506+
:param table_name: name for input table.
507+
:param local_data_model: optional Pandas data model.
508+
:param value_suffix: suffix to identify values
509+
:param record_key_suffix: suffix to identify record keys
510+
:return: cdata operator as a pipeline
511+
"""
512+
assert isinstance(value_suffix, str)
513+
assert isinstance(record_key_suffix, str)
514+
exp_inp = self.example_input(
515+
local_data_model=local_data_model,
516+
value_suffix=value_suffix,
517+
record_key_suffix=record_key_suffix)
518+
ops = (
519+
data_algebra.data_ops.describe_table(
520+
exp_inp,
521+
table_name=table_name,
522+
row_limit=None,
523+
keep_sample=True,
524+
keep_all=True,
525+
)
526+
.convert_records(self)
527+
)
528+
return ops
490529

491530
def inverse(self):
492531
"""
@@ -496,6 +535,12 @@ def inverse(self):
496535
assert self.strict
497536
return RecordMap(blocks_in=self.blocks_out, blocks_out=self.blocks_in, strict=True)
498537

538+
def __rshift__(self, other): # override self >> other
539+
return self.act_on(other)
540+
541+
def __rrshift__(self, other): # override other >> self
542+
return self.transform(other)
543+
499544
def fmt(self) -> str:
500545
"""Format for informal presentation."""
501546
if (self.blocks_in is None) and (self.blocks_out is None):

build/lib/data_algebra/data_ops.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -962,10 +962,6 @@ def convert_records(self, record_map) -> "ViewRepresentation":
962962
return ConvertRecordsNode(source=self, record_map=record_map)
963963

964964

965-
# Could also have general query as starting ops, but don't see a lot of point to
966-
# it until somebody needs it.
967-
968-
969965
class TableDescription(ViewRepresentation):
970966
"""
971967
Describe columns, and qualifiers, of a table.
@@ -2734,15 +2730,14 @@ class ConvertRecordsNode(ViewRepresentation):
27342730
"""
27352731

27362732
def __init__(self, *, source, record_map):
2737-
sources = [source]
27382733
self.record_map = record_map
27392734
unknown = set(self.record_map.columns_needed) - set(source.column_names)
27402735
if len(unknown) > 0:
27412736
raise ValueError("missing required columns: " + str(unknown))
27422737
ViewRepresentation.__init__(
27432738
self,
27442739
column_names=record_map.columns_produced,
2745-
sources=sources,
2740+
sources=[source],
27462741
node_name="ConvertRecordsNode",
27472742
)
27482743

@@ -2973,7 +2968,7 @@ def ex(d, *, data_model=None, allow_limited_tables: bool = False):
29732968
Evaluate operators with respect to Pandas data frames already stored in the operator chain.
29742969
29752970
:param d: data algebra pipeline/DAG to evaluate.
2976-
:param data_model: adaptor to data dialect (Pandas for now)
2971+
:param data_model: adaptor to data dialect
29772972
:param allow_limited_tables: logical, if True allow execution on non-complete tables
29782973
:return: table result
29792974
"""

coverage.txt

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
platform darwin -- Python 3.10.8, pytest-7.1.2, pluggy-1.0.0
33
rootdir: /Users/johnmount/Documents/work/data_algebra
44
plugins: anyio-3.5.0, cov-3.0.0
5-
collected 370 items
5+
collected 371 items
66

77
tests/test_OrderedSet.py ...... [ 1%]
88
tests/test_agg.py .. [ 2%]
@@ -15,12 +15,12 @@ tests/test_braid.py . [ 6%]
1515
tests/test_calc_warnings_errors.py . [ 7%]
1616
tests/test_cc.py .... [ 8%]
1717
tests/test_cdata1.py .... [ 9%]
18-
tests/test_cdata_convenience.py . [ 9%]
18+
tests/test_cdata_convenience.py .. [ 9%]
1919
tests/test_cdata_example.py .. [ 10%]
2020
tests/test_cdata_tr6_example.py .... [ 11%]
2121
tests/test_cdata_wvpy_case.py . [ 11%]
2222
tests/test_coalesce.py . [ 11%]
23-
tests/test_cols_used.py . [ 11%]
23+
tests/test_cols_used.py . [ 12%]
2424
tests/test_compare_data_frames.py . [ 12%]
2525
tests/test_complex_expr.py .... [ 13%]
2626
tests/test_compound_where.py . [ 13%]
@@ -38,7 +38,7 @@ tests/test_eval_cache.py ... [ 21%]
3838
tests/test_ex_examples.py ............ [ 24%]
3939
tests/test_example1.py .... [ 25%]
4040
tests/test_exp.py . [ 25%]
41-
tests/test_exp_parens.py . [ 25%]
41+
tests/test_exp_parens.py . [ 26%]
4242
tests/test_expand_rows.py . [ 26%]
4343
tests/test_expr_parse.py . [ 26%]
4444
tests/test_expression_expectations.py .. [ 27%]
@@ -48,9 +48,9 @@ tests/test_extend_order.py . [ 30%]
4848
tests/test_first_last.py . [ 30%]
4949
tests/test_float_divide.py .. [ 31%]
5050
tests/test_flow_text.py . [ 31%]
51-
tests/test_forbidden_calculation.py .. [ 31%]
51+
tests/test_forbidden_calculation.py .. [ 32%]
5252
tests/test_forbidden_ops.py ... [ 32%]
53-
tests/test_free_fn.py . [ 32%]
53+
tests/test_free_fn.py . [ 33%]
5454
tests/test_get_methods_used.py . [ 33%]
5555
tests/test_ghost_col_issue.py . [ 33%]
5656
tests/test_idioms.py ................. [ 38%]
@@ -61,13 +61,13 @@ tests/test_join_check.py . [ 40%]
6161
tests/test_join_conditions.py ... [ 41%]
6262
tests/test_join_effects.py . [ 41%]
6363
tests/test_join_multi_key.py . [ 41%]
64-
tests/test_join_opt.py . [ 41%]
64+
tests/test_join_opt.py . [ 42%]
6565
tests/test_join_variations.py . [ 42%]
6666
tests/test_lark_parser.py ..... [ 43%]
6767
tests/test_locf.py . [ 43%]
6868
tests/test_logistic_example.py . [ 44%]
6969
tests/test_mapv.py .. [ 44%]
70-
tests/test_math.py . [ 44%]
70+
tests/test_math.py . [ 45%]
7171
tests/test_method_catalog_issues.py .. [ 45%]
7272
tests/test_minimum.py . [ 45%]
7373
tests/test_mod_fns.py ... [ 46%]
@@ -80,20 +80,20 @@ tests/test_one_row_cdata_convert.py . [ 49%]
8080
tests/test_ops.py . [ 50%]
8181
tests/test_ops_eq.py . [ 50%]
8282
tests/test_or.py ..... [ 51%]
83-
tests/test_order_limit.py . [ 51%]
83+
tests/test_order_limit.py . [ 52%]
8484
tests/test_parens.py .. [ 52%]
8585
tests/test_parse.py .......................... [ 59%]
8686
tests/test_polars.py ............................ [ 67%]
8787
tests/test_project.py ..... [ 68%]
8888
tests/test_rank.py . [ 68%]
89-
tests/test_rank_to_average.py . [ 68%]
89+
tests/test_rank_to_average.py . [ 69%]
9090
tests/test_readme_example.py . [ 69%]
9191
tests/test_ref_detect.py .. [ 69%]
9292
tests/test_rename.py ...... [ 71%]
9393
tests/test_round.py ... [ 72%]
9494
tests/test_scalar_columns.py . [ 72%]
9595
tests/test_scatter_example.py . [ 72%]
96-
tests/test_scoring_example.py . [ 72%]
96+
tests/test_scoring_example.py . [ 73%]
9797
tests/test_select.py ... [ 73%]
9898
tests/test_select_stacking.py . [ 74%]
9999
tests/test_select_values.py .. [ 74%]
@@ -140,11 +140,11 @@ data_algebra/SQLite.py 193 19 90% 91, 101, 127, 141,
140140
data_algebra/SparkSQL.py 89 46 48% 16-17, 21-22, 26-28, 89, 94, 140-144, 150-154, 178-180, 186-193, 200-215, 226-231
141141
data_algebra/__init__.py 9 0 100%
142142
data_algebra/arrow.py 100 23 77% 45, 63, 69, 79-80, 85, 109, 113, 145, 154, 160-166, 169-175, 188, 190, 192, 196, 200
143-
data_algebra/cdata.py 330 61 82% 15, 31, 74, 76, 85, 87, 90-93, 95, 98, 104, 108, 111, 116, 120, 128, 136, 141, 162-166, 212-215, 218-233, 237, 290, 296, 302, 305, 323, 325, 327, 330, 333, 340, 344, 346, 392, 412, 444, 451-454, 465, 502, 544-547, 550-568
143+
data_algebra/cdata.py 344 62 82% 16, 32, 75, 77, 86, 88, 91-94, 96, 99, 105, 109, 112, 117, 121, 129, 137, 142, 163-167, 213-216, 219-234, 238, 291, 297, 303, 306, 324, 326, 328, 331, 334, 341, 345, 347, 393, 413, 449, 456-459, 470, 539, 547, 589-592, 595-613
144144
data_algebra/connected_components.py 22 0 100%
145145
data_algebra/data_model.py 62 0 100%
146146
data_algebra/data_model_space.py 51 7 86% 23, 39-40, 45, 55-56, 62
147-
data_algebra/data_ops.py 1319 205 84% 35-36, 55-56, 93, 129, 229, 298, 343, 378-381, 391, 393, 395, 397, 401, 430, 498, 543, 574, 601, 635, 641, 643, 728, 730, 779, 802, 808, 823, 825, 836, 848, 876, 878, 891, 893, 899, 911, 914, 926, 929, 942, 944, 946, 948, 959, 961, 995, 1013, 1029, 1031, 1033, 1035, 1039, 1060-1068, 1071-1081, 1097, 1121, 1159-1162, 1167, 1171, 1295, 1300, 1305, 1307, 1314, 1316, 1324, 1330, 1332, 1334, 1337, 1340, 1343, 1348, 1365, 1377, 1392, 1435, 1437, 1439, 1441, 1443, 1445, 1485, 1495, 1510, 1585, 1587, 1597, 1603, 1606, 1624, 1634, 1679, 1681, 1683, 1686, 1697, 1770, 1772, 1808-1812, 1816, 1820, 1832, 1884, 1888, 1891, 1893, 1909-1913, 1917, 1919, 1931, 1981, 1986, 1991, 2007-2011, 2015, 2017, 2028, 2079, 2084, 2090, 2093, 2109-2113, 2119, 2121, 2123, 2125, 2137, 2207, 2238-2242, 2246, 2248, 2250, 2261, 2359-2363, 2367, 2369, 2380, 2458, 2473, 2503, 2523, 2525, 2527, 2529, 2540, 2613, 2619, 2621, 2641-2645, 2654, 2656, 2658, 2660, 2671, 2741, 2757-2761, 2765, 2767, 2813, 2891-2899, 2903, 2905, 2907, 2909, 2915
147+
data_algebra/data_ops.py 1318 205 84% 35-36, 55-56, 93, 129, 229, 298, 343, 378-381, 391, 393, 395, 397, 401, 430, 498, 543, 574, 601, 635, 641, 643, 728, 730, 779, 802, 808, 823, 825, 836, 848, 876, 878, 891, 893, 899, 911, 914, 926, 929, 942, 944, 946, 948, 959, 961, 991, 1009, 1025, 1027, 1029, 1031, 1035, 1056-1064, 1067-1077, 1093, 1117, 1155-1158, 1163, 1167, 1291, 1296, 1301, 1303, 1310, 1312, 1320, 1326, 1328, 1330, 1333, 1336, 1339, 1344, 1361, 1373, 1388, 1431, 1433, 1435, 1437, 1439, 1441, 1481, 1491, 1506, 1581, 1583, 1593, 1599, 1602, 1620, 1630, 1675, 1677, 1679, 1682, 1693, 1766, 1768, 1804-1808, 1812, 1816, 1828, 1880, 1884, 1887, 1889, 1905-1909, 1913, 1915, 1927, 1977, 1982, 1987, 2003-2007, 2011, 2013, 2024, 2075, 2080, 2086, 2089, 2105-2109, 2115, 2117, 2119, 2121, 2133, 2203, 2234-2238, 2242, 2244, 2246, 2257, 2355-2359, 2363, 2365, 2376, 2454, 2469, 2499, 2519, 2521, 2523, 2525, 2536, 2609, 2615, 2617, 2637-2641, 2650, 2652, 2654, 2656, 2667, 2736, 2752-2756, 2760, 2762, 2808, 2886-2894, 2898, 2900, 2902, 2904, 2910
148148
data_algebra/data_ops_types.py 71 1 99% 328
149149
data_algebra/data_ops_utils.py 33 3 91% 29, 33, 43
150150
data_algebra/data_space.py 25 1 96% 76
@@ -164,10 +164,10 @@ data_algebra/polars_model.py 597 74 88% 180, 189, 203, 446-
164164
data_algebra/python3_lark.py 1 0 100%
165165
data_algebra/solutions.py 135 4 97% 63, 308, 389, 472
166166
data_algebra/sql_format_options.py 17 4 76% 61, 68-71
167-
data_algebra/test_util.py 334 65 81% 28-29, 104, 126, 136, 139, 143, 166, 169, 173, 175-178, 189, 233-234, 251-269, 273, 285, 295, 332, 334, 345, 353, 364, 371, 377, 389, 400, 414, 469, 473, 524-527, 529-532, 534-537, 539-542, 653-658, 663-664, 666
167+
data_algebra/test_util.py 334 59 82% 28-29, 104, 126, 136, 139, 143, 166, 169, 173, 175-178, 189, 264-269, 273, 285, 295, 332, 334, 345, 353, 364, 371, 377, 389, 400, 414, 469, 473, 524-527, 529-532, 534-537, 539-542, 653-658, 663-664, 666
168168
data_algebra/util.py 127 28 78% 26, 59-60, 63-64, 67-68, 71-72, 75-76, 79-80, 83-84, 87-88, 91-92, 95-96, 143, 165, 167, 182, 223, 227, 229
169169
--------------------------------------------------------------------
170-
TOTAL 6673 912 86%
170+
TOTAL 6686 907 86%
171171

172172

173-
======================= 370 passed in 849.24s (0:14:09) ========================
173+
======================= 371 passed in 900.58s (0:15:00) ========================
172 Bytes
Binary file not shown.

dist/data_algebra-1.6.4.tar.gz

112 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)