-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closes #255 . ### Summary of Changes Users are now able to call Column#transform to apply a function to every data point within the column Co-authored-by: [email protected] --------- Co-authored-by: megalinter-bot <[email protected]> Co-authored-by: Lars Reimann <[email protected]>
- Loading branch information
1 parent
626f26b
commit 40fb756
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
tests/safeds/data/tabular/containers/_column/test_transform.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import pytest | ||
from safeds.data.tabular.containers import Column | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("column", "expected"), | ||
[ | ||
(Column("test", []), Column("test", [])), | ||
(Column("test", [1, 2]), Column("test", [2, 3])), | ||
(Column("test", [-0.5, 0, 4]), Column("test", [0.5, 1, 5])), | ||
], | ||
ids=["empty", "integers", "floats"], | ||
) | ||
def test_should_transform_column(column: Column, expected: Column) -> None: | ||
assert column.transform(lambda it: it + 1) == expected | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("column", "original"), | ||
[ | ||
(Column("test", []), Column("test", [])), | ||
(Column("test", [1, 2]), Column("test", [1, 2])), | ||
(Column("test", [-0.5, 0, 4]), Column("test", [-0.5, 0, 4])), | ||
], | ||
ids=["empty", "integers", "floats"], | ||
) | ||
def test_should_not_change_original_column(column: Column, original: Column) -> None: | ||
column.transform(lambda it: it + 1) | ||
assert column == original |