ReliaQualAssociates / ramstk

Reliability, Availability, Maintainability, Safety (RAMS) analysis program.
https://www.reliaqual.com/rtk/
BSD 3-Clause "New" or "Revised" License
46 stars 15 forks source link

refactor: stress ratio calculations #1418

Closed weibullguy closed 1 month ago

weibullguy commented 1 month ago

Does this PR introduce a breaking change?

Purpose of this pull request

This pull request refactors the calculate_stress_ratio function to improve error handling and input validation. Specifically, it introduces validation to ensure that neither the operating nor the rated stress values are negative. Additionally, a new set of unit tests has been added to cover edge cases, including handling of zero and negative input values, as well as testing invalid data types.

Benefits of the pull request

Any particular area(s) reviewers should focus on

Any other pertinent information.

Pull Request Checklist

Summary by Sourcery

Refactor the calculate_stress_ratio function to enhance error handling and input validation, ensuring robustness against negative and zero values. Introduce comprehensive unit tests to cover edge cases and validate the new logic.

Enhancements:

Tests:

Chores:

sourcery-ai[bot] commented 1 month ago

Reviewer's Guide by Sourcery

This pull request refactors the stress ratio calculations to improve error handling and input validation. The changes focus on enhancing the robustness of the calculate_stress_ratio function by introducing proper input validation, improving error handling, and expanding the test coverage to include edge cases.

No diagrams generated as the changes look simple and do not need a visual representation.

File-Level Changes

Change Details Files
Refactored calculate_stress_ratio function for improved input validation and error handling
  • Added type checking for input parameters
  • Implemented validation for non-negative stress values
  • Improved error handling for zero-rated stress
  • Raised ValueError for negative stress inputs
src/ramstk/analyses/stress.py
Extended unit tests for stress ratio calculations
  • Added test for negative operating stress
  • Added test for negative rated stress
  • Added test for zero operating stress
  • Added test for both operating and rated stresses being zero
tests/analyses/test_stress.py
Updated copyright information and file headers
  • Changed copyright year from 2019 to 'since 2007'
  • Corrected file name in header comment
src/ramstk/analyses/stress.py
tests/analyses/test_stress.py
Improved pull request template
  • Reworded section headers for clarity
  • Adjusted formatting for consistency
.github/PULL_REQUEST_TEMPLATE.md

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).