-
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.
feat: add temporal operations (#832)
Closes #XYZ ### Summary of Changes <!-- Please provide a summary of changes in this pull request, ensuring all changes are explained. --> Added temporal operations to the temporal interface. --------- Co-authored-by: megalinter-bot <[email protected]> Co-authored-by: Lars Reimann <[email protected]> Co-authored-by: Simon Breuer <[email protected]>
- Loading branch information
1 parent
3c6232e
commit 06eab77
Showing
8 changed files
with
284 additions
and
5 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
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
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_century.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(18, datetime.datetime(1800, 1, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(21, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_day(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.century(), expected) |
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_day.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(9, datetime.datetime(2022, 1, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(1, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_day(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.day(), expected) |
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_month.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(3, datetime.datetime(2022, 3, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(1, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_month(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.month(), expected) |
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_week.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(10, datetime.datetime(2023, 3, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(52, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_week(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.week(), expected) |
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_weekday.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(4, datetime.datetime(2023, 3, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(6, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_weekday(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.weekday(), expected) |
20 changes: 20 additions & 0 deletions
20
tests/safeds/data/tabular/containers/_temporal_cell/test_year.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,20 @@ | ||
import datetime | ||
|
||
import pytest | ||
|
||
from tests.helpers import assert_cell_operation_works | ||
|
||
|
||
@pytest.mark.parametrize( | ||
("expected", "input_date"), | ||
[ | ||
(2023, datetime.datetime(2023, 3, 9, 23, 29, 1, tzinfo=datetime.UTC)), | ||
(2022, datetime.date(2022, 1, 1)), | ||
], | ||
ids=[ | ||
"ISO datetime", | ||
"ISO date", | ||
], | ||
) | ||
def test_get_year(input_date: datetime.date, expected: bool) -> None: | ||
assert_cell_operation_works(input_date, lambda cell: cell.dt.year(), expected) |