diff options
author | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 12:29:46 +0300 |
---|---|---|
committer | maxim-yurchuk <maxim-yurchuk@yandex-team.com> | 2024-10-09 13:14:22 +0300 |
commit | 9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80 (patch) | |
tree | a8fb3181d5947c0d78cf402aa56e686130179049 /contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py | |
parent | a44b779cd359f06c3ebbef4ec98c6b38609d9d85 (diff) | |
download | ydb-9731d8a4bb7ee2cc8554eaf133bb85498a4c7d80.tar.gz |
publishFullContrib: true for ydb
<HIDDEN_URL>
commit_hash:c82a80ac4594723cebf2c7387dec9c60217f603e
Diffstat (limited to 'contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py')
-rw-r--r-- | contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py b/contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py new file mode 100644 index 0000000000..255558a800 --- /dev/null +++ b/contrib/python/pandas/py2/pandas/tests/tslibs/test_ccalendar.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +from datetime import datetime + +import numpy as np +import pytest + +from pandas._libs.tslibs import ccalendar + + +@pytest.mark.parametrize("date_tuple,expected", [ + ((2001, 3, 1), 60), + ((2004, 3, 1), 61), + ((1907, 12, 31), 365), # End-of-year, non-leap year. + ((2004, 12, 31), 366), # End-of-year, leap year. +]) +def test_get_day_of_year_numeric(date_tuple, expected): + assert ccalendar.get_day_of_year(*date_tuple) == expected + + +def test_get_day_of_year_dt(): + dt = datetime.fromordinal(1 + np.random.randint(365 * 4000)) + result = ccalendar.get_day_of_year(dt.year, dt.month, dt.day) + + expected = (dt - dt.replace(month=1, day=1)).days + 1 + assert result == expected |