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

refactor: component type GTK3 panels #1394

Merged
merged 18 commits into from
Sep 17, 2024
Merged

Conversation

weibullguy
Copy link
Collaborator

@weibullguy weibullguy commented Sep 15, 2024

Does this PR introduce a breaking change?

  • Yes
  • No

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

  • Code Style

    • Code is following code style guidelines.
  • Static Checks

    • Failing static checks are only applicable to code outside the scope of
      this PR.
  • Tests

    • At least one test for all newly created functions/methods?
  • Chores

    • Issue(s) have been raised for problem areas outside the scope of
      this PR. These problem areas have been decorated with an ISSUE: # comment.

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:

  • Refactor GTK3 panel components by moving dictionary and list definitions outside of classes for improved readability and maintainability.
  • Introduce global dictionaries and lists for component attributes such as quality, type, application, and construction across various components like semiconductors, connections, relays, resistors, integrated circuits, switches, inductors, miscellaneous devices, and meters.
  • Simplify the initialization of attribute widget maps in GTK3 panel components by using a dedicated method to set up these mappings.
  • Improve the dormancy analysis module by replacing numpy arrays with dictionaries for dormant hazard rate multipliers, enhancing code clarity and maintainability.

Tests:

  • Add unit tests for the dormancy analysis module to verify the correct calculation of dormant hazard rates and environment type retrieval.

Chores:

  • Update pre-commit configuration to include a custom configuration file for the Ruff linter.

Copy link
Contributor

sourcery-ai bot commented Sep 15, 2024

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:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@github-actions github-actions bot added the type: refactor Issue or PR dealing with refactoring of RAMSTK code. label Sep 15, 2024
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @weibullguy - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

src/ramstk/analyses/dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Outdated Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
tests/analyses/test_dormancy.py Show resolved Hide resolved
@weibullguy weibullguy added priority: low Issue or PR is low priority. status: inprogress Issue or PR is open, milestoned, and assigned. type: style Issue or PR affects code quality (e.g., coding standards). labels Sep 16, 2024
@weibullguy weibullguy merged commit 87b3798 into master Sep 17, 2024
18 of 21 checks passed
@trafico-bot trafico-bot bot added the endgame: merged Pull Request has been merged successfully label Sep 17, 2024
@weibullguy weibullguy deleted the refactor/component_panels branch September 17, 2024 13:55
@weibullguy weibullguy added status: closed Pull Request is complete and integrated or closed for anther reason. and removed status: inprogress Issue or PR is open, milestoned, and assigned. labels Oct 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
endgame: merged Pull Request has been merged successfully priority: low Issue or PR is low priority. status: closed Pull Request is complete and integrated or closed for anther reason. type: refactor Issue or PR dealing with refactoring of RAMSTK code. type: style Issue or PR affects code quality (e.g., coding standards).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant