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
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/igorshubovych/markdownlint-cli
rev: 76b3d32d3f4b965e1d6425253c59407420ae2c43 # frozen: v0.47.0
rev: cbcdc463be5464e25e3e955a511599a67b9b987f # frozen: v0.50.0
hooks:
- id: markdownlint
args: ["--fix"]
Expand All @@ -79,7 +79,7 @@ repos:
# "off"); execution_count is not needed for that and is just as volatile
# as the timing metadata, so it's left to the default (stripped) behavior.
- repo: https://github.com/kynan/nbstripout
rev: 34071b78c181af3bf5af955c1426466e096fc3db # frozen: 0.9.1
rev: f5da19ce3b7b40e97c12ee9cd8ce97f48f97ddf7 # frozen: 0.9.1
hooks:
- id: nbstripout
args: ["--keep-output"]
Expand All @@ -97,13 +97,13 @@ repos:
args: ["--ignore=E006,E011"]

- repo: https://github.com/shellcheck-py/shellcheck-py
rev: 745eface02aef23e168a8afb6b5737818efbea95 # frozen: v0.11.0.1
rev: a6564f5d57444e123433a5c9af733e3975c77229 # frozen: v0.11.0.1-1
hooks:
- id: shellcheck
args: ["-x"] # Check external files

- repo: https://github.com/Mateusz-Grzelinski/actionlint-py
rev: 85c37735ea69e5baf0681530e57e63deee0ce733 # frozen: v1.7.10.24
rev: 357f7eec6dec49bf7693dc0dbec30212226d5492 # frozen: v1.7.12.25
hooks:
- id: actionlint

Expand All @@ -119,14 +119,14 @@ repos:
]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 9b1e9a33f1b33f6ecc2fdbb8d7cc894e951106e4 # frozen: v0.14.13
rev: 25bcf95026b96e2dd3c0aec3090c3d6ef6ca2e6c # frozen: v0.17.3
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix, --config=pyproject.toml]
- id: ruff-format

- repo: https://github.com/abravalheri/validate-pyproject
rev: 78f5e0f104cfa803d0597eaa924b4de3becd3e3e # frozen: v0.24.1
rev: 82d21874c3242e4dc27bb47641c996902ef64eef # frozen: v0.27
hooks:
- id: validate-pyproject
# Optional extra validations from SchemaStore:
Expand Down Expand Up @@ -165,7 +165,7 @@ repos:
entry: bash -c 'if [ ! -d .mypy_cache ]; then /bin/mkdir .mypy_cache; fi; exit 0'

- repo: https://github.com/pre-commit/mirrors-mypy
rev: "a66e98df7b4aeeb3724184b332785976d062b92e" # frozen: v1.19.1
rev: "ad26ebfa797fcb9b8f83275937c1c1d6e126719c" # frozen: v2.4.1
hooks:
- id: mypy
verbose: true
Expand Down
4 changes: 2 additions & 2 deletions docs/getting_started/asset_level_impacts.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
" key = i[\"key\"]\n",
" asset0_impact_dict[Key(key[\"hazard_type\"], key[\"scenario_id\"], key[\"year\"])] = i\n",
"\n",
"hazard_types = set(k.hazard_type for k in asset0_impact_dict.keys())\n",
"hazard_types = set(k.hazard_type for k in asset0_impact_dict)\n",
"wind_impact_histo = asset0_impact_dict[Key(\"Wind\", \"historical\", \"None\")]\n",
"wind_impact_ssp585 = asset0_impact_dict[Key(\"Wind\", \"ssp585\", \"2050\")]"
]
Expand All @@ -132,8 +132,8 @@
}
],
"source": [
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"exceedance_histo = wind_impact_histo[\"impact_exceedance\"]\n",
"exceedance_ssp585 = wind_impact_ssp585[\"impact_exceedance\"]\n",
Expand Down
10 changes: 6 additions & 4 deletions docs/getting_started/cement_plants_example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
"metadata": {},
"outputs": [],
"source": [
"from IPython.display import display\n",
"import json\n",
"from typing import NamedTuple\n",
"\n",
"import plotly.io\n",
"from dependency_injector import providers\n",
"from IPython.display import display\n",
"\n",
"from physrisk.container import Container\n",
"from physrisk.vulnerability_models.vulnerability import VulnerabilityModelsFactory\n",
"from physrisk.vulnerability_models.config_based_impact_curves import (\n",
" config_items_from_csv,\n",
" config_items_to_df,\n",
")\n",
"import plotly.io\n",
"from physrisk.vulnerability_models.vulnerability import VulnerabilityModelsFactory\n",
"\n",
"plotly.io.renderers.default = \"notebook\""
]
Expand Down Expand Up @@ -374,7 +376,7 @@
" key = i[\"key\"]\n",
" asset_impact_dict[Key(key[\"hazard_type\"], key[\"scenario_id\"], key[\"year\"])] = i\n",
"\n",
"hazard_types = sorted(set(k.hazard_type for k in asset_impact_dict.keys()))\n",
"hazard_types = sorted(set(k.hazard_type for k in asset_impact_dict))\n",
"\n",
"for hazard_type in hazard_types:\n",
" impact_histo = asset_impact_dict[Key(hazard_type, \"historical\", \"None\")]\n",
Expand Down
12 changes: 7 additions & 5 deletions docs/getting_started/custom_vulnerability.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,21 @@
"metadata": {},
"outputs": [],
"source": [
"from io import StringIO\n",
"import json\n",
"from io import StringIO\n",
"from typing import NamedTuple\n",
"\n",
"import plotly.io\n",
"from dependency_injector import providers\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.container import Container\n",
"from physrisk.vulnerability_models.vulnerability import VulnerabilityModelsFactory\n",
"from physrisk.vulnerability_models.config_based_impact_curves import (\n",
" VulnerabilityConfigItem,\n",
" config_items_from_csv,\n",
" config_items_to_df,\n",
")\n",
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from physrisk.vulnerability_models.vulnerability import VulnerabilityModelsFactory\n",
"\n",
"plotly.io.renderers.default = \"notebook\""
]
Expand Down Expand Up @@ -212,7 +214,7 @@
" key = i[\"key\"]\n",
" asset0_impact_dict[Key(key[\"hazard_type\"], key[\"scenario_id\"], key[\"year\"])] = i\n",
"\n",
"hazard_types = set(k.hazard_type for k in asset0_impact_dict.keys())\n",
"hazard_types = set(k.hazard_type for k in asset0_impact_dict)\n",
"wind_impact_histo = asset0_impact_dict[Key(\"Wind\", \"historical\", \"None\")]\n",
"wind_impact_ssp585 = asset0_impact_dict[Key(\"Wind\", \"ssp585\", \"2050\")]\n",
"\n",
Expand Down
2 changes: 1 addition & 1 deletion docs/getting_started/hazard_indicators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -202,8 +202,8 @@
}
],
"source": [
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"fig1 = make_subplots(rows=1, cols=2)\n",
"fig1.add_scatter(\n",
Expand Down
1 change: 1 addition & 0 deletions docs/getting_started/hazard_inventory.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"outputs": [],
"source": [
"import pprint as pp\n",
"\n",
"import pandas as pd\n",
"import requests\n",
"from IPython.display import Markdown, display"
Expand Down
8 changes: 5 additions & 3 deletions docs/user_guide/vulnerability/vulnerability_config.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,15 @@
"source": [
"# pip install nbformat pandas plotly requests\n",
"from io import StringIO\n",
"\n",
"import plotly.io\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.vulnerability_models.config_based_impact_curves import (\n",
" config_items_from_csv,\n",
" config_items_to_df,\n",
")\n",
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"\n",
"plotly.io.renderers.default = \"notebook\""
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@
"outputs": [],
"source": [
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.vulnerability_models.configuration.hazus_config_builders import (\n",
" ConfigBuilderHazusFlood,\n",
")\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@
"outputs": [],
"source": [
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.vulnerability_models.configuration.config_builders import (\n",
" ConfigBuilderJRCFlood,\n",
")\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"outputs": [],
"source": [
"import json\n",
"\n",
"import pandas\n",
"\n",
"data = {\"items\": []}\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@
"outputs": [],
"source": [
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.vulnerability_models.configuration.config_builders import (\n",
" ConfigBuilderEberenzWind,\n",
")\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@
"source": [
"import numpy as np\n",
"import plotly.io\n",
"from plotly.subplots import make_subplots\n",
"from IPython.display import HTML\n",
"from plotly.subplots import make_subplots\n",
"\n",
"from physrisk.vulnerability_models.configuration.hazus_config_builders import (\n",
" ConfigBuilderHazusWind,\n",
")\n",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from physrisk.vulnerability_models.config_cdf_based_vuln_function import (\n",
" CDFBasedVulnerabilityFunction,\n",
")\n",
Expand Down
5 changes: 3 additions & 2 deletions methodology/plots/interp_pixel_is_area.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
"source": [
"import os\n",
"import sys\n",
"from affine import Affine\n",
"\n",
"import s3fs\n",
"import hazard.utilities.zarr_utilities as zarr_utilities\n",
"from affine import Affine\n",
"from hazard.sources.osc_zarr import OscZarr\n",
"from hazard.utilities import zarr_utilities\n",
"\n",
"sys.path.append(\"../src\")\n",
"\n",
Expand Down
8 changes: 4 additions & 4 deletions src/physrisk/api/v1/availability_sources.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from typing import Dict, List
from pydantic import BaseModel, Field

from physrisk.api.v1.hazard_data import ScenarioYears


Expand All @@ -16,13 +16,13 @@ class AvailabilitySourcesRequest(BaseModel):


class HazardTypeAvailability(BaseModel):
scenarios: List[ScenarioYears] = []
available_for_assets_type: List[str] = []
scenarios: list[ScenarioYears] = []
available_for_assets_type: list[str] = []
indicator_display_name: str = ""


class AvailabilitySourcesResponse(BaseModel):
hazards: Dict[str, Dict[str, HazardTypeAvailability]] = Field(
hazards: dict[str, dict[str, HazardTypeAvailability]] = Field(
{},
description="Information of available sources for the hazards in the inventory",
)
Expand Down
Loading
Loading