Skip to content

Commit

Permalink
Fix pandas FutureWarnings in test cases, update CI deps (dynamicslab#207
Browse files Browse the repository at this point in the history
)

Update CI dependencies, fix FutureWarnings about datetime comparisons.
  • Loading branch information
gauchm committed Aug 7, 2023
1 parent fab7517 commit 11fc743
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs-ci.yml
Expand Up @@ -9,8 +9,8 @@ jobs:
docs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install pandoc
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/package-install.yml
Expand Up @@ -10,9 +10,9 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: '3.8'

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Expand Up @@ -10,7 +10,7 @@ jobs:
steps:
- uses: actions/checkout@master
- name: Set up Python 3.8
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.8'
- name: Install pypa/build
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/pytest-ci.yml
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
# Checkout the repository under $GITHUB_WORKSPACE
- uses: actions/checkout@v2
- uses: actions/checkout@v3

# initialize conda
- name: Conda setup
Expand All @@ -26,7 +26,7 @@ jobs:
python-version: '3.10'

# cache the conda installation to speedup the CI runs
- uses: actions/cache@v2
- uses: actions/cache@v3
id: cache
with:
path: /usr/share/miniconda/envs/neuralhydrology
Expand Down
9 changes: 4 additions & 5 deletions test/test_config_runs.py
@@ -1,6 +1,5 @@
"""Integration tests that perform full runs. """
import pickle
from datetime import datetime
from pathlib import Path
from typing import Dict, Tuple, Callable

Expand Down Expand Up @@ -161,7 +160,7 @@ def test_multi_timescale_regression(get_config: Fixture[Callable[[str], dict]],
daily_results = results['1D']['xr']
assert (results['1D']['xr']['time_step'].values == [0]).all()
assert pd.to_datetime(daily_results['date'].values[0]) == test_start_date
assert pd.to_datetime(daily_results['date'].values[-1]) == test_end_date.date()
assert pd.to_datetime(daily_results['date'].values[-1]) == test_end_date.floor('D')
assert len(daily_results['qobs_mm_per_hour_obs']) == len(discharge) // 24

assert len(discharge) == len(hourly_results)
Expand Down Expand Up @@ -213,8 +212,8 @@ def _check_results(config: Config, basin: str, discharge: pd.Series = None):

results = _get_basin_results(config.run_dir, 1)[basin]['1D']['xr'].isel(time_step=-1)

assert pd.to_datetime(results['date'].values[0]) == test_start_date.date()
assert pd.to_datetime(results['date'].values[-1]) == test_end_date.date()
assert pd.to_datetime(results['date'].values[0]) == test_start_date.floor('D')
assert pd.to_datetime(results['date'].values[-1]) == test_end_date.floor('D')

if discharge is None:
discharge = _get_discharge(config, basin)
Expand All @@ -226,7 +225,7 @@ def _check_results(config: Config, basin: str, discharge: pd.Series = None):
assert not pd.isna(results[f'{config.target_variables[0]}_sim']).any()


def _get_test_start_end_dates(config: Config) -> Tuple[datetime, datetime]:
def _get_test_start_end_dates(config: Config) -> Tuple[pd.Timestamp, pd.Timestamp]:
test_start_date = pd.to_datetime(config.test_start_date, format='%d/%m/%Y')
test_end_date = pd.to_datetime(config.test_end_date, format='%d/%m/%Y') + pd.Timedelta(days=1, seconds=-1)

Expand Down

0 comments on commit 11fc743

Please sign in to comment.