Skip to content

Commit

Permalink
feat: rename count_row_if to count_rows_if (#960)
Browse files Browse the repository at this point in the history
### Summary of Changes

Rename `Table.count_row_if` to `Table.count_rows_if` (plural). 

For all other methods of `Table`, the plural form was used, but if users
typed "rows", this method was not suggested by auto-completion. The
`_if` suffix is still included, to distinguish the method from the
attribute `row_count`.

---------

Co-authored-by: megalinter-bot <[email protected]>
  • Loading branch information
lars-reimann and megalinter-bot authored Nov 26, 2024
1 parent 0a9d905 commit f5d6324
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/safeds/data/tabular/containers/_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -1007,22 +1007,22 @@ def transform_column(
# ------------------------------------------------------------------------------------------------------------------

@overload
def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
ignore_unknown: Literal[True] = ...,
) -> int: ...

@overload
def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
ignore_unknown: bool,
) -> int | None: ...

def count_row_if(
def count_rows_if(
self,
predicate: Callable[[Row], Cell[bool | None]],
*,
Expand Down Expand Up @@ -1059,10 +1059,10 @@ def count_row_if(
--------
>>> from safeds.data.tabular.containers import Table
>>> table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]})
>>> table.count_row_if(lambda row: row["col1"] == row["col2"])
>>> table.count_rows_if(lambda row: row["col1"] == row["col2"])
2
>>> table.count_row_if(lambda row: row["col1"] > row["col2"])
>>> table.count_rows_if(lambda row: row["col1"] > row["col2"])
0
"""
expression = predicate(_LazyVectorizedRow(self))._polars_expression
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import pytest

from safeds.data.tabular.containers import Table


Expand Down Expand Up @@ -30,7 +31,7 @@ def test_should_handle_boolean_logic(
expected: int,
) -> None:
table = Table({"a": values})
assert table.count_row_if(lambda row: row["a"] < 2) == expected
assert table.count_rows_if(lambda row: row["a"] < 2) == expected


@pytest.mark.parametrize(
Expand Down Expand Up @@ -61,4 +62,4 @@ def test_should_handle_kleene_logic(
expected: int | None,
) -> None:
table = Table({"a": values})
assert table.count_row_if(lambda row: row["a"] < 2, ignore_unknown=False) == expected
assert table.count_rows_if(lambda row: row["a"] < 2, ignore_unknown=False) == expected

0 comments on commit f5d6324

Please sign in to comment.