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: Iterate over the dictionary directly instead of using .keys(). #3631

Merged
merged 8 commits into from
Jan 7, 2025

Conversation

MaxJPRey
Copy link
Contributor

@MaxJPRey MaxJPRey commented Dec 26, 2024

Description

  • Iterate over the dictionary directly instead of using .keys().
    If you want to check whether a specific key is in a dictionary, you can write if key in dictionary. There's no need to write if key in dictionary.keys(). Furthermore, if key in dictionary is faster because it uses a hash lookup, while if key in dictionary.keys() generates a new list and then does a linear search through that list.

  • Remove some bare except.

  • Update some docstrings.

Issue linked

Please mention the issue number or describe the problem this pull request addresses.

Checklist

@MaxJPRey MaxJPRey requested a review from a team as a code owner December 26, 2024 16:27
@ansys-reviewer-bot
Copy link
Contributor

Thanks for opening a Pull Request. If you want to perform a review write a comment saying:

@ansys-reviewer-bot review

@github-actions github-actions bot added the enhancement Improve any current implemented feature label Dec 26, 2024
@MaxJPRey MaxJPRey changed the title REFACTOR: Iterate over the dictionary directly instead of using .keys(). refactor: Iterate over the dictionary directly instead of using .keys(). Dec 26, 2024
Copy link

codecov bot commented Dec 26, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 87.14%. Comparing base (4f75f6a) to head (c79fac1).
Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3631      +/-   ##
==========================================
- Coverage   87.18%   87.14%   -0.05%     
==========================================
  Files         187      187              
  Lines       14660    14660              
==========================================
- Hits        12782    12775       -7     
- Misses       1878     1885       +7     

Copy link
Collaborator

@germa89 germa89 left a comment

Choose a reason for hiding this comment

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

LGTM. Thank you a lot for this!!

src/ansys/mapdl/core/pool.py Outdated Show resolved Hide resolved
src/ansys/mapdl/core/commands.py Show resolved Hide resolved
@github-actions github-actions bot added examples Publishing PyMAPDL examples documentation Documentation related (improving, adding, etc) labels Jan 7, 2025
@github-actions github-actions bot removed examples Publishing PyMAPDL examples documentation Documentation related (improving, adding, etc) labels Jan 7, 2025
@germa89 germa89 enabled auto-merge (squash) January 7, 2025 13:01
@germa89 germa89 merged commit 841313d into main Jan 7, 2025
56 of 60 checks passed
@germa89 germa89 deleted the maint/iterate_keys branch January 7, 2025 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improve any current implemented feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants