Skip to content

Commit f7d4230

Browse files
committed
fix: use col() references in tests and fix formatting
1 parent 71caefc commit f7d4230

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

daft/functions/datetime.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1555,7 +1555,9 @@ def make_timestamp_ltz(
15551555
Examples:
15561556
>>> import daft
15571557
>>> from daft.functions import make_timestamp_ltz
1558-
>>> make_timestamp_ltz(daft.col("y"), daft.col("m"), daft.col("d"), daft.col("h"), daft.col("mi"), daft.col("s"))
1558+
>>> make_timestamp_ltz(
1559+
... daft.col("y"), daft.col("m"), daft.col("d"), daft.col("h"), daft.col("mi"), daft.col("s")
1560+
... )
15591561
make_timestamp_ltz(col(y), col(m), col(d), col(h), col(mi), col(s))
15601562
"""
15611563
year = Expression._to_expression(year)

tests/dataframe/test_temporals.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -979,18 +979,14 @@ def test_make_date_invalid() -> None:
979979

980980

981981
def test_make_timestamp() -> None:
982-
df = daft.from_pydict(
983-
{"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [30], "s": [45.0]}
984-
)
982+
df = daft.from_pydict({"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [30], "s": [45.0]})
985983
df = df.with_column("ts", make_timestamp(col("y"), col("m"), col("d"), col("h"), col("mi"), col("s")))
986984
result = df.to_pydict()
987985
assert result["ts"] == [datetime(2021, 1, 1, 12, 30, 45)]
988986

989987

990988
def test_make_timestamp_with_timezone() -> None:
991-
df = daft.from_pydict(
992-
{"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]}
993-
)
989+
df = daft.from_pydict({"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]})
994990
df = df.with_column(
995991
"ts", make_timestamp(col("y"), col("m"), col("d"), col("h"), col("mi"), col("s"), timezone="UTC")
996992
)
@@ -1002,18 +998,14 @@ def test_make_timestamp_with_timezone() -> None:
1002998

1003999

10041000
def test_make_timestamp_ltz() -> None:
1005-
df = daft.from_pydict(
1006-
{"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]}
1007-
)
1001+
df = daft.from_pydict({"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]})
10081002
df = df.with_column("ts", make_timestamp_ltz(col("y"), col("m"), col("d"), col("h"), col("mi"), col("s")))
10091003
result = df.to_pydict()
10101004
assert result["ts"] == [datetime(2021, 1, 1, 12, 0, 0, tzinfo=timezone.utc)]
10111005

10121006

10131007
def test_make_timestamp_ltz_with_timezone() -> None:
1014-
df = daft.from_pydict(
1015-
{"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]}
1016-
)
1008+
df = daft.from_pydict({"y": [2021], "m": [1], "d": [1], "h": [12], "mi": [0], "s": [0.0]})
10171009
df = df.with_column(
10181010
"ts", make_timestamp_ltz(col("y"), col("m"), col("d"), col("h"), col("mi"), col("s"), timezone="US/Eastern")
10191011
)
@@ -1026,9 +1018,7 @@ def test_make_timestamp_ltz_with_timezone() -> None:
10261018

10271019

10281020
def test_last_day() -> None:
1029-
df = daft.from_pydict(
1030-
{"dt": [date(2021, 1, 15), date(2021, 2, 10), date(2020, 2, 10), date(2021, 4, 1)]}
1031-
)
1021+
df = daft.from_pydict({"dt": [date(2021, 1, 15), date(2021, 2, 10), date(2020, 2, 10), date(2021, 4, 1)]})
10321022
df = df.with_column("last", last_day(col("dt")))
10331023
result = df.to_pydict()
10341024
assert result["last"] == [

0 commit comments

Comments
 (0)