ReliaQualAssociates / ramstk

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

refactor: component type GTK3 panels #1394

Closed weibullguy closed 1 day ago

weibullguy commented 3 days ago

Does this PR introduce a breaking change?

Describe the purpose of this pull request.

To refactor the component type GTK3 panels for readability.

Describe how this was implemented.

Added global variables outside the class with dict and list values that are assigned to class variables on initiation.

Describe any particular area(s) reviewers should focus on.

None

Pull Request Checklist

Summary by Sourcery

Refactor GTK3 panel components by externalizing dictionaries and lists for component attributes, enhancing code readability and maintainability. Simplify attribute widget map initialization in components. Improve dormancy analysis by using dictionaries for hazard rate multipliers and add corresponding unit tests. Update pre-commit configuration for Ruff linter.

Enhancements:

Tests:

Chores:

sourcery-ai[bot] commented 3 days ago

Reviewer's Guide by Sourcery

This pull request refactors the component type GTK3 panels for improved readability. The main changes involve moving global variables outside the class definitions and assigning them to class variables on initialization. This refactoring affects multiple files related to different component types such as semiconductors, connections, relays, resistors, integrated circuits, switches, inductors, and meters.

File-Level Changes

Change Details Files
Moved global variables outside class definitions
  • Created global dictionaries and lists for component-specific data
  • Assigned global variables to class variables on initialization
  • Renamed some variables for consistency (e.g., _dic_quality to RESISTOR_QUALITY_DICT)
src/ramstk/views/gtk3/design_electric/components/semiconductor.py
src/ramstk/views/gtk3/design_electric/components/connection.py
src/ramstk/views/gtk3/design_electric/components/relay.py
src/ramstk/views/gtk3/design_electric/components/resistor.py
src/ramstk/views/gtk3/design_electric/components/integrated_circuit.py
src/ramstk/views/gtk3/design_electric/components/switch.py
src/ramstk/views/gtk3/design_electric/components/inductor.py
src/ramstk/views/gtk3/design_electric/components/meter.py
Refactored initialization of attribute widget maps
  • Created _do_initialize_attribute_widget_map method in each component class
  • Moved attribute widget map initialization to the new method
src/ramstk/views/gtk3/design_electric/components/semiconductor.py
src/ramstk/views/gtk3/design_electric/components/connection.py
src/ramstk/views/gtk3/design_electric/components/relay.py
src/ramstk/views/gtk3/design_electric/components/resistor.py
src/ramstk/views/gtk3/design_electric/components/integrated_circuit.py
src/ramstk/views/gtk3/design_electric/components/switch.py
src/ramstk/views/gtk3/design_electric/components/inductor.py
src/ramstk/views/gtk3/design_electric/components/meter.py
src/ramstk/views/gtk3/design_electric/components/miscellaneous.py
Refactored dormancy calculations
  • Replaced numpy array with nested dictionaries for dormant hazard rate multipliers
  • Added new functions get_environment_type and get_dormant_hr_multiplier
  • Updated do_calculate_dormant_hazard_rate function to use new helper functions
src/ramstk/analyses/dormancy.py
tests/analyses/test_dormancy.py
Updated pre-commit configuration
  • Added --config ./pyproject.toml to ruff arguments
.pre-commit-config.yaml

Tips - Trigger a new Sourcery review by commenting `@sourcery-ai review` on the pull request. - Continue your discussion with Sourcery by replying directly to review comments. - You can change your review settings at any time by accessing your [dashboard](https://app.sourcery.ai): - Enable or disable the Sourcery-generated pull request summary or reviewer's guide; - Change the review language; - You can always [contact us](mailto:support@sourcery.ai) if you have any questions or feedback.