gdsfactory.cell#
- gdsfactory.cell(func: None, /, *, autoname: bool = True, copy_if_cached: bool = True, max_name_length: int | None = None, include_module: bool = False, with_hash: bool = False, ports_offgrid: str | None = None, ports_not_manhattan: str | None = None, flatten: bool = False, naming_style: str = 'default', default_decorator: Callable[[Component], Component] | None = None, add_settings: bool = True, validate: bool = False, get_child_name: bool = False, post_process: Sequence[Callable] | None = None, info: dict[str, int | float | str] | None = None) partial [source]#
- gdsfactory.cell(func: _F, /, *, autoname: bool = True, copy_if_cached: bool = True, max_name_length: int | None = None, include_module: bool = False, with_hash: bool = False, ports_offgrid: str | None = None, ports_not_manhattan: str | None = None, flatten: bool = False, naming_style: str = 'default', default_decorator: Callable[[Component], Component] | None = None, add_settings: bool = True, validate: bool = False, get_child_name: bool = False, post_process: Sequence[Callable] | None = None, info: dict[str, int | float | str] | None = None) _F
Parametrized Decorator for Component functions.
- Parameters:
func – function to decorate.
autoname – True renames Component based on args and kwargs. True by default.
copy_if_cached – True by default. If the component is already in the cache, it returns a copy of the component.
max_name_length – truncates name beyond some characters with a hash. Defaults to CONF.max_name_length.
include_module – True adds module name to the cell name.
with_hash – True adds a hash to the cell name.
ports_offgrid – “warn”, “error” or “ignore”. Checks if ports are on grid. Defaults to CONF.ports_offgrid.
ports_not_manhattan – “warn”, “error” or “ignore”. Checks if ports are manhattan. Defaults to CONF.ports_non_manhattan.
flatten – False by default. True flattens component hierarchy.
naming_style – “default” or “updk”. “default” is the default naming style.
default_decorator – default decorator to apply to the component. None by default.
add_settings – True by default. Adds settings to the component.
validate – validate the function call. Does not work with annotations that have None | Callable.
get_child_name – Use child name as component name prefix.
post_process – list of post processing functions to apply to the component.
info – dictionary with metadata to add to the component.
Implements a cache so that if a component has already been build it returns the component from the cache directly. This avoids creating two exact Components that have the same name. Can autoname components based on the function name and arguments.
A decorator is a function that runs over a function, so when you do.
import gdsfactory as gf @gf.cell def mzi_with_bend(): c = gf.Component() mzi = c << gf.components.mzi() bend = c << gf.components.bend_euler() return c
it’s equivalent to
def mzi_with_bend(): c = gf.Component() mzi = c << gf.components.mzi() bend = c << gf.components.bend_euler(radius=radius) return c mzi_with_bend_decorated = gf.cell(mzi_with_bend)