Skip to content

Commit c298f3b

Browse files
committed
work on print interfering with column calc
1 parent 5e593d4 commit c298f3b

File tree

6 files changed

+19
-68
lines changed

6 files changed

+19
-68
lines changed

build/lib/data_algebra/arrow.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ def __init__(self, pipeline, *, free_table_key=None):
4848
raise ValueError(
4949
"free_table_key must be a table key used in the pipeline"
5050
)
51-
c_used = pipeline.columns_used(using=pipeline.column_names)
5251
self.free_table_key = free_table_key
53-
self.incoming_columns = c_used[free_table_key]
54-
self.incoming_types = t_used[free_table_key].column_types
52+
self.incoming_columns = t_used[free_table_key].column_names.copy()
53+
self.incoming_types = None
54+
if t_used[free_table_key].column_types is not None:
55+
self.incoming_types = t_used[free_table_key].column_types.copy()
5556
self.outgoing_columns = pipeline.column_names.copy()
5657
self.outgoing_columns.sort()
5758
self.outgoing_types = None
58-
if isinstance(pipeline, data_algebra.data_ops.TableDescription):
59-
self.outgoing_types = self.incoming_types
59+
if isinstance(pipeline, data_algebra.data_ops.TableDescription) and self.incoming_types is not None:
60+
self.outgoing_types = self.incoming_types.copy()
6061
Arrow.__init__(self)
6162

6263
# noinspection PyPep8Naming

coverage.txt

Lines changed: 5 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ collected 77 items
66

77
tests/test_R_yaml.py . [ 1%]
88
tests/test_apply.py . [ 2%]
9-
tests/test_arrow1.py ..F [ 6%]
9+
tests/test_arrow1.py ... [ 6%]
1010
tests/test_calc_issue.py . [ 7%]
1111
tests/test_calc_warnings_errors.py . [ 9%]
1212
tests/test_cc.py ...... [ 16%]
@@ -47,67 +47,14 @@ tests/test_transform_examples.py ........... [ 97%]
4747
tests/test_window2.py . [ 98%]
4848
tests/test_window_fns.py . [100%]
4949

50-
=================================== FAILURES ===================================
51-
_____________________________ test_arrow_compose_2 _____________________________
52-
53-
def test_arrow_compose_2():
54-
b1 = DataOpArrow(TableDescription(column_names=['x', 'y'], table_name=None). \
55-
extend({
56-
'y': 7
57-
}))
58-
b2 = DataOpArrow(TableDescription(column_names=['x', 'y'], table_name=None). \
59-
extend({
60-
'y': 9
61-
}))
62-
> b1 >> b2
63-
64-
tests/test_arrow1.py:247:
65-
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
66-
data_algebra/arrow.py:26: in __rshift__
67-
return other.transform(self, strict=True)
68-
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
69-
70-
self = DataOpArrow(
71-
TableDescription(
72-
table_name='',
73-
column_names=[
74-
'x', 'y']) .\
75-
extend({
76-
'y': '9'}),
77-
free_table_key='')
78-
X = DataOpArrow(
79-
TableDescription(
80-
table_name='',
81-
column_names=[
82-
'x', 'y']) .\
83-
extend({
84-
'y': '7'}),
85-
free_table_key='')
86-
87-
def transform(self, X, *, strict=True):
88-
"""replace self input table with X"""
89-
if isinstance(X, data_algebra.data_ops.ViewRepresentation):
90-
X = DataOpArrow(X)
91-
if isinstance(X, DataOpArrow):
92-
missing = set(self.incoming_columns) - set(X.outgoing_columns)
93-
if len(missing) > 0:
94-
raise ValueError("missing required columns: " + str(missing))
95-
excess = set(X.outgoing_columns) - set(self.incoming_columns)
96-
if len(excess) > 0:
97-
if strict:
98-
> raise ValueError("extra incoming columns: " + str(excess))
99-
E ValueError: extra incoming columns: {'y'}
100-
101-
data_algebra/arrow.py:74: ValueError
102-
10350
---------- coverage: platform darwin, python 3.7.5-final-0 -----------
10451
Name Stmts Miss Cover
10552
----------------------------------------------------------
10653
data_algebra/PostgreSQL.py 21 4 81%
10754
data_algebra/SQLite.py 90 13 86%
10855
data_algebra/SparkSQL.py 21 4 81%
10956
data_algebra/__init__.py 5 0 100%
110-
data_algebra/arrow.py 143 49 66%
57+
data_algebra/arrow.py 144 50 65%
11158
data_algebra/cdata.py 232 75 68%
11259
data_algebra/cdata_impl.py 10 1 90%
11360
data_algebra/connected_components.py 49 1 98%
@@ -127,6 +74,7 @@ data_algebra/test_util.py 119 17 86%
12774
data_algebra/util.py 44 10 77%
12875
data_algebra/yaml.py 102 13 87%
12976
----------------------------------------------------------
130-
TOTAL 3701 928 75%
77+
TOTAL 3702 929 75%
78+
13179

132-
========================= 1 failed, 76 passed in 7.04s =========================
80+
============================== 77 passed in 9.63s ==============================

data_algebra/arrow.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,16 @@ def __init__(self, pipeline, *, free_table_key=None):
4848
raise ValueError(
4949
"free_table_key must be a table key used in the pipeline"
5050
)
51-
c_used = pipeline.columns_used(using=pipeline.column_names)
5251
self.free_table_key = free_table_key
53-
self.incoming_columns = c_used[free_table_key]
54-
self.incoming_types = t_used[free_table_key].column_types
52+
self.incoming_columns = t_used[free_table_key].column_names.copy()
53+
self.incoming_types = None
54+
if t_used[free_table_key].column_types is not None:
55+
self.incoming_types = t_used[free_table_key].column_types.copy()
5556
self.outgoing_columns = pipeline.column_names.copy()
5657
self.outgoing_columns.sort()
5758
self.outgoing_types = None
58-
if isinstance(pipeline, data_algebra.data_ops.TableDescription):
59-
self.outgoing_types = self.incoming_types
59+
if isinstance(pipeline, data_algebra.data_ops.TableDescription) and self.incoming_types is not None:
60+
self.outgoing_types = self.incoming_types.copy()
6061
Arrow.__init__(self)
6162

6263
# noinspection PyPep8Naming
0 Bytes
Binary file not shown.

dist/data_algebra-0.3.8.tar.gz

-7 Bytes
Binary file not shown.

tests/test_arrow1.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,5 @@ def test_arrow_compose_2():
244244
extend({
245245
'y': 9
246246
}))
247-
b1 >> b2
247+
ops = b1 >> b2
248+
assert isinstance(ops.pipeline.sources[0], TableDescription)

0 commit comments

Comments
 (0)