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

Conversation

zsarnoczay
Copy link
Collaborator

No description provided.

- This commit separates the objects defined in `model.py` and places
  them into dedicated files. We utilize `__init__.py` to maintain the
  same import syntax. `model.py` is removed.
- Tests and linting are passing.
- This commit may have interfered with the `autosummary` directive for
  the documentation, and we will revisit this later.
This commit only contains automated formatting changes (using
`black`).
Eliminates repetition in resolving `PelicunDefault/`
This commit breaks down the signle `RandomVariable` object into
individual dedicated random variable objects, utilizing class
inheritance. This reduces if/else logic and optional arguments, making
the code much easier to understand and work with.
It attempts to minimize the extent of changes outside of the UQ
module.

Key changes include:

- Introduction of a base `BaseRandomVariable` class and specialized RV
  classes for different distribution types (e.g.,
  `NormalRandomVariable`, `LogNormalRandomVariable`).
- Implementation of a `rv_class_map` function, allowing for the
  previously used distribution names to be mapped to the new objects.
- Modifications to the `RandomVariableSet` and
  `RandomVariableRegistry` classes to accommodate the new RV structure.
- Numerous updates to unit tests (`test_uq.py`) to reflect the changes
  in RV handling.
- A limited numer of code formatting changes to other areas of the
  affected files.

- [X] Linter checks and unit tests pass.
Improve `empirical_data` handling for saving/loading DemandModel
objects.
Using `interp` for these operations is more straightforward and
consistent with the rest of the linear interpolation operations in the
code base.
- [X] Linter checks pass
This commit adds a default `truncation_limits` argument to all RV
objects, even for those that don't support it yet. The default is
`nan` in both directions, and for the RVs that don't support
truncation, a `NotImplementedError` is raised if the attribute is set
to a different value while instantiating the object.  This helps
eliminate the if/else logic in the `model` module code, where we had
to check if the distribution family is one for which we support
truncation and not add that argument if it doesn't. Now we rely on the
users to avoid specifying truncation limits for families that don't
support it, or they will be getting the `NotImplementedError` at
runtime.
Pandas 2 is out.
https://pandas.pydata.org/docs/whatsnew/v2.0.0.html
Unit tests and additional trial runs pass with
Pandas 2 installed.  This commit raises the ceiling for the Pandas
version to eliminate environment dependency incompatibilities for the
users.
Windows sometimes uses different dtypes for ints there, but the values
are the same. Instead of explicitly checking the OS, it's simpler to
just not expect the dtypes to always match. The represented values
should still be equal.
Begin including `Hazus_Earthquake_IM.py`, `Hazus_Earthquake_Story.py`,
and `export_DB.py` in flake8 checks.
Getting ready to work on `db.py`
Reorder imports, silence `too-many...` warnings
Specify encoding
Remove `== True` after `pd.isna(...)`
Using `is` for `None` checks
- Code reformatting
- Remove unused `target_meta_file` from
  `create_Hazus_EQ_bldg_injury_db`
- Enables pylint warnings on docstring issues.
- Fixes the resulting warnings for `uq.py`.
ioannis-vm and others added 21 commits March 23, 2024 04:43
- Roll back formatting changes on DataFrame definition
Removes unnecessary code
This merge was a bit messy, but I'll be more careful during the next
one.

--John
- Implemented a -LOC keyword for location-specific damage processes.
- Redesigned damage evaluation to use a damage states when applying
  damage processes for more intuitive logic and to reduce if/else
  calls.
- Modified the unit tests to align with the new approach and extended
  them to cover the -LOC damage process.
- Updated loss estimation to bypass calculations if no damage is
  present, *subject to review*.
Utilizes location matching damage process tasks to aggregate pipe
damage states.
Adds more cases and tests them:
- `-LOC` + `NA`
- `-LOC` + `ALL` + `NA`
@codecov-commenter
Copy link

Codecov Report

Attention: Patch coverage is 89.26302% with 169 lines in your changes are missing coverage. Please review.

Project coverage is 92.58%. Comparing base (1e0906a) to head (bee2e79).
Report is 4 commits behind head on master.

Files Patch % Lines
pelicun/model/loss_model.py 76.94% 95 Missing ⚠️
pelicun/model/damage_model.py 85.39% 58 Missing ⚠️
pelicun/uq.py 96.38% 9 Missing ⚠️
pelicun/model/demand_model.py 97.88% 6 Missing ⚠️
pelicun/model/asset_model.py 99.34% 1 Missing ⚠️

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #38      +/-   ##
==========================================
- Coverage   93.36%   92.58%   -0.79%     
==========================================
  Files           6       12       +6     
  Lines        2428     2509      +81     
==========================================
+ Hits         2267     2323      +56     
- Misses        161      186      +25     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@zsarnoczay zsarnoczay merged commit 9b518e4 into NHERI-SimCenter:master Mar 28, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants