From f5d6324ce1bfd2d81cb2cfee9a6515963aa4ce41 Mon Sep 17 00:00:00 2001 From: Lars Reimann Date: Tue, 26 Nov 2024 16:11:04 +0100 Subject: [PATCH] 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> --- src/safeds/data/tabular/containers/_table.py | 10 +++++----- .../{test_count_row_if.py => test_count_rows_if.py} | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) rename tests/safeds/data/tabular/containers/_table/{test_count_row_if.py => test_count_rows_if.py} (88%) diff --git a/src/safeds/data/tabular/containers/_table.py b/src/safeds/data/tabular/containers/_table.py index fc32f9cc7..d53f314af 100644 --- a/src/safeds/data/tabular/containers/_table.py +++ b/src/safeds/data/tabular/containers/_table.py @@ -1007,7 +1007,7 @@ def transform_column( # ------------------------------------------------------------------------------------------------------------------ @overload - def count_row_if( + def count_rows_if( self, predicate: Callable[[Row], Cell[bool | None]], *, @@ -1015,14 +1015,14 @@ def count_row_if( ) -> 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]], *, @@ -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 diff --git a/tests/safeds/data/tabular/containers/_table/test_count_row_if.py b/tests/safeds/data/tabular/containers/_table/test_count_rows_if.py similarity index 88% rename from tests/safeds/data/tabular/containers/_table/test_count_row_if.py rename to tests/safeds/data/tabular/containers/_table/test_count_rows_if.py index b4ab7f289..638675d49 100644 --- a/tests/safeds/data/tabular/containers/_table/test_count_row_if.py +++ b/tests/safeds/data/tabular/containers/_table/test_count_rows_if.py @@ -1,4 +1,5 @@ import pytest + from safeds.data.tabular.containers import Table @@ -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( @@ -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