Skip to content

Commit

Permalink
Merge pull request #303 from Deltares/chore/75-standardize-module-names
Browse files Browse the repository at this point in the history
chore: #75 standardize module names
  • Loading branch information
ArdtK authored Mar 6, 2024
2 parents 65dfd37 + df71169 commit 51dc7fe
Show file tree
Hide file tree
Showing 163 changed files with 370 additions and 336 deletions.
6 changes: 0 additions & 6 deletions ra2ce/analyses/direct/damage_calculation/__init__.py

This file was deleted.

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


from __future__ import annotations

import math
from dataclasses import dataclass, field
from pathlib import Path
from typing import Optional

from ra2ce.analyses.analysis_config_data.enums.analysis_direct_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_direct_enum import (
AnalysisDirectEnum,
)
from ra2ce.analyses.analysis_config_data.enums.analysis_indirect_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_indirect_enum import (
AnalysisIndirectEnum,
)
from ra2ce.analyses.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.analysis.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.common.configuration.config_data_protocol import ConfigDataProtocol
from ra2ce.graph.network_config_data.enums.aggregate_wl_enum import AggregateWlEnum
from ra2ce.graph.network_config_data.network_config_data import (
from ra2ce.network.network_config_data.enums.aggregate_wl_enum import AggregateWlEnum
from ra2ce.network.network_config_data.network_config_data import (
NetworkSection,
OriginsDestinationsSection,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
from configparser import ConfigParser
from pathlib import Path
from shutil import copyfile

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionBase,
AnalysisSectionDirect,
Expand All @@ -34,13 +33,13 @@
IndirectAnalysisNameList,
ProjectSection,
)
from ra2ce.analyses.analysis_config_data.enums.analysis_direct_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_direct_enum import (
AnalysisDirectEnum,
)
from ra2ce.analyses.analysis_config_data.enums.analysis_indirect_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_indirect_enum import (
AnalysisIndirectEnum,
)
from ra2ce.analyses.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.analysis.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.common.configuration.ini_configuration_reader_protocol import (
ConfigDataReaderProtocol,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,17 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


from typing import Any

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
DirectAnalysisNameList,
IndirectAnalysisNameList,
)
from ra2ce.common.validation.ra2ce_validator_protocol import Ra2ceIoValidator
from ra2ce.common.validation.validation_report import ValidationReport
from ra2ce.configuration.ra2ce_enum_base import Ra2ceEnumBase
from ra2ce.graph.network_config_data.network_config_data_validator import (
from ra2ce.network.network_config_data.network_config_data_validator import (
NetworkDictValues,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

from pathlib import Path

from ra2ce.analyses.analysis_config_data.analysis_config_data import AnalysisConfigData
from ra2ce.analyses.analysis_config_data.analysis_config_data_validator import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import AnalysisConfigData
from ra2ce.analysis.analysis_config_data.analysis_config_data_validator import (
AnalysisConfigDataValidator,
)
from ra2ce.common.configuration.config_wrapper_protocol import ConfigWrapperProtocol
from ra2ce.graph.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.graph.network_config_wrapper import NetworkConfigWrapper
from ra2ce.network.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.network.network_config_wrapper import NetworkConfigWrapper


class AnalysisConfigWrapper(ConfigWrapperProtocol):
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,27 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
import time
from pathlib import Path
from typing import Any

import geopandas as gpd

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionDirect,
)
from ra2ce.analyses.analysis_config_data.enums.analysis_direct_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_direct_enum import (
AnalysisDirectEnum,
)
from ra2ce.analyses.direct.cost_benefit_analysis import EffectivenessMeasures
from ra2ce.analyses.direct.damage.manual_damage_functions import ManualDamageFunctions
from ra2ce.analyses.direct.damage_calculation import (
from ra2ce.analysis.direct.cost_benefit_analysis import EffectivenessMeasures
from ra2ce.analysis.direct.damage.manual_damage_functions import ManualDamageFunctions
from ra2ce.analysis.direct.damage_calculation import (
DamageNetworkEvents,
DamageNetworkReturnPeriods,
)
from ra2ce.graph.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.network.graph_files.graph_files_collection import GraphFilesCollection


class DirectAnalyses: ### THIS SHOULD ONLY DO COORDINATION
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
import os
from pathlib import Path
Expand All @@ -28,7 +27,7 @@
import numpy as np
import pandas as pd

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionDirect,
)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,13 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
from pathlib import Path

import pandas as pd

from ra2ce.analyses.direct.damage.damage_fraction_uniform import DamageFractionUniform
from ra2ce.analyses.direct.damage.max_damage import MaxDamageByRoadTypeByLane
from ra2ce.analysis.direct.damage.damage_fraction_uniform import DamageFractionUniform
from ra2ce.analysis.direct.damage.max_damage import MaxDamageByRoadTypeByLane


class DamageFunctionByRoadTypeByLane:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
from pathlib import Path

from ra2ce.analyses.direct.damage.damage_function_road_type_lane import (
from ra2ce.analysis.direct.damage.damage_function_road_type_lane import (
DamageFunctionByRoadTypeByLane,
)

Expand Down
File renamed without changes.
6 changes: 6 additions & 0 deletions ra2ce/analysis/direct/damage_calculation/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from ra2ce.analysis.direct.damage_calculation.damage_network_events import (
DamageNetworkEvents,
)
from ra2ce.analysis.direct.damage_calculation.damage_network_return_periods import (
DamageNetworkReturnPeriods,
)
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging
from abc import ABC, abstractmethod

import numpy as np
import pandas as pd

from ra2ce.analyses.direct.direct_lookup import LookUp as lookup
from ra2ce.analyses.direct.direct_lookup import dataframe_lookup
from ra2ce.analyses.direct.direct_utils import (
from ra2ce.analysis.direct.direct_lookup import LookUp as lookup
from ra2ce.analysis.direct.direct_lookup import dataframe_lookup
from ra2ce.analysis.direct.direct_utils import (
clean_lane_data,
create_summary_statistics,
scale_damage_using_lanes,
Expand Down Expand Up @@ -230,7 +229,11 @@ def calculate_damage_HZ(self, events):

df = self._gdf_mask
df["lanes"] = df["lanes"].astype(int)
df["max_dam_hz"] = df.apply(dataframe_lookup, args=(df_max_damages_huizinga, ['lanes', 'road_type']), axis=1)
df["max_dam_hz"] = df.apply(
dataframe_lookup,
args=(df_max_damages_huizinga, ["lanes", "road_type"]),
axis=1,
)

for event in events:
df["dam_{}_{}".format(event, curve_name)] = round(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


from __future__ import annotations

from pathlib import Path

from ra2ce.analyses.direct.damage_calculation.damage_network_base import (
from ra2ce.analysis.direct.damage_calculation.damage_network_base import (
DamageNetworkBase,
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging

import numpy as np
import pandas as pd

from ra2ce.analyses.direct.damage_calculation.damage_network_base import (
from ra2ce.analysis.direct.damage_calculation.damage_network_base import (
DamageNetworkBase,
)

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


import logging

from ra2ce.analyses.analysis_config_data.analysis_config_data import AnalysisConfigData
from ra2ce.analysis.analysis_config_data.analysis_config_data import AnalysisConfigData


class DirectAnalyses:
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@
from shapely.geometry import LineString, MultiLineString
from tqdm import tqdm

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionIndirect,
)
from ra2ce.analyses.analysis_config_data.enums.analysis_indirect_enum import (
from ra2ce.analysis.analysis_config_data.enums.analysis_indirect_enum import (
AnalysisIndirectEnum,
)
from ra2ce.analyses.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.analyses.indirect.losses import Losses
from ra2ce.analyses.indirect.origin_closest_destination import OriginClosestDestination
from ra2ce.analyses.indirect.traffic_analysis.traffic_analysis_factory import (
from ra2ce.analysis.analysis_config_data.enums.weighing_enum import WeighingEnum
from ra2ce.analysis.indirect.losses import Losses
from ra2ce.analysis.indirect.origin_closest_destination import OriginClosestDestination
from ra2ce.analysis.indirect.traffic_analysis.traffic_analysis_factory import (
TrafficAnalysisFactory,
)
from ra2ce.graph.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.graph.networks_utils import buffer_geometry, graph_to_gdf, graph_to_gpkg
from ra2ce.network.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.network.networks_utils import buffer_geometry, graph_to_gdf, graph_to_gpkg


class IndirectAnalyses:
Expand Down Expand Up @@ -1229,10 +1229,10 @@ def _save_gpkg_analysis(
opt_routes_with_hazard,
) = analyzer.multi_link_origin_closest_destination()

(
opt_routes_with_hazard
) = analyzer.difference_length_with_without_hazard(
opt_routes_with_hazard, opt_routes_without_hazard
(opt_routes_with_hazard) = (
analyzer.difference_length_with_without_hazard(
opt_routes_with_hazard, opt_routes_without_hazard
)
)

else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


from pathlib import Path

import numpy as np
import pandas as pd

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionIndirect,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
"""


# -*- coding: utf-8 -*-
import copy
import logging
Expand All @@ -31,11 +30,11 @@
from shapely.geometry import LineString, MultiLineString
from tqdm import tqdm

from ra2ce.analyses.analysis_config_data.analysis_config_data import (
from ra2ce.analysis.analysis_config_data.analysis_config_data import (
AnalysisConfigData,
AnalysisSectionIndirect,
)
from ra2ce.graph.graph_files.graph_files_collection import GraphFilesCollection
from ra2ce.network.graph_files.graph_files_collection import GraphFilesCollection


class OriginClosestDestination:
Expand Down Expand Up @@ -435,16 +434,19 @@ def get_nr_without_access(
]

pp_no_access = [
round(
(
origins.loc[
origins[self.od_id].isin(origins_no_access), self.origin_count
]
* self.origin_out_fraction
).sum()
(
round(
(
origins.loc[
origins[self.od_id].isin(origins_no_access),
self.origin_count,
]
* self.origin_out_fraction
).sum()
)
if len(origins_no_access) > 0
else 0
)
if len(origins_no_access) > 0
else 0
]

self.results_dict[f"Nr. no access{add_key_name}"] = pp_no_access
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
import numpy as np
import pandas as pd

from ra2ce.analyses.indirect.traffic_analysis.accumulated_traffic_dataclass import (
from ra2ce.analysis.indirect.traffic_analysis.accumulated_traffic_dataclass import (
AccumulatedTraffic,
)
from ra2ce.analyses.indirect.traffic_analysis.traffic_analysis_base import (
from ra2ce.analysis.indirect.traffic_analysis.traffic_analysis_base import (
TrafficAnalysisBase,
)

Expand Down
Loading

0 comments on commit 51dc7fe

Please sign in to comment.