Skip to content

Commit

Permalink
Update black and change some code so is sees it as a call chain. (#3645)
Browse files Browse the repository at this point in the history
  • Loading branch information
ghuls committed Jun 10, 2022
1 parent 99e6cbe commit cea3e89
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 41 deletions.
2 changes: 1 addition & 1 deletion py-polars/build.requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ types-pytz
maturin==0.12.19
pytest==7.1.2
pytest-cov[toml]==3.0.0
black==21.6b0
black==22.3.0
blackdoc==0.3.4
isort~=5.10.1
mypy==0.961
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/internals/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def sqrt(self) -> "Expr":
"""
Compute the square root of the elements
"""
return self ** 0.5
return self**0.5

def log10(self) -> "Expr":
"""
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/internals/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def sqrt(self) -> "Series":
]
"""
return self ** 0.5
return self**0.5

def any(self) -> bool:
"""
Expand Down
3 changes: 1 addition & 2 deletions py-polars/tests/io/test_lazy_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,5 +64,4 @@ def test_scan_csv_schema_overwrite_and_dtypes_overwrite(foods_csv: str) -> None:
)
.collect()
.dtypes
== [pl.Utf8, pl.Utf8, pl.Float32, pl.Int64]
)
) == [pl.Utf8, pl.Utf8, pl.Float32, pl.Int64]
9 changes: 3 additions & 6 deletions py-polars/tests/test_lazy.py
Original file line number Diff line number Diff line change
Expand Up @@ -1236,8 +1236,7 @@ def test_quantile_filtered_agg() -> None:
.groupby("group")
.agg(pl.col("value").filter(pl.col("value") < 2).quantile(0.5))["value"]
.to_list()
== [1.0, 1.0]
)
) == [1.0, 1.0]


def test_lazy_schema() -> None:
Expand Down Expand Up @@ -1269,8 +1268,7 @@ def test_deadlocks_3409() -> None:
)
.with_columns([pl.col("col1").arr.eval(pl.element().apply(lambda x: x))])
.to_dict(False)
== {"col1": [[1, 2, 3]]}
)
) == {"col1": [[1, 2, 3]]}

assert (
pl.DataFrame(
Expand All @@ -1280,5 +1278,4 @@ def test_deadlocks_3409() -> None:
)
.with_columns([pl.col("col1").cumulative_eval(pl.element().map(lambda x: 0))])
.to_dict(False)
== {"col1": [0, 0, 0]}
)
) == {"col1": [0, 0, 0]}
3 changes: 1 addition & 2 deletions py-polars/tests/test_queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,7 @@ def test_overflow_uint16_agg_mean() -> None:
.groupby(["col1"])
.agg(pl.col("col3").mean())
.to_dict(False)
== {"col1": ["A"], "col3": [64.0]}
)
) == {"col1": ["A"], "col3": [64.0]}


def test_binary_on_list_agg_3345() -> None:
Expand Down
12 changes: 6 additions & 6 deletions py-polars/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_init_inputs(monkeypatch: Any) -> None:
with pytest.raises(ValueError):
pl.Series({"a": [1, 2, 3]})
with pytest.raises(OverflowError):
pl.Series("bigint", [2 ** 64])
pl.Series("bigint", [2**64])


def test_concat() -> None:
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_arithmetic(s: pl.Series) -> None:
with pytest.raises(ValueError):
a % 2
with pytest.raises(ValueError):
a ** 2
a**2
with pytest.raises(ValueError):
2 / a
with pytest.raises(ValueError):
Expand All @@ -212,7 +212,7 @@ def test_arithmetic(s: pl.Series) -> None:
with pytest.raises(ValueError):
2 % a
with pytest.raises(ValueError):
2 ** a
2**a


def test_add_string() -> None:
Expand Down Expand Up @@ -473,7 +473,7 @@ def test_fill_null() -> None:

def test_apply() -> None:
a = pl.Series("a", [1, 2, None])
b = a.apply(lambda x: x ** 2)
b = a.apply(lambda x: x**2)
assert b == [1, 4, None]

a = pl.Series("a", ["foo", "bar", None])
Expand Down Expand Up @@ -849,9 +849,9 @@ def test_range() -> None:

def test_strict_cast() -> None:
with pytest.raises(pl.ComputeError):
pl.Series("a", [2 ** 16]).cast(dtype=pl.Int16, strict=True)
pl.Series("a", [2**16]).cast(dtype=pl.Int16, strict=True)
with pytest.raises(pl.ComputeError):
pl.DataFrame({"a": [2 ** 16]}).select([pl.col("a").cast(pl.Int16, strict=True)])
pl.DataFrame({"a": [2**16]}).select([pl.col("a").cast(pl.Int16, strict=True)])


def test_list_concat_dispatch() -> None:
Expand Down
21 changes: 11 additions & 10 deletions py-polars/tests/test_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ def test_extract_all_count() -> None:
pl.col("foo").str.count_match(r"a").alias("count"),
]
).to_dict(False)
== {"extract": [["a", "a"], None], "count": [2, 0]}
)
) == {"extract": [["a", "a"], None], "count": [2, 0]}

assert df["foo"].str.extract_all(r"a").dtype == pl.List
assert df["foo"].str.count_match(r"a").dtype == pl.UInt32
Expand Down Expand Up @@ -71,14 +70,16 @@ def test_zfill() -> None:

def test_ljust_and_rjust() -> None:
df = pl.DataFrame({"a": ["foo", "longer_foo", "longest_fooooooo", "hi"]})
assert df.select(
[
pl.col("a").str.rjust(10).alias("rjust"),
pl.col("a").str.rjust(10).str.lengths().alias("rjust_len"),
pl.col("a").str.ljust(10).alias("ljust"),
pl.col("a").str.ljust(10).str.lengths().alias("ljust_len"),
]
).to_dict(False) == {
assert (
df.select(
[
pl.col("a").str.rjust(10).alias("rjust"),
pl.col("a").str.rjust(10).str.lengths().alias("rjust_len"),
pl.col("a").str.ljust(10).alias("ljust"),
pl.col("a").str.ljust(10).str.lengths().alias("ljust_len"),
]
).to_dict(False)
) == {
"rjust": [" foo", "longer_foo", "longest_fooooooo", " hi"],
"rjust_len": [10, 10, 16, 10],
"ljust": ["foo ", "longer_foo", "longest_fooooooo", "hi "],
Expand Down
6 changes: 2 additions & 4 deletions py-polars/tests/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ def test_struct_order() -> None:
{"a": 2, "b": 20},
],
).to_list()
== [{"a": 1, "b": None}, {"a": 2, "b": 20}]
)
) == [{"a": 1, "b": None}, {"a": 2, "b": 20}]

assert (
pl.Series(
Expand All @@ -441,8 +440,7 @@ def test_struct_order() -> None:
{"a": 2, "b": None},
],
).to_list()
== [{"a": 1, "b": 10}, {"a": 2, "b": None}]
)
) == [{"a": 1, "b": 10}, {"a": 2, "b": None}]


def test_struct_schema_on_append_extend_3452() -> None:
Expand Down
17 changes: 9 additions & 8 deletions py-polars/tests/test_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,14 @@ def test_cumulative_eval_window_functions() -> None:
}
)

assert df.with_column(
pl.col("val")
.cumulative_eval(pl.element().max())
.over("group")
.alias("cumulative_eval_max")
).to_dict(False) == {
assert (
df.with_column(
pl.col("val")
.cumulative_eval(pl.element().max())
.over("group")
.alias("cumulative_eval_max")
).to_dict(False)
) == {
"group": [0, 0, 0, 1, 1, 1],
"val": [20, 40, 30, 2, 4, 3],
"cumulative_eval_max": [20, 40, 40, 2, 4, 4],
Expand All @@ -169,5 +171,4 @@ def test_count_window() -> None:
)
.with_column(pl.count().over("a"))["count"]
.to_list()
== [2, 2, 1]
)
) == [2, 2, 1]

0 comments on commit cea3e89

Please sign in to comment.