Skip to content

Commit f5d6324

Browse files
feat: rename count_row_if to count_rows_if (#960)
### 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 <129584137+megalinter-bot@users.noreply.github.com>
1 parent 0a9d905 commit f5d6324

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/safeds/data/tabular/containers/_table.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,22 +1007,22 @@ def transform_column(
10071007
# ------------------------------------------------------------------------------------------------------------------
10081008

10091009
@overload
1010-
def count_row_if(
1010+
def count_rows_if(
10111011
self,
10121012
predicate: Callable[[Row], Cell[bool | None]],
10131013
*,
10141014
ignore_unknown: Literal[True] = ...,
10151015
) -> int: ...
10161016

10171017
@overload
1018-
def count_row_if(
1018+
def count_rows_if(
10191019
self,
10201020
predicate: Callable[[Row], Cell[bool | None]],
10211021
*,
10221022
ignore_unknown: bool,
10231023
) -> int | None: ...
10241024

1025-
def count_row_if(
1025+
def count_rows_if(
10261026
self,
10271027
predicate: Callable[[Row], Cell[bool | None]],
10281028
*,
@@ -1059,10 +1059,10 @@ def count_row_if(
10591059
--------
10601060
>>> from safeds.data.tabular.containers import Table
10611061
>>> table = Table({"col1": [1, 2, 3], "col2": [1, 3, 3]})
1062-
>>> table.count_row_if(lambda row: row["col1"] == row["col2"])
1062+
>>> table.count_rows_if(lambda row: row["col1"] == row["col2"])
10631063
2
10641064
1065-
>>> table.count_row_if(lambda row: row["col1"] > row["col2"])
1065+
>>> table.count_rows_if(lambda row: row["col1"] > row["col2"])
10661066
0
10671067
"""
10681068
expression = predicate(_LazyVectorizedRow(self))._polars_expression

tests/safeds/data/tabular/containers/_table/test_count_row_if.py renamed to tests/safeds/data/tabular/containers/_table/test_count_rows_if.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import pytest
2+
23
from safeds.data.tabular.containers import Table
34

45

@@ -30,7 +31,7 @@ def test_should_handle_boolean_logic(
3031
expected: int,
3132
) -> None:
3233
table = Table({"a": values})
33-
assert table.count_row_if(lambda row: row["a"] < 2) == expected
34+
assert table.count_rows_if(lambda row: row["a"] < 2) == expected
3435

3536

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

0 commit comments

Comments
 (0)