Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updates to enable water pipeline damage modeling and other minor enhancements #38

Merged
merged 51 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
92e66ad
Split `model.py` into subcomponents.
ioannis-vm Mar 1, 2024
e211f2f
Code formatting
ioannis-vm Mar 1, 2024
a5e49b6
Abstract default path substitution
ioannis-vm Mar 1, 2024
1901098
Refactor random variable handling in pelicun
ioannis-vm Mar 2, 2024
2f6f7dd
Remove `bldg` term from repair models
ioannis-vm Mar 2, 2024
b66257a
Remove block weights
ioannis-vm Mar 2, 2024
1600b7c
Use `deepcopy` to avoid fixture mutation
ioannis-vm Mar 2, 2024
92bcadb
Improve `empirical_data` handling
ioannis-vm Mar 2, 2024
d62352d
Replace Scipy's `interp1d` with Numpy's `interp`
ioannis-vm Mar 3, 2024
22a9e1d
Consider `auto.py` when linting
ioannis-vm Mar 3, 2024
e51e8ac
Minor formatting
ioannis-vm Mar 3, 2024
dca077a
Add unit tests for `auto.py`
ioannis-vm Mar 3, 2024
5edf5ce
Remove block weights (2)
ioannis-vm Mar 6, 2024
fbe69c9
remove a simple named function
ioannis-vm Mar 6, 2024
2c7d3ca
Default `truncation_limits` for all RV objects
ioannis-vm Mar 9, 2024
0f740c2
Bump pandas version
ioannis-vm Mar 9, 2024
6aa7166
Give up checking index/column dtypes in tests
ioannis-vm Mar 9, 2024
fc17b87
Add a few more keywords
ioannis-vm Mar 9, 2024
5cf0ede
Explicit dtype assignment in test
ioannis-vm Mar 9, 2024
361096b
Explicit dtype assignment (2)
ioannis-vm Mar 9, 2024
3f94ac9
Explicit dtype assignment (3)
ioannis-vm Mar 9, 2024
fdb5eb2
Reformatting & Linting
ioannis-vm Mar 9, 2024
bd42efa
Reformating & Linting
ioannis-vm Mar 9, 2024
0e9fff8
Refactoring & Linting
ioannis-vm Mar 9, 2024
40fc5fc
Refactoring & Linting
ioannis-vm Mar 9, 2024
fbbdae6
Refactoring & Linting
ioannis-vm Mar 9, 2024
00815c5
Refactoring & Linting
ioannis-vm Mar 9, 2024
c061ac4
Refactoring & Linting
ioannis-vm Mar 9, 2024
8e48d0b
Change Error to Warning
ioannis-vm Mar 23, 2024
d130353
More strict `pylint` checks for docstrings
ioannis-vm Mar 23, 2024
608e251
Improve formatting
ioannis-vm Mar 23, 2024
622a1cd
Roll back certain `db.py` changes
ioannis-vm Mar 23, 2024
7dedb4f
Merge branch '2024-03-01_refactoring' into develop
ioannis-vm Mar 23, 2024
1243a74
manually merge `Hazus_Earthquake_IM.py`
ioannis-vm Mar 23, 2024
313af71
ignore flake8 warnings for specific lines
ioannis-vm Mar 23, 2024
1af9056
Add `super.()__init__()` calls in parent classes.
ioannis-vm Mar 23, 2024
15467d5
Simplify test
ioannis-vm Mar 24, 2024
d59f85e
Remove unnecessary pylint error suppression
ioannis-vm Mar 24, 2024
35f6145
Remove `bldg` term from variables
ioannis-vm Mar 24, 2024
b4e72ae
Remove unnecessary lines from test
ioannis-vm Mar 24, 2024
6f7e87c
Formatting changes
ioannis-vm Mar 24, 2024
3079ff1
manually merge `Hazus_Earthquake_IM.py` (2)
ioannis-vm Mar 24, 2024
2def079
`-LOC` damage process, refactor damage model
ioannis-vm Mar 25, 2024
9d5233b
Use `convert_units` for pipe segment calculation
ioannis-vm Mar 28, 2024
4bb6f5b
Update imports and formatting
ioannis-vm Mar 28, 2024
5a5fa07
Location matching
ioannis-vm Mar 28, 2024
22adc77
Don't add `collapse` column for water networks
ioannis-vm Mar 28, 2024
c1f3d3a
Improve formatting
ioannis-vm Mar 28, 2024
64ef134
Add support for more location matching cases
ioannis-vm Mar 28, 2024
6b1d6bc
Merge branch '2024-03-24_dmg_process_loc'
ioannis-vm Mar 28, 2024
bee2e79
Merge remote-tracking branch 'John/main'
zsarnoczay Mar 28, 2024
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
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
Loading