Skip to content

Commit

Permalink
Update error message
Browse files Browse the repository at this point in the history
  • Loading branch information
stinodego committed Apr 3, 2024
1 parent bab7462 commit 0402126
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6913,7 +6913,7 @@ def clear(self, n: int = 0) -> Self:
└──────┴──────┴──────┘
"""
if n < 0:
msg = "n should be greater than or equal to 0."
msg = f"`n` should be greater than or equal to 0, got {n}"
raise ValueError(msg)
# faster path
if n == 0:
Expand Down
2 changes: 1 addition & 1 deletion py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4760,7 +4760,7 @@ def clear(self, n: int = 0) -> Series:
]
"""
if n < 0:
msg = "n should be greater than or equal to 0."
msg = f"`n` should be greater than or equal to 0, got {n}"
raise ValueError(msg)
# faster path
if n == 0:
Expand Down
10 changes: 5 additions & 5 deletions py-polars/tests/unit/operations/test_clear.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ def test_clear_series_object_starting_with_null() -> None:

def test_clear_raise_negative_n() -> None:
s = pl.Series([1, 2, 3])
with pytest.raises(ValueError, match="n should be greater than or equal to 0"):
s.clear(-1)

df = pl.DataFrame({"a": [1, 2, 3]})
with pytest.raises(ValueError, match="n should be greater than or equal to 0"):
df.clear(-1)
msg = "`n` should be greater than or equal to 0, got -1"
with pytest.raises(ValueError, match=msg):
s.clear(-1)
with pytest.raises(ValueError, match=msg):
s.to_frame().clear(-1)

0 comments on commit 0402126

Please sign in to comment.