Closed weibullguy closed 1 month ago
This pull request refactors the allocation calculations in the RAMSTK project. The main changes include improved error handling, code organization, and the introduction of helper functions to reduce code duplication. The refactoring aims to make the code more maintainable and easier to understand.
classDiagram
direction TB
class Allocation {
+Dict _calculate_agree_apportionment(float parent_goal, Dict attributes)
+Dict _calculate_arinc_apportionment(float parent_goal, Dict attributes)
+Dict _calculate_equal_apportionment(float parent_goal, Dict attributes)
+Dict _calculate_foo_apportionment(float parent_goal, int cum_weight, Dict attributes)
+Dict do_allocate_reliability(float parent_goal, int cumulative_weight, **attributes)
+Dict _calculate_common_values(Dict attributes)
+void _send_pubsub_message(string message_type, string message)
}
Allocation --> PubSub : uses
class PubSub {
+void sendMessage(string message_type, string error_message)
}
Change | Details | Files |
---|---|---|
Refactored allocation calculation functions |
|
src/ramstk/analyses/allocation.py |
Improved code organization in do_allocate_reliability() |
|
src/ramstk/analyses/allocation.py |
Updated test cases to reflect new error messages |
|
tests/analyses/allocation_calc_integration_test.py |
Does this PR introduce a breaking change?
Describe the purpose of this pull request.
This PR refactors the Allocation calculations.
Describe how this was implemented.
Ran code through ChatGPT.
Describe any particular area(s) reviewers should focus on.
None
Provide any other pertinent information.
Pull Request Checklist
Code Style
Static Checks
Tests
Chores
Summary by Sourcery
Refactor allocation calculations to enhance code clarity and error handling, and update tests to align with these changes.
Enhancements:
_send_pubsub_message
to streamline the sending of failure messages via pubsub.do_allocate_reliability
function to use a dictionary for method selection, simplifying the allocation method dispatch logic.Tests: