Skip to content

Commit

Permalink
Merge pull request #38 from zsarnoczay/master
Browse files Browse the repository at this point in the history
updates to enable water pipeline damage modeling and other minor enhancements
  • Loading branch information
zsarnoczay authored Mar 28, 2024
2 parents b4b807b + bee2e79 commit 9b518e4
Show file tree
Hide file tree
Showing 27 changed files with 8,256 additions and 6,660 deletions.
3 changes: 0 additions & 3 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[run]
omit =
db.py
auto.py
*/tests/*
[report]
exclude_lines =
def get_required_resources
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[flake8]
max-line-length = 85
ignore = E203, E241, E701, W503
exclude = db.py,auto.py,flycheck*,Hazus_Earthquake_IM.py,Hazus_Earthquake_Story.py,export_DB.py
exclude = flycheck*
16 changes: 13 additions & 3 deletions .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ init-hook='import sys; sys.path.append("."); sys.path.append("../"); sys.path.ap

# Files or directories to be skipped. They should be base names, not
# paths.
ignore=auto.py,db.py,flycheck_*.py
ignore=flycheck_*

# Add files or directories matching the regex patterns to the ignore-list. The
# regex matches against paths and can be in Posix or Windows format.
Expand Down Expand Up @@ -143,7 +143,7 @@ logging-format-style=old
[MISCELLANEOUS]

# List of note tags to take in consideration, separated by a comma.
notes=FIXME,XXX,TODO
notes=FIXME,XXX,TODO,todo,debug

# Regular expression of note tags to take in consideration.
#notes-rgx=
Expand All @@ -152,7 +152,7 @@ notes=FIXME,XXX,TODO
[SIMILARITIES]

# Minimum lines number of a similarity.
min-similarity-lines=6
min-similarity-lines=8

# Ignore comments when computing similarities.
ignore-comments=yes
Expand Down Expand Up @@ -335,6 +335,16 @@ docstring-min-length=-1
# List of decorators that define properties, such as abc.abstractproperty.
property-classes=abc.abstractproperty

#
# Docstring parameter documentation:
# https://pylint.pycqa.org/en/1.7/technical_reference/extensions.html
#

accept-no-raise-doc = no
accept-no-param-doc = no
accept-no-return-doc = no
accept-no-yields-doc = no


[TYPECHECK]

Expand Down
14 changes: 7 additions & 7 deletions pelicun/assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ class Assessment:
...
damage: DamageModel
...
bldg_repair: BldgRepairModel
repair: RepairModel
...
stories: int
Number of stories.
Expand Down Expand Up @@ -146,18 +146,18 @@ def damage(self):
return self.damage

@property
def bldg_repair(self):
def repair(self):
"""
Return an BldgRepairModel object that manages the repair information.
Return a RepairModel object that manages the repair information.
"""
# pylint: disable = access-member-before-definition

if hasattr(self, '_bldg_repair'):
return self._bldg_repair
if hasattr(self, '_repair'):
return self._repair

self._bldg_repair = model.BldgRepairModel(self)
return self.bldg_repair
self._repair = model.RepairModel(self)
return self.repair

def get_default_data(self, data_name):
"""
Expand Down
28 changes: 16 additions & 12 deletions pelicun/auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,41 +50,46 @@

import sys
import importlib
import json
from pathlib import Path

from . import base

def auto_populate(config, auto_script_path, **kwargs):

def auto_populate(
config, auto_script_path, **kwargs # pylint: disable=unused-argument
):
"""
Automatically prepares the DL configuration for a Pelicun calculation.
Automatically populates the DL configuration for a Pelicun
calculation.
Parameters
----------
config: dict
Configuration dictionary with a GeneralInformation key that holds
another dictionary with attributes of the asset of interest.
Configuration dictionary with a GeneralInformation key that
holds another dictionary with attributes of the asset of
interest.
auto_script_path: string
Path pointing to a python script with the auto-population rules.
Built-in scripts can be referenced using the PelicunDefault/XY format
where XY is the name of the script.
Path pointing to a python script with the auto-population
rules. Built-in scripts can be referenced using the
PelicunDefault/XY format where XY is the name of the script.
"""

# try to get the AIM attributes
AIM = config.get('GeneralInformation', None)
if AIM == None:
if AIM is None:
raise ValueError(
"No Asset Information provided for the auto-population routine."
)

# replace default keyword with actual path in auto_script location
if 'PelicunDefault/' in auto_script_path:
auto_script_path = auto_script_path.replace(
'PelicunDefault/', f'{base.pelicun_path}/resources/auto/')
'PelicunDefault/', f'{base.pelicun_path}/resources/auto/'
)

# load the auto population module
ASP = Path(auto_script_path).resolve()
sys.path.insert(0, str(ASP.parent)+'/')
sys.path.insert(0, str(ASP.parent) + '/')
auto_script = importlib.__import__(ASP.name[:-3], globals(), locals(), [], 0)
auto_populate_ext = auto_script.auto_populate

Expand All @@ -97,4 +102,3 @@ def auto_populate(config, auto_script_path, **kwargs):

# return the extended config data and the component quantities
return config, CMP

Loading

0 comments on commit 9b518e4

Please sign in to comment.