From b9a85d91acc08547fc50753e1973b98f1e57afbd Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Wed, 16 Oct 2024 16:01:43 +0200 Subject: [PATCH 01/11] Startting with new func --- src/ssb_konjunk/prompts.py | 19 +++++++++++++++++++ tests/test_prompts.py | 4 ++++ 2 files changed, 23 insertions(+) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index 27dc0f9..93dad2c 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -335,3 +335,22 @@ def publishing_date() -> str: date = set_publishing_date() ok_date = check_publishing_date(date) return ok_date + +def get_previous_month(year: str|int, month:str|int) -> tuple[int, int]: + """Turn e.g. month 01 year 2023 into month 12 and year 2022. + + Args: + year: the current year YYYY + month: the current month MM + Return: + tuple[int, int]: the previous month with year. + """ + prev_month = int(month) - 1 + + if prev_month != 0: + prev_year = year + else: + prev_month = 12 + prev_year = int(year) - 1 + + return prev_year, prev_month \ No newline at end of file diff --git a/tests/test_prompts.py b/tests/test_prompts.py index a096bb2..999e56e 100644 --- a/tests/test_prompts.py +++ b/tests/test_prompts.py @@ -7,6 +7,7 @@ from ssb_konjunk.prompts import extract_start_end_dates from ssb_konjunk.prompts import iterate_years_months from ssb_konjunk.prompts import validate_month +from ssb_konjunk.prompts import get_previous_month """Test of function days in month""" @@ -148,3 +149,6 @@ def test_validate_month() -> None: assert validate_month(10) == "10" assert validate_month("10") == "10" + +def test_get_previous_month() -> None: + assert get_previous_month(2022, 1) == \ No newline at end of file From 0083b4881cbbf96ae25ddc3e50e0b2ecdda7d908 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:36:52 +0200 Subject: [PATCH 02/11] nox --- src/ssb_konjunk/prompts.py | 11 ++++++----- tests/test_prompts.py | 11 +++++++++-- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index 93dad2c..41bd66c 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -336,9 +336,10 @@ def publishing_date() -> str: ok_date = check_publishing_date(date) return ok_date -def get_previous_month(year: str|int, month:str|int) -> tuple[int, int]: + +def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: """Turn e.g. month 01 year 2023 into month 12 and year 2022. - + Args: year: the current year YYYY month: the current month MM @@ -346,11 +347,11 @@ def get_previous_month(year: str|int, month:str|int) -> tuple[int, int]: tuple[int, int]: the previous month with year. """ prev_month = int(month) - 1 - + if prev_month != 0: prev_year = year else: prev_month = 12 prev_year = int(year) - 1 - - return prev_year, prev_month \ No newline at end of file + + return prev_year, prev_month diff --git a/tests/test_prompts.py b/tests/test_prompts.py index 999e56e..9ba2f42 100644 --- a/tests/test_prompts.py +++ b/tests/test_prompts.py @@ -5,9 +5,9 @@ from ssb_konjunk.prompts import bump_quarter from ssb_konjunk.prompts import days_in_month from ssb_konjunk.prompts import extract_start_end_dates +from ssb_konjunk.prompts import get_previous_month from ssb_konjunk.prompts import iterate_years_months from ssb_konjunk.prompts import validate_month -from ssb_konjunk.prompts import get_previous_month """Test of function days in month""" @@ -150,5 +150,12 @@ def test_validate_month() -> None: assert validate_month(10) == "10" assert validate_month("10") == "10" + def test_get_previous_month() -> None: - assert get_previous_month(2022, 1) == \ No newline at end of file + prev_month = get_previous_month(2022, 1) + assert prev_month[0] == 2021, f"Previous year for previous month: {prev_month[0]}" + assert prev_month[1] == 12, f"Previous month for previous month: {prev_month[1]}" + + prev_month = get_previous_month(2022, 12) + assert prev_month[0] == 2022, f"Previous year for previous month: {prev_month[0]}" + assert prev_month[1] == 11, f"Previous month for previous month: {prev_month[1]}" From 88398283ec73508211af56174a5d5733f6fa2bf0 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:40:00 +0200 Subject: [PATCH 03/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index 41bd66c..c7fb9da 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -354,4 +354,4 @@ def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: prev_month = 12 prev_year = int(year) - 1 - return prev_year, prev_month + return (prev_year, prev_month) From 0e7893f8b16915a9da64ba04858cc1c45fcbb3eb Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:41:34 +0200 Subject: [PATCH 04/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index c7fb9da..97e58c5 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -349,7 +349,7 @@ def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: prev_month = int(month) - 1 if prev_month != 0: - prev_year = year + prev_year = int(year) else: prev_month = 12 prev_year = int(year) - 1 From f1d3c8802d9a17eb8c71ef9663fbf454698f1ab6 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:46:58 +0200 Subject: [PATCH 05/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index 97e58c5..a9e08a5 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -354,4 +354,4 @@ def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: prev_month = 12 prev_year = int(year) - 1 - return (prev_year, prev_month) + return prev_year, prev_month From b8570758d315d479d53902a10e34a6ff8b39fa7e Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:49:04 +0200 Subject: [PATCH 06/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index a9e08a5..d35d5ea 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -337,14 +337,14 @@ def publishing_date() -> str: return ok_date -def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: +def get_previous_month(year: str | int, month: str | int) -> list[int, int]: """Turn e.g. month 01 year 2023 into month 12 and year 2022. Args: - year: the current year YYYY - month: the current month MM + year: the current year YYYY. + month: the current month MM. Return: - tuple[int, int]: the previous month with year. + list[int, int]: the previous month with year. """ prev_month = int(month) - 1 @@ -354,4 +354,4 @@ def get_previous_month(year: str | int, month: str | int) -> tuple[int, int]: prev_month = 12 prev_year = int(year) - 1 - return prev_year, prev_month + return [prev_year, prev_month] From 1fea717792e81c2fd18324ba253e6b5f1d02515c Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:50:15 +0200 Subject: [PATCH 07/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index d35d5ea..c200291 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -343,6 +343,7 @@ def get_previous_month(year: str | int, month: str | int) -> list[int, int]: Args: year: the current year YYYY. month: the current month MM. + Return: list[int, int]: the previous month with year. """ From abfbb94265c6ac361104f70acf3c87afecc66185 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:53:13 +0200 Subject: [PATCH 08/11] =?UTF-8?q?made=20tup=C3=B8e=20in=20return?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/ssb_konjunk/prompts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index c200291..c617da3 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -344,7 +344,7 @@ def get_previous_month(year: str | int, month: str | int) -> list[int, int]: year: the current year YYYY. month: the current month MM. - Return: + Returns: list[int, int]: the previous month with year. """ prev_month = int(month) - 1 From 3a549d31870cf75eedf098ba71832e491d8a1b08 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 15:57:12 +0200 Subject: [PATCH 09/11] Update type hints --- src/ssb_konjunk/prompts.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ssb_konjunk/prompts.py b/src/ssb_konjunk/prompts.py index c617da3..1bfaa7e 100644 --- a/src/ssb_konjunk/prompts.py +++ b/src/ssb_konjunk/prompts.py @@ -337,7 +337,7 @@ def publishing_date() -> str: return ok_date -def get_previous_month(year: str | int, month: str | int) -> list[int, int]: +def get_previous_month(year: str | int, month: str | int) -> list[int]: """Turn e.g. month 01 year 2023 into month 12 and year 2022. Args: @@ -345,7 +345,7 @@ def get_previous_month(year: str | int, month: str | int) -> list[int, int]: month: the current month MM. Returns: - list[int, int]: the previous month with year. + list[int]: the previous month with year. """ prev_month = int(month) - 1 From 8ef2f9f71780a94d2fe113719db9b26ddb7505ba Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 16:03:46 +0200 Subject: [PATCH 10/11] Updated docs --- docs/ssb_konjunk.rst | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/docs/ssb_konjunk.rst b/docs/ssb_konjunk.rst index 649c439..2b31a3d 100644 --- a/docs/ssb_konjunk.rst +++ b/docs/ssb_konjunk.rst @@ -26,6 +26,14 @@ ssb\_konjunk.prompts module :undoc-members: :show-inheritance: +ssb\_konjunk.rounding module +---------------------------- + +.. automodule:: ssb_konjunk.rounding + :members: + :undoc-members: + :show-inheritance: + ssb\_konjunk.saving module -------------------------- @@ -34,26 +42,26 @@ ssb\_konjunk.saving module :undoc-members: :show-inheritance: -ssb\_konjunk.timestamp module ------------------------------ +ssb\_konjunk.statbank\_format module +------------------------------------ -.. automodule:: ssb_konjunk.timestamp +.. automodule:: ssb_konjunk.statbank_format :members: :undoc-members: :show-inheritance: -ssb\_konjunk.xml\_handling module ---------------------------------- +ssb\_konjunk.timestamp module +----------------------------- -.. automodule:: ssb_konjunk.xml_handling +.. automodule:: ssb_konjunk.timestamp :members: :undoc-members: :show-inheritance: -ssb\_konjunk.rounding module +ssb\_konjunk.xml\_handling module --------------------------------- -.. automodule:: ssb_konjunk.rounding +.. automodule:: ssb_konjunk.xml_handling :members: :undoc-members: :show-inheritance: From 5c8722195f20067c78f1056d9f5f7af943868839 Mon Sep 17 00:00:00 2001 From: Johanne Saxegaard Date: Mon, 21 Oct 2024 16:04:14 +0200 Subject: [PATCH 11/11] Release 0.1.14 --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 162a5aa..3edc922 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "ssb-konjunk" -version = "0.1.13" +version = "0.1.14" description = "SSB Konjunk" authors = ["Edvard Garmannslund "] license = "MIT"