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

Update gdsfactory #495

Merged
merged 6 commits into from
Nov 23, 2024
Merged

Update gdsfactory #495

merged 6 commits into from
Nov 23, 2024

Conversation

joamatab
Copy link
Contributor

@joamatab joamatab commented Nov 23, 2024

make it compatible with latest gdsfactory

Summary by Sourcery

Enhance codebase by updating type annotations, refactoring string formatting, and improving docstring consistency. Update pre-commit hooks to latest versions for better linting and notebook handling.

Enhancements:

  • Update type annotations to use the '|' syntax for optional types, improving code readability and compatibility with newer Python versions.
  • Refactor string formatting to use f-strings with '!s' for better readability and performance.
  • Remove unnecessary blank lines and trailing whitespace to clean up the codebase.
  • Improve docstring formatting for consistency and clarity across the codebase.

Build:

  • Update pre-commit hooks to use the latest versions of 'ruff' and 'nbstripout' for improved linting and notebook handling.

Copy link
Contributor

sourcery-ai bot commented Nov 23, 2024

Reviewer's Guide by Sourcery

This pull request updates the codebase to be compatible with the latest version of gdsfactory. The main changes focus on improving type hints, docstring formatting, and code style to align with modern Python practices and the latest gdsfactory requirements.

Updated class diagram for sprocess.py

classDiagram
    class Sprocess {
        +initialize_sprocess(component, waferstack, layermap, xsection_bounds: tuple[tuple[float, float], tuple[float, float]] | None, u_offset: float, round_tol: int, simplify_tol: float, initial_z_resolutions: Dict, initial_xy_resolution: float | None, extra_resolution_str: str | None)
        +write_sprocess(component, waferstack, layermap, process, xsection_bounds: tuple[tuple[float, float], tuple[float, float]] | None, u_offset: float, init_tdr: str | None, save_directory: Path | None, execution_directory: Path | None, filename: str, struct_prefix: str, structout: str | None, split_steps: bool, init_lines: str, initial_z_resolutions: Dict, initial_xy_resolution: float | None, extra_resolution_str: str | None, global_process_remeshing_str: str, global_device_remeshing_str: str, num_threads: int, contact_str: str, device_remesh: bool) -> None
    }
Loading

Updated class diagram for spice_to_yaml.py

classDiagram
    class SpiceToYaml {
        +spice_to_yaml(netlist_path: str, mapping_path: str, picyaml_path: str, pdk: str, mode: str) -> None
        +cli(netlist_path: str, mode: str, picyaml_path: str) -> None
        +get_netlists(netlist_path: str, mapping_path: str, pdk: str, ignore_electrical: bool, map_flag: str, ignored_info: tuple[str, ...]) -> list
    }
Loading

Updated class diagram for uz_xsection_mesh.py

classDiagram
    class UzXsectionMesh {
        +get_u_bounds_polygons(polygons, xsection_bounds: tuple[tuple[float, float], tuple[float, float]], u_offset: float)
        +get_u_bounds_layers(layer_polygons_dict: dict[tuple(str, str, str), MultiPolygon], xsection_bounds: tuple[tuple[float, float], tuple[float, float]])
        +get_uz_bounds_layers(layer_polygons_dict, xsection_bounds: tuple[tuple[float, float], tuple[float, float]], layer_stack: LayerStack, u_offset: float, z_bounds: tuple[float, float] | None)
    }
Loading

Updated class diagram for xyz_mesh.py

classDiagram
    class XyzMesh {
        +define_prisms(layer_polygons_dict: dict, layer_stack: LayerStack, model: Model, resolutions: dict, scale_factor: float)
        +xyz_mesh(component, layer_stack, layer_physical_map, layer_meshbool_map, resolutions, default_characteristic_length: float, background_tag: str, background_padding: tuple, background_mesh_order: int, global_scaling: float, global_scaling_premesh: float, global_2D_algorithm: str, global_3D_algorithm: str, filename: str, verbosity: int, round_tol: int, simplify_tol: float, n_threads: int, port_names: list[str] | None, edge_ports: list[str] | None, gmsh_version: float | None, layer_port_delimiter: str | None, background_remeshing_file: Path | None, optimization_flags: tuple[tuple[str, int]] | None) -> bool
    }
Loading

File-Level Changes

Change Details Files
Updated type hints throughout the codebase to use the new Python syntax
  • Changed Optional[Type] to Type
None
  • Added return type annotations to functions
  • Updated list type hints to use list[Type] instead of List[Type]
  • Added missing type hints to class methods
  • Improved docstring formatting and documentation
    • Removed redundant empty lines after docstrings
    • Fixed docstring formatting to follow Google style
    • Changed 'TODO' to 'Todo' in docstrings
    • Removed redundant quotes in docstrings
    • Added missing parameter descriptions
    gplugins/tidy3d/component.py
    gplugins/sax/build_model.py
    gplugins/gmeep/write_sparameters_meep.py
    gplugins/klayout/get_density.py
    Updated string formatting to use f-strings with !s for string conversion
    • Replaced str() calls in f-strings with !s format specifier
    • Updated string concatenation to use f-strings
    gplugins/sentaurus/sprocess.py
    gplugins/sentaurus/svisual.py

    Tips and commands

    Interacting with Sourcery

    • Trigger a new review: Comment @sourcery-ai review on the pull request.
    • Continue discussions: Reply directly to Sourcery's review comments.
    • Generate a GitHub issue from a review comment: Ask Sourcery to create an
      issue from a review comment by replying to it.
    • Generate a pull request title: Write @sourcery-ai anywhere in the pull
      request title to generate a title at any time.
    • Generate a pull request summary: Write @sourcery-ai summary anywhere in
      the pull request body to generate a PR summary at any time. You can also use
      this command to specify where the summary should be inserted.

    Customizing Your Experience

    Access your dashboard to:

    • Enable or disable review features such as the Sourcery-generated pull request
      summary, the reviewer's guide, and others.
    • Change the review language.
    • Add, remove or edit custom review instructions.
    • Adjust other review settings.

    Getting Help

    @joamatab joamatab added the dependencies Pull requests that update a dependency file label Nov 23, 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.

    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.

    @@ -130,8 +129,7 @@ def report_pathlengths(


    def get_paths(pathlength_graph: nx.Graph) -> list[dict[str, Any]]:
    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): Low code quality found in get_paths - 10% (low-code-quality)


    ExplanationThe 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.

    @@ -34,7 +34,7 @@ def initialize_sde(
    component,
    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:

    @@ -661,7 +655,7 @@ def get_var_name(string: str):


    def group_instance_str(netlist: str) -> list:
    """Group instance SPICE strings if they are extended by '+' and filter away lines that do not have params
    """Group instance SPICE strings if they are extended by '+' and filter away lines that do not have params.
    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:

    @joamatab joamatab merged commit 9758699 into main Nov 23, 2024
    3 of 15 checks passed
    @joamatab joamatab deleted the update_gdsfactory branch November 23, 2024 06:05
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    dependencies Pull requests that update a dependency file
    Projects
    None yet
    Development

    Successfully merging this pull request may close these issues.

    1 participant