Skip to content

Commit

Permalink
Merge pull request #129 from Deltares/fix-tests
Browse files Browse the repository at this point in the history
some fixing of the tests
  • Loading branch information
shartgring authored Sep 23, 2024
2 parents 32785ba + fe629bf commit 73b79bf
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 30 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
max-parallel: 5
matrix:
python-version: ["3.9", "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11"] #, "3.12"] # TODO: add 3.12 by fixing https://github.com/Deltares/hydromt_delft3dfm/issues/136
os: ["windows-latest"]

name: ${{ matrix.os }} - py${{ matrix.python-version }}
Expand All @@ -29,7 +29,7 @@ jobs:

steps:
- uses: actions/checkout@v3
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
miniforge-variant: Mambaforge
Expand Down
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Changed
Fixed
-----
- Bugfixing of reading of frictions (global), crosssections and boundaries when update. (PR #81)
- Fixing bug related to changes to pandas TimeDelta formatting, see also https://pandas.pydata.org/docs/whatsnew/v2.2.0.html#other-deprecations. (PR #129)

v0.2.0 (20 November 2023)
=========================
Expand Down
14 changes: 7 additions & 7 deletions envs/hydromt-delft3dfm-min.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ channels:

dependencies:
- flit>=3.4
- geopandas
- hydromt>= 0.9.0
- geopandas<1
- hydromt==0.10.0
- numpy
- pandas
- pandas>=2.0.0
- pip
- pyflwdir >=0.5.4
- pyproj
- python=3.9.*
- python>=3.9
- scipy
- shapely>=2.0.0
- xarray
- xugrid>=0.9.0
- networkx
- llvmlite>=0.39.1 # hydrolib-core
- pip:
- hydrolib-core>=0.6.0
- xugrid>=0.7.1
- meshkernel>=3.0.0
- hydrolib-core>=0.6.1,<0.8
- meshkernel>=4.3.0
12 changes: 7 additions & 5 deletions envs/hydromt-delft3dfm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ dependencies:
- black # linting
- cartopy # to run examples
- flit>=3.4
- geopandas<1
- jupyter # to run examples
- matplotlib # to run examples
- hydromt>= 0.9.0
- hydromt>=0.10.0,<1 # To avoid getting v1 alpha
- nbsphinx # docs notebook examples
- numpy
- pandas
- pandas>=2.0.0
- pip
- pre-commit # linting
- pydata-sphinx-theme # docs
Expand All @@ -23,15 +24,16 @@ dependencies:
- pytest-cov # tests
- pytest-mock # tests
- pytest-timeout # test
- python>=3.9
- responses # tests
- ruff # linting
- shapely>=2.0.0
- sphinx # docs
- sphinx-design # docs
- xarray
- xugrid>=0.9.0
- networkx
- llvmlite>=0.39.1 # hydrolib-core
- pip:
- hydrolib-core>=0.6.0
- xugrid>=0.7.1
- meshkernel>=3.0.0
- hydrolib-core>=0.6.1,<0.8
- meshkernel>=4.3.0
13 changes: 9 additions & 4 deletions hydromt_delft3dfm/workflows/boundaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

logger = logging.getLogger(__name__)


__all__ = [
"get_boundaries_with_nodeid",
"select_boundary_type",
Expand All @@ -26,6 +25,15 @@
"get_geometry_coords_for_polygons",
]

_TIMESTR = {
"D": "days",
"h": "hours",
"min": "minutes",
"s": "seconds",
"H": "hours", # support for pandas<2.2.0
"S": "seconds", # support for pandas<2.2.0
}


def get_boundaries_with_nodeid(
branches: gpd.GeoDataFrame, network1d_nodes: gpd.GeoDataFrame
Expand Down Expand Up @@ -319,7 +327,6 @@ def compute_2dboundary_values(
else:
# prepare boundary data
# get data freq in seconds
_TIMESTR = {"D": "days", "H": "hours", "T": "minutes", "S": "seconds"}
dt = df_bnd.time[1] - df_bnd.time[0]
freq = dt.resolution_string
multiplier = 1
Expand Down Expand Up @@ -508,7 +515,6 @@ def compute_meteo_forcings(

logger.info("Preparing global (spatially uniform) timeseries.")
# get data freq in seconds
_TIMESTR = {"D": "days", "H": "hours", "T": "minutes", "S": "seconds"}
dt = df_meteo.time[1] - df_meteo.time[0]
freq = dt.resolution_string
multiplier = 1
Expand Down Expand Up @@ -559,7 +565,6 @@ def compute_meteo_forcings(

def _standardize_forcing_timeindexes(da):
"""Standardize timeindexes frequency based on forcing DataArray."""
_TIMESTR = {"D": "days", "H": "hours", "T": "minutes", "S": "seconds"}
dt = pd.to_timedelta((da.time[1].values - da.time[0].values))
freq = dt.resolution_string
multiplier = 1
Expand Down
8 changes: 5 additions & 3 deletions hydromt_delft3dfm/workflows/branches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1187,9 +1187,11 @@ def snap_newbranches_to_branches_at_snappednodes(
new_branch = new_branches.loc[snapnode.branchid]
snapped_line = LineString(
[
snapnode.geometry_right
if Point(xy).equals(snapnode.geometry_left)
else Point(xy)
(
snapnode.geometry_right
if Point(xy).equals(snapnode.geometry_left)
else Point(xy)
)
for xy in new_branch.geometry.coords[:]
]
)
Expand Down
18 changes: 10 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,19 @@ authors = [
{ name = "Jelmer Veenstra", email = "[email protected]" },
]
dependencies = [
"hydromt >=0.9.0",
"geopandas >=0.10",
"hydromt>=0.10.0, <1", # TODO: move to hydromt>=1: https://github.com/Deltares/hydromt_delft3dfm/issues/137
"geopandas>=0.10, <1", # TODO: remove upper bound: https://github.com/Deltares/hydromt_delft3dfm/issues/135
"numpy",
"pandas",
"pandas>=2.0.0",
"xarray",
"hydrolib-core >=0.6.0",
"xugrid >=0.7.1",
"meshkernel >= 3.0.0",
"hydrolib-core>=0.6.1, <0.8",
"xugrid>=0.9.0",
"meshkernel>=4.3.0",
"pyproj",
"shapely >=2.0.0",
"shapely>=2.0.0",
"scipy",
"pyflwdir >=0.5.4",
"universal_pathlib>=0.2", # provides path compatibility between different filesystems
"pyflwdir>=0.5.4",
"networkx",
]
requires-python = ">=3.9"
Expand All @@ -38,6 +39,7 @@ classifiers = [
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ['version', 'description']

Expand Down
2 changes: 1 addition & 1 deletion tests/test_hydromt.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def test_model_build(tmpdir, model):
mod0 = _model["model"](root=root, mode="r")
mod0.read()
# check if equal
equal, errors = mod0._test_equal(mod1)
equal, errors = mod0._test_equal(mod1, skip_component=["geoms"])
# skip config.filepath (root is different)
if "config.filepath" in errors:
errors.pop("config.filepath", None)
Expand Down

0 comments on commit 73b79bf

Please sign in to comment.