Skip to content

Commit 9a8fc79

Browse files
committed
rebuid and retest
1 parent 73a63d7 commit 9a8fc79

25 files changed

+176
-394
lines changed

build/lib/data_algebra/pandas_base.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -322,14 +322,14 @@ def _populate_impl_map(self) -> Dict[str, Callable]:
322322
"as_int64": lambda x: x.astype("int64").copy(),
323323
"as_str": lambda x: x.astype("str").copy(),
324324
"trimstr": lambda x, start, stop: x.str.slice(start=start, stop=stop),
325-
"datetime_to_date": lambda x: x.dt.date.copy(),
325+
"datetime_to_date": lambda x: self.pd.to_datetime(x).dt.date.copy(),
326326
"parse_datetime": lambda x, format: self.pd.to_datetime(
327327
x, format=format
328328
),
329329
"parse_date": lambda x, format: self.pd.to_datetime(
330330
x, format=format
331331
).dt.date.copy(),
332-
"format_datetime": lambda x, format: x.dt.strftime(date_format=format),
332+
"format_datetime": lambda x, format: self.pd.to_datetime(x).dt.strftime(date_format=format),
333333
"format_date": lambda x, format: self.pd.to_datetime(
334334
x
335335
).dt.strftime(date_format=format),
@@ -343,22 +343,12 @@ def _populate_impl_map(self) -> Dict[str, Callable]:
343343
)
344344
% 7
345345
),
346-
"dayofyear": lambda x: self.pd.to_datetime(x)
347-
.dt.dayofyear.astype("int64")
348-
.copy(),
346+
"dayofyear": lambda x: self.pd.to_datetime(x).dt.dayofyear.astype("int64").copy(),
349347
"weekofyear": lambda x: self._calc_week_of_Year(x),
350-
"dayofmonth": lambda x: self.pd.to_datetime(x)
351-
.dt.day.astype("int64")
352-
.copy(),
353-
"month": lambda x: self.pd.to_datetime(x)
354-
.dt.month.astype("int64")
355-
.copy(),
356-
"quarter": lambda x: self.pd.to_datetime(x)
357-
.dt.quarter.astype("int64")
358-
.copy(),
359-
"year": lambda x: self.pd.to_datetime(x)
360-
.dt.year.astype("int64")
361-
.copy(),
348+
"dayofmonth": lambda x: self.pd.to_datetime(x).dt.day.astype("int64").copy(),
349+
"month": lambda x: self.pd.to_datetime(x).dt.month.astype("int64").copy(),
350+
"quarter": lambda x: self.pd.to_datetime(x).dt.quarter.astype("int64").copy(),
351+
"year": lambda x: self.pd.to_datetime(x).dt.year.astype("int64").copy(),
362352
"timestamp_diff": lambda c1, c2: [
363353
self.pd.Timedelta(c1[i] - c2[i]).total_seconds()
364354
for i in range(len(c1))

build/lib/data_algebra/polars_model.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ def get_cell(self, *, d, row: int, colname: str):
637637

638638
def set_col(self, *, d, colname: str, values):
639639
"""set column, return ref"""
640-
d2 = d.with_column(pl.Series(values=values).alias(colname))
640+
d2 = d.with_columns([pl.Series(values=values).alias(colname)])
641641
return d2
642642

643643
def table_is_keyed_by_columns(self, table, *, column_names: Iterable[str]) -> bool:
@@ -667,7 +667,7 @@ def table_is_keyed_by_columns(self, table, *, column_names: Iterable[str]) -> bo
667667
mx = (
668668
table
669669
.select(column_names)
670-
.with_column(pl.lit(1, pl.Int64).alias("_da_count_tmp"))
670+
.with_columns([pl.lit(1, pl.Int64).alias("_da_count_tmp")])
671671
.groupby(column_names)
672672
.sum()["_da_count_tmp"]
673673
.max()
@@ -720,8 +720,8 @@ def _concat_rows_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *,
720720
assert len(inputs) == 2
721721
inputs = [input_i.select(common_columns) for input_i in inputs] # get columns in same order
722722
if op.id_column is not None:
723-
inputs[0] = inputs[0].with_column(_build_lit(op.a_name).alias(op.id_column))
724-
inputs[1] = inputs[1].with_column(_build_lit(op.b_name).alias(op.id_column))
723+
inputs[0] = inputs[0].with_columns([_build_lit(op.a_name).alias(op.id_column)])
724+
inputs[1] = inputs[1].with_columns([_build_lit(op.b_name).alias(op.id_column)])
725725
res = pl.concat(inputs, how="vertical")
726726
return res
727727

@@ -799,7 +799,7 @@ def _extend_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *, data
799799
if c not in partition_set:
800800
order_cols.append(c)
801801
reversed_cols = [True if ci in set(op.reverse) else False for ci in op.order_by]
802-
res = res.sort(by=op.order_by, reverse=reversed_cols)
802+
res = res.sort(by=op.order_by, descending=reversed_cols)
803803
res = res.with_columns(produced_columns)
804804
if len(temp_v_columns) > 0:
805805
res = res.select(op.columns_produced())
@@ -865,7 +865,7 @@ def _project_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *, dat
865865
res = res.collect()
866866
if res.shape[0] <= 0:
867867
# make an all None frame
868-
res = pl.DataFrame({c: [None] for c in res.columns}, columns=[(res.columns[j], res.dtypes[j]) for j in range(res.shape[1])])
868+
res = pl.DataFrame({c: [None] for c in res.columns}, schema=[(res.columns[j], res.dtypes[j]) for j in range(res.shape[1])])
869869
# see if we need to convert to lazy type
870870
if self.use_lazy_eval and isinstance(res, pl.DataFrame):
871871
res = res.lazy()
@@ -952,7 +952,7 @@ def _order_rows_step(self, op: data_algebra.data_ops_types.OperatorPlatform, *,
952952
)
953953
res = self._compose_polars_ops(op.sources[0], data_map=data_map)
954954
reversed_cols = [True if ci in set(op.reverse) else False for ci in op.order_columns]
955-
res = res.sort(by=op.order_columns, reverse=reversed_cols)
955+
res = res.sort(by=op.order_columns, descending=reversed_cols)
956956
if op.limit is not None:
957957
res = res.head(op.limit)
958958
return res

coverage.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
============================= test session starts ==============================
2-
platform darwin -- Python 3.10.8, pytest-7.1.2, pluggy-1.0.0
2+
platform darwin -- Python 3.10.10, pytest-7.1.2, pluggy-1.0.0
33
rootdir: /Users/johnmount/Documents/work/data_algebra
4-
plugins: anyio-3.5.0, cov-3.0.0
4+
plugins: anyio-3.5.0, cov-4.0.0
55
collected 377 items
66

77
tests/test_OrderedSet.py ...... [ 1%]
@@ -131,7 +131,7 @@ tests/test_window_fns.py ..... [ 98%]
131131
tests/test_with.py .. [ 99%]
132132
tests/test_xicor.py .. [100%]
133133

134-
---------- coverage: platform darwin, python 3.10.8-final-0 ----------
134+
--------- coverage: platform darwin, python 3.10.10-final-0 ----------
135135
Name Stmts Miss Cover Missing
136136
--------------------------------------------------------------------
137137
data_algebra/BigQuery.py 126 67 47% 22-23, 27, 131-135, 139, 153-160, 169-178, 183-201, 215-244, 248-261, 272-287
@@ -159,7 +159,7 @@ data_algebra/expression_walker.py 11 0 100%
159159
data_algebra/flow_text.py 17 0 100%
160160
data_algebra/near_sql.py 237 3 99% 41, 256-257
161161
data_algebra/op_catalog.py 3 0 100%
162-
data_algebra/pandas_base.py 696 68 90% 54, 68, 77, 87, 92, 101, 223, 225, 239, 242, 247, 252, 427, 467, 478, 503, 506, 511, 514, 516, 528, 534-541, 548, 582-587, 617, 621, 624, 626, 663, 717, 758, 775, 795, 813, 823, 838, 886, 894, 902, 917, 928, 940, 959, 974, 1002, 1017, 1054, 1071, 1074, 1085, 1113, 1145, 1154, 1181, 1198, 1210, 1265, 1279-1281
162+
data_algebra/pandas_base.py 696 68 90% 54, 68, 77, 87, 92, 101, 223, 225, 239, 242, 247, 252, 417, 457, 468, 493, 496, 501, 504, 506, 518, 524-531, 538, 572-577, 607, 611, 614, 616, 653, 707, 748, 765, 785, 803, 813, 828, 876, 884, 892, 907, 918, 930, 949, 964, 992, 1007, 1044, 1061, 1064, 1075, 1103, 1135, 1144, 1171, 1188, 1200, 1255, 1269-1271
163163
data_algebra/pandas_model.py 19 2 89% 32-33
164164
data_algebra/parse_by_lark.py 164 24 85% 71, 93, 108, 129-130, 137, 161, 171, 185-186, 188, 200, 206, 213-217, 245, 253, 263-266
165165
data_algebra/polars_model.py 597 74 88% 180, 189, 203, 446-452, 458-465, 483-484, 486, 570, 586, 596, 603, 616-620, 628, 630, 655, 658, 663, 666, 715, 733, 749, 816, 832-834, 879, 922, 941, 950, 965, 983, 1001, 1021, 1033-1035, 1038, 1045, 1047, 1054-1066, 1073, 1078, 1109, 1138, 1147, 1175, 1190, 1202
@@ -173,4 +173,4 @@ data_algebra/util.py 127 28 78% 26, 59-60, 63-64, 6
173173
TOTAL 6737 912 86%
174174

175175

176-
======================= 377 passed in 857.38s (0:14:17) ========================
176+
======================= 377 passed in 793.00s (0:13:12) ========================
-10 Bytes
Binary file not shown.

dist/data_algebra-1.6.6.tar.gz

5 Bytes
Binary file not shown.

docs/data_algebra.html

Lines changed: 43 additions & 43 deletions
Large diffs are not rendered by default.

docs/data_algebra/BigQuery.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

docs/data_algebra/MySQL.html

Lines changed: 6 additions & 37 deletions
Large diffs are not rendered by default.

docs/data_algebra/OrderedSet.html

Lines changed: 6 additions & 6 deletions
Large diffs are not rendered by default.

docs/data_algebra/PostgreSQL.html

Lines changed: 6 additions & 39 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)