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

bugfix in manhattan routing if the first reference is a bend turn #2704

Merged
merged 1 commit into from
Apr 27, 2024

Conversation

thomaslima
Copy link
Contributor

I first observed this bug when calling round_corners on a path that is supposed to start with a bend. The first port is not computed properly because the first zero-length straight section is discarded.

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 @thomaslima - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 2 issues found
  • 🟢 Security: all looks good
  • 🟡 Testing: 1 issue found
  • 🟢 Complexity: 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.

Comment on lines +911 to +915
else:
# Sometimes the path starts with a bend,
# therefore the initial straight has zero length.
# Adding it here so that the first port is correctly returned.
wg_refs += [wg_ref]
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (edge_case_not_handled): Consider handling the case where wg_ref might be None or invalid.

In the added else block, there's an assumption that wg_ref is always a valid reference. It might be beneficial to add a check to ensure wg_ref is not None or does not fail other validity checks before adding it to wg_refs.

Suggested change
else:
# Sometimes the path starts with a bend,
# therefore the initial straight has zero length.
# Adding it here so that the first port is correctly returned.
wg_refs += [wg_ref]
else:
if wg_ref is not None:
wg_refs += [wg_ref]

Comment on lines +911 to +915
else:
# Sometimes the path starts with a bend,
# therefore the initial straight has zero length.
# Adding it here so that the first port is correctly returned.
wg_refs += [wg_ref]
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion (testing): Missing test for the new condition handling zero-length straights.

The code change introduces handling for cases where the path starts with a bend, leading to a zero-length straight. It's crucial to add a unit test to verify that the first port is computed correctly in this scenario.

Suggested change
else:
# Sometimes the path starts with a bend,
# therefore the initial straight has zero length.
# Adding it here so that the first port is correctly returned.
wg_refs += [wg_ref]
else:
wg_refs.append(wg_ref)

Copy link

codecov bot commented Apr 26, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.71%. Comparing base (90d6d9c) to head (1c0b76b).
Report is 78 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2704      +/-   ##
==========================================
- Coverage   71.78%   71.71%   -0.07%     
==========================================
  Files         366      366              
  Lines       23755    23797      +42     
  Branches     3873     3876       +3     
==========================================
+ Hits        17052    17067      +15     
- Misses       5578     5603      +25     
- Partials     1125     1127       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joamatab joamatab added the bug Something isn't working label Apr 27, 2024
@joamatab joamatab self-requested a review April 27, 2024 00:56
Copy link
Contributor

@joamatab joamatab left a comment

Choose a reason for hiding this comment

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

awesome! thank you Thomas!

@joamatab joamatab merged commit d1e0a26 into gdsfactory:main Apr 27, 2024
12 of 14 checks passed
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.

None yet

2 participants