Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 46 additions & 4 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ jobs:
shell: bash -e -l {0}
runs-on: ${{ inputs.os }}
timeout-minutes: 30
env:
PIXI_ENV: test-py${{ inputs.python-version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand All @@ -21,7 +23,7 @@ jobs:
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004
with:
pixi-version: "v0.65.0"
environments: test-py${{ inputs.python-version }}
environments: ${{ env.PIXI_ENV }}
locked: false
cache: true
cache-write: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
Expand All @@ -35,7 +37,7 @@ jobs:

- name: Test
run: |
pixi run -e test-py${{ inputs.python-version }} test-cov
pixi run -e ${{ env.PIXI_ENV }} test-cov

- name: Upload coverage
if: inputs.os == 'ubuntu-latest' && inputs.python-version == '314'
Expand Down Expand Up @@ -67,6 +69,8 @@ jobs:
runs-on: ${{ inputs.os }}
needs: unit
timeout-minutes: 30
env:
PIXI_ENV: test-py${{ inputs.python-version }}
steps:
- name: Checkout code
uses: actions/checkout@v6
Expand All @@ -75,7 +79,7 @@ jobs:
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004
with:
pixi-version: "v0.65.0"
environments: test-py${{ inputs.python-version }}
environments: ${{ env.PIXI_ENV }}
locked: false
cache: true
cache-write: false
Expand All @@ -89,4 +93,42 @@ jobs:

- name: Test
run: |
pixi run -e test-py${{ inputs.python-version }} test-integration
pixi run -e ${{ env.PIXI_ENV }} test-integration

system:
defaults:
run:
shell: bash -e -l {0}
runs-on: ${{ inputs.os }}
needs: integration
strategy:
fail-fast: false
matrix:
fiat-install: ["stable", "dev"]
name: "system (${{ matrix.fiat-install }})"
timeout-minutes: 30
env:
PIXI_ENV: test-py${{ inputs.python-version }}${{ matrix.fiat-install == 'dev' && '-dev' || '' }}
steps:
- name: Checkout code
uses: actions/checkout@v6

- name: Setup pixi env
uses: prefix-dev/setup-pixi@28eb668aafebd9dede9d97c4ba1cd9989a4d0004
with:
pixi-version: "v0.65.0"
environments: ${{ env.PIXI_ENV }}
locked: false
cache: true
cache-write: false

- name: Download cache
uses: actions/cache/restore@v5
with:
path: .cache
key: test-data
enableCrossOsArchive: true

- name: Test
run: |
pixi run -e ${{ env.PIXI_ENV }} test-system
27,719 changes: 16,033 additions & 11,686 deletions pixi.lock

Large diffs are not rendered by default.

25 changes: 17 additions & 8 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,13 @@ pandoc = "*"
[tool.pixi.feature.test.dependencies]
gdal = ">=3.9.1"

[tool.pixi.feature.test.pypi-dependencies]
delft_fiat = "*"
[tool.pixi.feature.delft-fiat-stable]
dependencies = {libgdal-core = ">=3.5", libgdal-arrow-parquet = "*", libgdal-netcdf = "*"}
pypi-dependencies = {delft_fiat = "*"}

[tool.pixi.feature.delft-fiat-dev]
dependencies = {libgdal-core = ">=3.5", libgdal-arrow-parquet = "*", libgdal-netcdf = "*"}
pypi-dependencies = {delft_fiat = { git = "https://github.com/Deltares/DELFT-fiat.git", branch = "v1" }}

[tool.pixi.feature.wheel.dependencies]
pip = "*"
Expand All @@ -324,11 +329,15 @@ python = "3.11.*"

## Define the environments
[tool.pixi.environments]
default = { features = ["py314", "dev", "docs", "examples", "test"] }
default = { features = ["py314", "dev", "docs", "examples", "test", "delft-fiat-stable"] }
docs = { features = ["py313", "docs", "examples"] }
slim = { features = [] }
test-py314 = { features = ["py314", "test"] }
test-py313 = { features = ["py313", "test"] }
test-py312 = { features = ["py312", "test"] }
test-py311 = { features = ["py311", "test"] }
wheel = { features = ["py313", "test", "wheel"], no-default-feature=true }
test-py314 = { features = ["py314", "test", "delft-fiat-stable"] }
test-py313 = { features = ["py313", "test", "delft-fiat-stable"] }
test-py312 = { features = ["py312", "test", "delft-fiat-stable"] }
test-py311 = { features = ["py311", "test", "delft-fiat-stable"] }
test-py314-dev = { features = ["py314", "test", "delft-fiat-dev"] }
test-py313-dev = { features = ["py313", "test", "delft-fiat-dev"] }
test-py312-dev = { features = ["py312", "test", "delft-fiat-dev"] }
test-py311-dev = { features = ["py311", "test", "delft-fiat-dev"] }
wheel = { features = ["py313", "test", "delft-fiat-stable", "wheel"], no-default-feature=true }
4 changes: 2 additions & 2 deletions src/hydromt_fiat/components/vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ def setup(
vulnerability_linking_fname: Path | str | None = None,
*,
unit: str = "m",
index_name: str = "water depth",
index_name: str = "depth",
column_oriented: bool = True,
**select,
) -> None:
Expand All @@ -271,7 +271,7 @@ def setup(
unit : str, optional
The unit which the vulnerability index is in, by default "m".
index_name : str, optional
The output name of the index column, by default "water depth".
The output name of the index column, by default "depth".
column_oriented : bool, optional
Whether the vulnerability data is column oriented, i.e. the values of a
curve are in the same column spanning multiple rows. If False, the values
Expand Down
4 changes: 2 additions & 2 deletions src/hydromt_fiat/workflows/vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def vulnerability_setup(
vulnerability_linking: pd.DataFrame | None = None,
*,
unit: str = "m",
index_name: str = "water depth",
index_name: str = "depth",
column_oriented: bool = True,
**select,
) -> tuple[pd.DataFrame, pd.DataFrame]:
Expand All @@ -91,7 +91,7 @@ def vulnerability_setup(
The unit of the vulnerability dataset index, by default "m".
index_name : str, optional
The name of the outgoing vulnerability curves dataset index,
by default "water depth".
by default "depth".
column_oriented : bool, optional
Whether the vulnerability data is column oriented, i.e. the values of a curve
are in the same column spanning multiple rows. If False, the values are ought
Expand Down
18 changes: 11 additions & 7 deletions tests/system/test_system_geom.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,19 @@
from packaging.version import Version

from hydromt_fiat import FIATModel
from hydromt_fiat.utils import FLOOD_LEVEL, GEOM
from hydromt_fiat.utils import FLOOD_DEPTH, GEOM

try:
from fiat import Configurations, GeomModel, __version__

HAS_FIAT = True

except ImportError:
__version__ = "0.0.0"
HAS_FIAT = False


@pytest.mark.skipif(
not HAS_FIAT or Version(__version__) < Version("1"),
not HAS_FIAT or Version(__version__) < Version("1.0.0.dev0"),
reason="At least Delft-FIAT version 1.0.0 is required.",
)
@pytest.mark.system
Expand All @@ -36,7 +35,7 @@ def test_system_geom_model(
)

# Add model type and region
model.setup_config(model_type=GEOM, calculation_method=FLOOD_LEVEL)
model.setup_config(model_type=GEOM, calculation_method=FLOOD_DEPTH)
model.setup_region(build_region_small)

# Setup the vulnerability
Expand All @@ -50,6 +49,7 @@ def test_system_geom_model(
# Add an hazard layer
model.hazard.setup(
"flood_event",
hazard_type="water_depth",
)

# Setup the exposure geometry data
Expand All @@ -58,17 +58,21 @@ def test_system_geom_model(
exposure_object_type_column="gebruiksdoel",
exposure_link_fname="buildings_link",
)
model.exposure_geoms.setup_link_vulnerability(
exposure_name="buildings",
impact_type="damage",
)
model.exposure_geoms.setup_max_damage(
exposure_name="buildings",
exposure_type="damage",
impact_type="damage",
exposure_cost_table_fname="jrc_damage",
country="Netherlands", # Select the correct row from the data
)
# Needed for flood calculations
model.exposure_geoms.update_column(
exposure_name="buildings",
columns=["ref", "method"],
values=[0, "centroid"],
columns=["reference", "elevation", "method"],
values=[0, 0, "centroid"],
)

# Write the model
Expand Down
4 changes: 2 additions & 2 deletions tests/workflows/test_vulnerability.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def test_vulnerability_setup_units(
continent="europe",
curve=["residential", "commercial"],
)
mean_val = int(vuln_curves["water depth"].mean() * 100)
mean_val = int(vuln_curves["depth"].mean() * 100)
assert mean_val == 500

# Assert that different units work (in this case feet)
Expand All @@ -191,7 +191,7 @@ def test_vulnerability_setup_units(
continent="europe",
curve=["residential", "commercial"],
)
mean_val_ft = int(vuln_curves["water depth"].mean() * 100)
mean_val_ft = int(vuln_curves["depth"].mean() * 100)
assert mean_val > 3 * mean_val_ft
assert (
"Given unit (foot) does not match the standard unit (meter) for [length]"
Expand Down
Loading