Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
deanm0000 committed Apr 11, 2024
1 parent 2e2df00 commit fc8cf09
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion py-polars/polars/_utils/parse_expr_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def _parse_inputs_as_iterable(

def _is_iterable(input: Any | Iterable[Any]) -> bool:
return isinstance(input, Iterable) and not isinstance(
input, (str, bytes, pl.Series)
input, (str, bytes, pl.Series, pl.DataFrame, pl.LazyFrame)
)


Expand Down
11 changes: 11 additions & 0 deletions py-polars/tests/unit/utils/test_parse_expr_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from polars._utils.parse_expr_input import parse_as_expression
from polars._utils.wrap import wrap_expr
from polars.testing import assert_frame_equal
from polars.exceptions import InvalidOperationError


def assert_expr_equal(result: pl.Expr, expected: pl.Expr) -> None:
Expand Down Expand Up @@ -78,3 +79,13 @@ def test_parse_as_expression_structify_multiple_outputs() -> None:
result = wrap_expr(parse_as_expression(pl.col("*"), structify=True))
expected = pl.struct("a", "b")
assert_expr_equal(result, expected)


def test_raise_with_df_in_context() -> None:
df = pl.DataFrame({"a": [1, 2, 3]})
df2 = pl.DataFrame({"b": [2, 3, 4]})
with pytest.raises(InvalidOperationError):
df.with_columns(df2)

with pytest.raises(InvalidOperationError):
df.select([df2])

0 comments on commit fc8cf09

Please sign in to comment.