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

Cell can do partials #2618

Closed
wants to merge 6 commits into from
Closed

Cell can do partials #2618

wants to merge 6 commits into from

Conversation

joamatab
Copy link
Contributor

@joamatab joamatab commented Mar 11, 2024

allows you to use cell to create partials, and create new function signatures while maintaining IDE autocompletion

straight = gf.components.straight
straight_sc = cell(straight, cross_section="xs_sc", basename="straight_sc")
straight_so = cell(straight, cross_section="xs_so", basename="straight_so")
straight_rc = cell(straight, cross_section="xs_rc", basename="straight_rc")
straight_ro = cell(straight, cross_section="xs_ro", basename="straight_ro")
straight_nc = cell(straight, cross_section="xs_nc", basename="straight_nc")
straight_no = cell(straight, cross_section="xs_no", basename="straight_no")

fixes #2609 in a more elegant way

@joamatab joamatab added the enhancement New feature or request label Mar 11, 2024
Copy link

codecov bot commented Mar 11, 2024

Codecov Report

Attention: Patch coverage is 66.66667% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 71.70%. Comparing base (3eb14d5) to head (d9dc971).
Report is 2 commits behind head on main.

Files Patch % Lines
gdsfactory/read/from_yaml.py 0.00% 2 Missing ⚠️
gdsfactory/typings.py 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2618      +/-   ##
==========================================
- Coverage   71.71%   71.70%   -0.02%     
==========================================
  Files         365      365              
  Lines       23657    23645      -12     
  Branches     3855     3855              
==========================================
- Hits        16966    16954      -12     
  Misses       5569     5569              
  Partials     1122     1122              

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

@tvt173
Copy link
Collaborator

tvt173 commented Mar 11, 2024

I think this is much nicer than just using a regular partial. These are my only concerns:

  1. Versus rewriting the function definition in each case, a downside will still be that the docs for the cell are not tailored to each function. Of course, this is no better or worse than a partial, but still results in something less polished than if you were to write a function wrapper for each case (or only maintain one function for the PDK with a string arg for each case). I suppose you could get around this though by providing a doc argument or something like that.
  2. I'm not sure it's best to conflate all this into cell directly vs creating a separate function (i.e. partial_cell) for this purpose. I'm concerned of edge cases and user confusion if we let cell become overly complicated... I suppose it's ok though and might be more difficult to implement otherwise. Thoughts?

@flaport
Copy link
Collaborator

flaport commented Mar 11, 2024

derived_cell?

@joamatab
Copy link
Contributor Author

That's a good name

@joamatab
Copy link
Contributor Author

the issue is that it would require maintaining 2 cell decorators, so maybe keeping one only makes things easier

@sebastian-goeldi

@joamatab
Copy link
Contributor Author

maybe this is too hacky and shoulnd't be merged, as it won't be compatible with the future kfactory backend,

i'll mark it as draft

@nikosavola

@joamatab joamatab marked this pull request as draft March 11, 2024 05:21
@joamatab joamatab closed this Mar 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

simpler generic PDK customized components
3 participants