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

Support instances in path-length extraction from gds #468

Merged
merged 2 commits into from
Aug 15, 2024

Conversation

nikosavola
Copy link
Member

  • Re-support instances for path length GDS analysis
  • More correct typing for layer

@nikosavola nikosavola self-assigned this Aug 14, 2024
@nikosavola nikosavola changed the title support instances in path length analysis gds Support instances in path-length extraction from gds Aug 14, 2024
@nikosavola nikosavola requested a review from joamatab August 14, 2024 14:12
@nikosavola nikosavola marked this pull request as ready for review August 14, 2024 14:12
Copy link
Contributor

sourcery-ai bot commented Aug 14, 2024

🧙 Sourcery has finished reviewing your pull request!


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.

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.

We've reviewed this pull request using the Sourcery rules engine. If you would also like our AI-powered code review then let us know.

@@ -236,7 +236,7 @@ def centerline_single_poly_2_ports(poly, under_sampling, port_list) -> np.ndarra

def extract_paths(
Copy link
Contributor

Choose a reason for hiding this comment

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

issue (code-quality): We've found these issues:


ExplanationThe most concise and Pythonic way to create a list is to use the [] notation.

This fits in with the way we create lists with elements, saving a bit of mental
energy that might be taken up with thinking about two different ways of creating
lists.

x = ["first", "second"]

Doing things this way has the added advantage of being a nice little performance
improvement.

Here are the timings before and after the change:

$ python3 -m timeit "x = list()"
5000000 loops, best of 5: 63.3 nsec per loop
$ python3 -m timeit "x = []"
20000000 loops, best of 5: 15.8 nsec per loop

Similar reasoning and performance results hold for replacing dict() with {}.
The most concise and Pythonic way to create a list is to use the [] notation.

This fits in with the way we create lists with elements, saving a bit of mental
energy that might be taken up with thinking about two different ways of creating
lists.

x = ["first", "second"]

Doing things this way has the added advantage of being a nice little performance
improvement.

Here are the timings before and after the change:

$ python3 -m timeit "x = list()"
5000000 loops, best of 5: 63.3 nsec per loop
$ python3 -m timeit "x = []"
20000000 loops, best of 5: 15.8 nsec per loop

Similar reasoning and performance results hold for replacing dict() with {}.
Python has a number of builtin variables: functions and constants that
form a part of the language, such as list, getattr, and type
(See https://docs.python.org/3/library/functions.html).
It is valid, in the language, to re-bind such variables:

list = [1, 2, 3]

However, this is considered poor practice.

  • It will confuse other developers.
  • It will confuse syntax highlighters and linters.
  • It means you can no longer use that builtin for its original purpose.

How can you solve this?

Rename the variable something more specific, such as integers.
In a pinch, my_list and similar names are colloquially-recognized
placeholders.
The quality score for this function is below the quality threshold of 25%.
This score is a combination of the method length, cognitive complexity and working memory.

How can you solve this?

It might be worth refactoring this function to make it shorter and more readable.

  • Reduce the function length by extracting pieces of functionality out into
    their own functions. This is the most important thing you can do - ideally a
    function should be less than 10 lines.
  • Reduce nesting, perhaps by introducing guard clauses to return early.
  • Ensure that variables are tightly scoped, so that code using related concepts
    sits together within the function rather than being scattered.

Copy link
Member Author

Choose a reason for hiding this comment

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

Confused about where this was used. Not in this patch at least.

Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like my initial review comment might have been a bit too general and not directly related to the specific changes in this patch. I apologize for any confusion caused.

To clarify, the issues I mentioned are general code quality improvements that could be applied to the codebase, but they might not be directly relevant to the specific changes in this pull request. If these issues are not present in the diff you provided, you can disregard them for now.

If you have any specific questions or need further clarification on any part of the review, please let me know! I'm here to help.

@nikosavola nikosavola enabled auto-merge August 14, 2024 14:13
@nikosavola nikosavola merged commit a989649 into main Aug 15, 2024
10 of 17 checks passed
@nikosavola nikosavola deleted the support-instances-in-path-length-analysis-gds branch August 15, 2024 15:46
@joamatab joamatab added the bug Something isn't working label Aug 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants