From 782113a074e6112b8d104753cc00151ba16a4bad Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:23:04 +0100 Subject: [PATCH 01/16] wip: working on better tests for docstrings --- conftest.py | 43 +++++++++++++++++++++++++++++++++++ src/pymorize/frequency.py | 2 +- src/pymorize/gather_inputs.py | 5 ++-- tests/conftest.py | 21 ----------------- 4 files changed, 47 insertions(+), 24 deletions(-) create mode 100644 conftest.py delete mode 100644 tests/conftest.py diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..669b359 --- /dev/null +++ b/conftest.py @@ -0,0 +1,43 @@ +import os +import re +from pathlib import Path + +import pytest + +from tests.utils.constants import TEST_ROOT + +pytest_plugins = [ + "tests.fixtures.configs", + "tests.fixtures.environment", + "tests.fixtures.fake_filesystem", + "tests.fixtures.sample_rules", + "tests.fixtures.config_files", + "tests.fixtures.CV_Dir", + "tests.fixtures.CMIP_Tables_Dir", +] + + +@pytest.hookimpl(tryfirst=True) +def pytest_collection_modifyitems(config, items): + for item in items: + if item.fspath and item.fspath.ext == ".py": + item.add_marker(pytest.mark.doctest) + + +@pytest.fixture(autouse=True) +def pathlib_doctest_directive(doctest_namespace): + """Replace PosixPath/WindowsPath with Path in doc-test output.""" + doctest_namespace["Path"] = Path + + def path_replace(output): + """Replace platform-specific Path output with generic Path in doc-tests.""" + return re.sub(r"(PosixPath|WindowsPath)\((.*?)\)", r"Path(\2)", output) + + doctest_namespace["path_replace"] = path_replace + + +def pytest_unconfigure(config): + """Remove all JSON files containing 'pipeline' in their name.""" + for file in os.listdir(): + if "pipeline" in file and file.endswith(".json"): + os.remove(file) diff --git a/src/pymorize/frequency.py b/src/pymorize/frequency.py index 55c6314..f309101 100644 --- a/src/pymorize/frequency.py +++ b/src/pymorize/frequency.py @@ -11,7 +11,7 @@ >>> freq = Frequency("day", 1.0) >>> print(freq.name) -'day' +day >>> print(freq.approx_interval) 1.0 >>> print(freq.time_method) diff --git a/src/pymorize/gather_inputs.py b/src/pymorize/gather_inputs.py index f8806fc..795c51f 100644 --- a/src/pymorize/gather_inputs.py +++ b/src/pymorize/gather_inputs.py @@ -84,12 +84,13 @@ def _input_pattern_from_env(config: dict) -> re.Pattern: re.compile('.*') >>> bool(pattern.match('test')) True - >>> pattern = _input_pattern_from_env(config_only_env_name) >>> os.environ["CMOR_PATTERN"] = "test*nc" + >>> pattern = _input_pattern_from_env(config_only_env_name) >>> pattern re.compile('test*nc') >>> bool(pattern.match('test')) - True + False + >>> del os.environ["CMOR_PATTERN"] >>> pattern = _input_pattern_from_env(config_only_env_value) >>> pattern re.compile('.*') diff --git a/tests/conftest.py b/tests/conftest.py deleted file mode 100644 index 5d19748..0000000 --- a/tests/conftest.py +++ /dev/null @@ -1,21 +0,0 @@ -import os - -from tests.utils.constants import TEST_ROOT - -pytest_plugins = [ - "tests.fixtures.configs", - "tests.fixtures.environment", - "tests.fixtures.fake_filesystem", - "tests.fixtures.sample_rules", - "tests.fixtures.config_files", - "tests.fixtures.CV_Dir", - "tests.fixtures.CMIP_Tables_Dir", -] - - -def pytest_unconfigure(config): - - # Remove all json files - for file in os.listdir(): - if "pipeline" in file and file.endswith(".json"): - os.remove(file) From e85542e7fc37733e7f616356edf8a91971f85084 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:27:57 +0100 Subject: [PATCH 02/16] wip: more doctest tries --- .github/workflows/CI-test.yaml | 2 ++ conftest.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI-test.yaml b/.github/workflows/CI-test.yaml index 2f394d2..2de788e 100644 --- a/.github/workflows/CI-test.yaml +++ b/.github/workflows/CI-test.yaml @@ -38,4 +38,6 @@ jobs: - name: Test with pytest run: | pytest -v --cov + - name: Test with doctest + run: | pytest -v --doctest-modules src/ diff --git a/conftest.py b/conftest.py index 669b359..c739abd 100644 --- a/conftest.py +++ b/conftest.py @@ -17,11 +17,11 @@ ] -@pytest.hookimpl(tryfirst=True) -def pytest_collection_modifyitems(config, items): - for item in items: - if item.fspath and item.fspath.ext == ".py": - item.add_marker(pytest.mark.doctest) +# @pytest.hookimpl(tryfirst=True) +# def pytest_collection_modifyitems(config, items): +# for item in items: +# if item.fspath and item.fspath.ext == ".py": +# item.add_marker(pytest.mark.doctest) @pytest.fixture(autouse=True) From 32fe2c578db720b4105d7a8851e43bc71b768d7a Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:32:47 +0100 Subject: [PATCH 03/16] wip: more doctest tries --- .github/workflows/CI-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI-test.yaml b/.github/workflows/CI-test.yaml index 2de788e..8a286f9 100644 --- a/.github/workflows/CI-test.yaml +++ b/.github/workflows/CI-test.yaml @@ -40,4 +40,4 @@ jobs: pytest -v --cov - name: Test with doctest run: | - pytest -v --doctest-modules src/ + PYTHONPATH=src pytest -v --doctest-modules src/ From 5a08e595e01be41264e57b21af24108604ec9981 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:36:03 +0100 Subject: [PATCH 04/16] wip: more doctest tries --- conftest.py | 10 +++++----- src/pymorize/frequency.py | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/conftest.py b/conftest.py index c739abd..669b359 100644 --- a/conftest.py +++ b/conftest.py @@ -17,11 +17,11 @@ ] -# @pytest.hookimpl(tryfirst=True) -# def pytest_collection_modifyitems(config, items): -# for item in items: -# if item.fspath and item.fspath.ext == ".py": -# item.add_marker(pytest.mark.doctest) +@pytest.hookimpl(tryfirst=True) +def pytest_collection_modifyitems(config, items): + for item in items: + if item.fspath and item.fspath.ext == ".py": + item.add_marker(pytest.mark.doctest) @pytest.fixture(autouse=True) diff --git a/src/pymorize/frequency.py b/src/pymorize/frequency.py index f309101..23c3e09 100644 --- a/src/pymorize/frequency.py +++ b/src/pymorize/frequency.py @@ -28,7 +28,7 @@ >>> freq = Frequency.for_name("day") >>> print(freq.name) -'day' +day """ from enum import Enum From 40fd98b80d136bc0e211054ecfb0b3dac5c5b169 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:46:25 +0100 Subject: [PATCH 05/16] wip --- src/pymorize/calendar.py | 11 +++---- src/pymorize/gather_inputs.py | 56 +---------------------------------- 2 files changed, 5 insertions(+), 62 deletions(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index 2540c54..e605f8f 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -16,13 +16,10 @@ >>> print(year_bounds) [[2000, 2001], [2002, 2003], [2004, 2005], [2006, 2007], [2008, 2009], [2010, 2010]] ->>> date_range = date_ranges_from_bounds(year_bounds, freq="Y") ->>> print(date_range) -([Timestamp('2000-12-31 00:00:00', freq='A-DEC'), Timestamp('2001-12-31 00:00:00', freq='A-DEC')], [Timestamp('2002-12-31 00:00:00', freq='A-DEC'), Timestamp('2003-12-31 00:00:00', freq='A-DEC')], [Timestamp('2004-12-31 00:00:00', freq='A-DEC'), Timestamp('2005-12-31 00:00:00', freq='A-DEC')], [Timestamp('2006-12-31 00:00:00', freq='A-DEC'), Timestamp('2007-12-31 00:00:00', freq='A-DEC')], [Timestamp('2008-12-31 00:00:00', freq='A-DEC'), Timestamp('2009-12-31 00:00:00', freq='A-DEC')], [Timestamp('2010-12-31 00:00:00', freq='A-DEC')]) - ->>> date_range = date_ranges_from_year_bounds(year_bounds, freq="Y") ->>> print(date_range) -([Timestamp('2000-12-31 00:00:00', freq='A-DEC'), Timestamp('2001-12-31 00:00:00', freq='A-DEC')], [Timestamp('2002-12-31 00:00:00', freq='A-DEC'), Timestamp('2003-12-31 00:00:00', freq='A-DEC')], [Timestamp('2004-12-31 00:00:00', freq='A-DEC'), Timestamp('2005-12-31 00:00:00', freq='A-DEC')], [Timestamp('2006-12-31 00:00:00', freq='A-DEC'), Timestamp('2007-12-31 00:00:00', freq='A-DEC')], [Timestamp('2008-12-31 00:00:00', freq='A-DEC'), Timestamp('2009-12-31 00:00:00', freq='A-DEC')], [Timestamp('2010-12-31 00:00:00', freq='A-DEC')]) +>>> bounds = [("2020-01-01", "2020-12-31")] +>>> date_ranges = date_ranges_from_bounds(bounds, freq="M") +>>> print(date_ranges) +(DatetimeIndex(['2020-01-31', '2020-02-29', ..., '2020-12-31'], dtype='datetime64[ns]', freq='M'),) """ import pendulum diff --git a/src/pymorize/gather_inputs.py b/src/pymorize/gather_inputs.py index 795c51f..7cae6ef 100644 --- a/src/pymorize/gather_inputs.py +++ b/src/pymorize/gather_inputs.py @@ -297,62 +297,8 @@ def gather_inputs(config: dict) -> dict: config: The configuration dictionary with the input files added. - - Examples - -------- - Assuming a filesystem with:: - - /path/to/input/files/test2000.nc - /path/to/input/files/test2001.nc - /path/to/input/files/test2002.nc - /path/to/input/files/test2003.nc - /path/to/input/files/test2004.nc - /path/to/input/files/test2005.nc - /path/to/input/files/test2006.nc - /path/to/input/files/test2007.nc - /path/to/input/files/test2008.nc - /path/to/input/files/test2009.nc - /path/to/input/files/test2010.nc - - >>> config = { - ... "rules": [ - ... { - ... "input_patterns": [ - ... "/path/to/input/files/test*nc" - ... ], - ... "year_start": 2000, - ... "year_end": 2010 - ... } - ... ] - ... } - >>> gather_inputs(config) - { - "rules": [ - { - "input_patterns": [ - "/path/to/input/files/test*nc" - ], - "year_start": 2000, - "year_end": 2010, - "input_files": { - "/path/to/input/files/test*nc": [ - "/path/to/input/files/test2000.nc", - "/path/to/input/files/test2001.nc", - "/path/to/input/files/test2002.nc", - "/path/to/input/files/test2003.nc", - "/path/to/input/files/test2004.nc", - "/path/to/input/files/test2005.nc", - "/path/to/input/files/test2006.nc", - "/path/to/input/files/test2007.nc", - "/path/to/input/files/test2008.nc", - "/path/to/input/files/test2009.nc", - "/path/to/input/files/test2010.nc" - ], - } - } - ] - } """ + # NOTE(PG): Example removed from docstring as it is scheduled for deprecation. rules = config.get("rules", []) for rule in rules: input_patterns = rule.get("input_patterns", []) From be2311abfcba7cf3039ac20b014c3c86633ec768 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Wed, 6 Nov 2024 09:51:17 +0100 Subject: [PATCH 06/16] wip: fixing tests some more --- src/pymorize/calendar.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index e605f8f..29ba292 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -19,7 +19,10 @@ >>> bounds = [("2020-01-01", "2020-12-31")] >>> date_ranges = date_ranges_from_bounds(bounds, freq="M") >>> print(date_ranges) -(DatetimeIndex(['2020-01-31', '2020-02-29', ..., '2020-12-31'], dtype='datetime64[ns]', freq='M'),) +DatetimeIndex(['2020-01-31', '2020-02-29', '2020-03-31', '2020-04-30', + '2020-05-31', '2020-06-30', '2020-07-31', '2020-08-31', + '2020-09-30', '2020-10-31', '2020-11-30', '2020-12-31'], + dtype='datetime64[ns]', freq='ME') """ import pendulum From a1585b0ec50f8d91c267b9a08b88fb8f4113b7d8 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 16:43:22 +0100 Subject: [PATCH 07/16] wip, removes bad example in calendar --- .github/workflows/CI-test.yaml | 2 +- pytest.ini | 2 ++ src/pymorize/calendar.py | 13 ++++--------- src/pymorize/gather_inputs.py | 5 +++-- 4 files changed, 10 insertions(+), 12 deletions(-) create mode 100644 pytest.ini diff --git a/.github/workflows/CI-test.yaml b/.github/workflows/CI-test.yaml index 8a286f9..9092a75 100644 --- a/.github/workflows/CI-test.yaml +++ b/.github/workflows/CI-test.yaml @@ -40,4 +40,4 @@ jobs: pytest -v --cov - name: Test with doctest run: | - PYTHONPATH=src pytest -v --doctest-modules src/ + PYTHONPATH=src pytest -v --doctest-modules --doctest-options=+NORMALIZE_WHITESPACE src/ diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..5a96837 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,2 @@ +[pytest] +doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index 29ba292..3de9bd8 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -20,9 +20,10 @@ >>> date_ranges = date_ranges_from_bounds(bounds, freq="M") >>> print(date_ranges) DatetimeIndex(['2020-01-31', '2020-02-29', '2020-03-31', '2020-04-30', - '2020-05-31', '2020-06-30', '2020-07-31', '2020-08-31', - '2020-09-30', '2020-10-31', '2020-11-30', '2020-12-31'], - dtype='datetime64[ns]', freq='ME') + '2020-05-31', '2020-06-30', '2020-07-31', '2020-08-31', + '2020-09-30', '2020-10-31', '2020-11-30', '2020-12-31'], + dtype='datetime64[ns]', + freq='ME') """ import pendulum @@ -157,12 +158,6 @@ def date_ranges_from_bounds(bounds, freq: str = "M", **kwargs): Examples -------- - >>> bounds = [("2020-01-01", "2020-01-31"), ("2020-02-01", "2020-02-29")] - >>> date_ranges = date_ranges_from_bounds(bounds) - >>> print(date_ranges) - (DatetimeIndex(['2020-01-01', '2020-01-02', ..., '2020-01-31'], dtype='datetime64[ns]', freq='D'), - DatetimeIndex(['2020-02-01', '2020-02-02', ..., '2020-02-29'], dtype='datetime64[ns]', freq='D')) - >>> bounds = [("2020-01-01", "2020-12-31")] >>> date_ranges = date_ranges_from_bounds(bounds, freq="M") >>> print(date_ranges) diff --git a/src/pymorize/gather_inputs.py b/src/pymorize/gather_inputs.py index 7cae6ef..a8f7667 100644 --- a/src/pymorize/gather_inputs.py +++ b/src/pymorize/gather_inputs.py @@ -155,8 +155,9 @@ def _resolve_symlinks(files: List[pathlib.Path]) -> List[pathlib.Path]: -------- >>> from pathlib import Path >>> files = [Path('/path/to/file1'), Path('/path/to/file2')] - >>> _resolve_symlinks(files) - [Path('/path/to/file1'), Path('/path/to/file2')] + >>> paths = _resolve_symlinks(files) + >>> [str(p) for p in paths] # Convert to strings for doctest + ['/path/to/file1', '/path/to/file2'] """ if not all(isinstance(f, pathlib.Path) for f in files): logger.error("All files must be pathlib.Path objects. Got the following:") From 3063cd64e187cd319f4ff29c88a48ad837018ee6 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 15:49:46 +0100 Subject: [PATCH 08/16] test: fixes test with bad pint dependency (https://tinyurl.com/ypf99xnh) --- .github/workflows/CI-test.yaml | 2 +- setup.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI-test.yaml b/.github/workflows/CI-test.yaml index 9092a75..8caff7d 100644 --- a/.github/workflows/CI-test.yaml +++ b/.github/workflows/CI-test.yaml @@ -18,7 +18,7 @@ jobs: with: submodules: recursive - name: Set up Python ${{ matrix.python-version }} - uses: actions/setup-python@v3 + uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - name: Install dependencies diff --git a/setup.py b/setup.py index 94d8305..9e44e14 100644 --- a/setup.py +++ b/setup.py @@ -41,6 +41,7 @@ def read(filename): "deprecation", "distributed", "dpath", + "flexparser < 0.4", # NOTE(PG): See https://tinyurl.com/ypf99xnh "flox", "imohash", "numbagg", From e21272bc801dc541f3478d88b527c9f542ac9c36 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 16:51:33 +0100 Subject: [PATCH 09/16] ci: doctest options in pytest.ini --- .github/workflows/CI-test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/CI-test.yaml b/.github/workflows/CI-test.yaml index 8caff7d..a97c76c 100644 --- a/.github/workflows/CI-test.yaml +++ b/.github/workflows/CI-test.yaml @@ -40,4 +40,4 @@ jobs: pytest -v --cov - name: Test with doctest run: | - PYTHONPATH=src pytest -v --doctest-modules --doctest-options=+NORMALIZE_WHITESPACE src/ + PYTHONPATH=src pytest -v --doctest-modules src/ From 1abd9efd08fa02d589f1fcbb7397a97db54d3b76 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:01:12 +0100 Subject: [PATCH 10/16] fix: doctests for filecache work now --- src/pymorize/filecache.py | 37 +++++++++++++++++++++++++------ tests/data/dummy_data/random1.nc | Bin 0 -> 1060 bytes tests/data/dummy_data/random2.nc | Bin 0 -> 1060 bytes 3 files changed, 30 insertions(+), 7 deletions(-) create mode 100644 tests/data/dummy_data/random1.nc create mode 100644 tests/data/dummy_data/random2.nc diff --git a/src/pymorize/filecache.py b/src/pymorize/filecache.py index 34e753f..5b5eef0 100644 --- a/src/pymorize/filecache.py +++ b/src/pymorize/filecache.py @@ -39,12 +39,31 @@ .. code-block:: python - >>> filepath = "/pool/data/CO2f_fesom_1850-01-01_1900-01-01.nc" + >>> filepath = "tests/data/test_experiments/my_expid/outdata/fesom/volo.nc" >>> cache.add_file(filepath) >>> # adding multiple files at once - >>> cache.add_files(["/path/to/file1.nc", "/path/to/file2.nc"]) + >>> cache.add_files(["tests/data/dummy_data/random1.nc", "tests/data/dummy_data/random2.nc"]) + +You can access the metadata of a file in the cache using the `get` method: + +.. code-block:: python + + >>> filepath = "tests/data/test_experiments/my_expid/outdata/fesom/volo.nc" >>> # alternative way of adding file to cache and getting the metadata is by usuig the `get` method - >>> cache.get("filepath") + >>> cache.get(filepath) + filepath tests/data/test_experiments/my_expid/outdata/f... + filename volo.nc + checksum imohash:c8047bbd7e292dbe54a6387611f500c4 + filesize 584 + mtime 1730990838.355325 + start 1951-01-02 00:00:00 + end 1951-01-13 00:00:00 + timespan 11 days, 0:00:00 + freq D + steps 12 + variable volo + units m3 + Name: 0, dtype: object For an overview of the cached data, use `summary` method: This method returns a @@ -55,6 +74,14 @@ .. code-block:: python >>> cache.summary() + variable seq volo + freq D D + start 0001-01-01 00:00:00 1951-01-02 00:00:00 + end 0001-01-11 00:00:00 1951-01-13 00:00:00 + timespan 10 days 00:00:00 11 days 00:00:00 + nfiles 2 1 + steps 11 12 + size 2120 584 To use a subset of the collection for a given variable, use `select_range` method. This will limit the files in the cache to those that are within the @@ -537,7 +564,3 @@ def register_cache(ds): filename = ds.encoding["source"] fc.add_file(filename) return ds - - -datapath = "/work/ba1103/a270073/out/awicm-1.0-recom/awi-esm-1-1-lr_kh800/piControl/outdata/fesom" -# filepat = "CO2f_fesom_*nc" diff --git a/tests/data/dummy_data/random1.nc b/tests/data/dummy_data/random1.nc new file mode 100644 index 0000000000000000000000000000000000000000..0c993d3ffd834447e3c42818fb8f456078511eb8 GIT binary patch literal 1060 zcma)5!EV$r5OvA6EVMmwtGcl~50GVKIrju}JLTcvo=iC-lg% zM?Qm3;X8IO%y?swMo49LJsyuo&(F`3G&_4h2swoD7)AhNWMwU2MhhyfaNct=RTfesP{Dg#j(FX~ejMKOhxA&*2V!PiRi}UFiHic0|01k=ux#_2u{oUJwHEB;^h1hA>BV|8=(x;HxBn8KA+6|6I_zVxonKCzq`HHSNWR0)f*a|(%DJ0IE}(H8V2D! zqG_h-z8U&I3TikKV3xR;JLY!w+ ztqV~ZnJ!ngSm|1F`+g(-O(HDT>|KEaJAg5^5%IP#_um?MKg9V7^u|h>b=EbDT@UUx ztQp?#C=b?uD-v^I<0_Ob&*N<&>=#slFVQ0H+a(6@68yDXa_O6Rt sLRcqS(o(`cx;!K7vx`3w);(C#{vfQoRMKt<`{HVD2(xWNNYdVtKcug~{Qv*} literal 0 HcmV?d00001 From d91c771934ee7beb71c8c4cf477929159f10777a Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:05:52 +0100 Subject: [PATCH 11/16] fix: attempt number 2 --- pytest.ini | 2 +- src/pymorize/filecache.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pytest.ini b/pytest.ini index 5a96837..3b8e6a6 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,2 +1,2 @@ [pytest] -doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL +doctest_optionflags = NORMALIZE_WHITESPACE IGNORE_EXCEPTION_DETAIL ELLIPSIS diff --git a/src/pymorize/filecache.py b/src/pymorize/filecache.py index 5b5eef0..26394b8 100644 --- a/src/pymorize/filecache.py +++ b/src/pymorize/filecache.py @@ -55,7 +55,7 @@ filename volo.nc checksum imohash:c8047bbd7e292dbe54a6387611f500c4 filesize 584 - mtime 1730990838.355325 + mtime 1730995292.193093 start 1951-01-02 00:00:00 end 1951-01-13 00:00:00 timespan 11 days, 0:00:00 From 9cb01177843bbf227135c673c1463d27a79a5e92 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:08:57 +0100 Subject: [PATCH 12/16] fix: with ellipses --- src/pymorize/filecache.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pymorize/filecache.py b/src/pymorize/filecache.py index 26394b8..56e84f2 100644 --- a/src/pymorize/filecache.py +++ b/src/pymorize/filecache.py @@ -55,7 +55,7 @@ filename volo.nc checksum imohash:c8047bbd7e292dbe54a6387611f500c4 filesize 584 - mtime 1730995292.193093 + mtime ... start 1951-01-02 00:00:00 end 1951-01-13 00:00:00 timespan 11 days, 0:00:00 From 5c234b4723aa40f0c11689390dd1a47ab93b7c3d Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:14:41 +0100 Subject: [PATCH 13/16] fix: with ellipses again --- src/pymorize/calendar.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index 3de9bd8..90408ec 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -19,11 +19,7 @@ >>> bounds = [("2020-01-01", "2020-12-31")] >>> date_ranges = date_ranges_from_bounds(bounds, freq="M") >>> print(date_ranges) -DatetimeIndex(['2020-01-31', '2020-02-29', '2020-03-31', '2020-04-30', - '2020-05-31', '2020-06-30', '2020-07-31', '2020-08-31', - '2020-09-30', '2020-10-31', '2020-11-30', '2020-12-31'], - dtype='datetime64[ns]', - freq='ME') +DatetimeIndex(['2020-01-31', ..., '2020-12-31'], dtype='datetime64[ns]', freq='ME') """ import pendulum From 5b47b962ae80c3a4abbd6abee2151aeb32775c22 Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:18:04 +0100 Subject: [PATCH 14/16] test: removes an example, too difficult to reproduce in doctest right now --- src/pymorize/calendar.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index 90408ec..eb71659 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -15,11 +15,6 @@ >>> year_bounds = year_bounds_major_digits(2000, 2010, 2, 2) >>> print(year_bounds) [[2000, 2001], [2002, 2003], [2004, 2005], [2006, 2007], [2008, 2009], [2010, 2010]] - ->>> bounds = [("2020-01-01", "2020-12-31")] ->>> date_ranges = date_ranges_from_bounds(bounds, freq="M") ->>> print(date_ranges) -DatetimeIndex(['2020-01-31', ..., '2020-12-31'], dtype='datetime64[ns]', freq='ME') """ import pendulum From b6395a987f9e52f7ae9b4e4d7a05d950179fe76c Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:21:37 +0100 Subject: [PATCH 15/16] still trying --- src/pymorize/calendar.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index eb71659..b613e44 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -150,8 +150,7 @@ def date_ranges_from_bounds(bounds, freq: str = "M", **kwargs): Examples -------- >>> bounds = [("2020-01-01", "2020-12-31")] - >>> date_ranges = date_ranges_from_bounds(bounds, freq="M") - >>> print(date_ranges) + >>> date_ranges_from_bounds(bounds, freq="M") (DatetimeIndex(['2020-01-31', '2020-02-29', ..., '2020-12-31'], dtype='datetime64[ns]', freq='M'),) """ objs = [] From 76b003f88a098e08381b2633a3ad5621180c48ef Mon Sep 17 00:00:00 2001 From: Paul Gierz Date: Thu, 7 Nov 2024 17:26:27 +0100 Subject: [PATCH 16/16] fix frequency string in doctest --- src/pymorize/calendar.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pymorize/calendar.py b/src/pymorize/calendar.py index b613e44..c026a01 100644 --- a/src/pymorize/calendar.py +++ b/src/pymorize/calendar.py @@ -151,7 +151,7 @@ def date_ranges_from_bounds(bounds, freq: str = "M", **kwargs): -------- >>> bounds = [("2020-01-01", "2020-12-31")] >>> date_ranges_from_bounds(bounds, freq="M") - (DatetimeIndex(['2020-01-31', '2020-02-29', ..., '2020-12-31'], dtype='datetime64[ns]', freq='M'),) + DatetimeIndex(['2020-01-31', '2020-02-29', ..., '2020-12-31'], dtype='datetime64[ns]', freq='ME') """ objs = [] for start, end in bounds: