tidy3d.components.base.Tidy3dBaseModel
tidy3d.components.base.Tidy3dBaseModel#
- class tidy3d.components.base.Tidy3dBaseModel#
Base pydantic model that all Tidy3d components inherit from. Defines configuration for handling data structures as well as methods for imporing, exporting, and hashing tidy3d objects. For more details on pydantic base models, see: Pydantic Models
Show JSON schema
{ "title": "Tidy3dBaseModel", "description": "Base pydantic model that all Tidy3d components inherit from.\nDefines configuration for handling data structures\nas well as methods for imporing, exporting, and hashing tidy3d objects.\nFor more details on pydantic base models, see:\n`Pydantic Models <https://pydantic-docs.helpmanual.io/usage/models/>`_", "type": "object", "properties": {}, "additionalProperties": false }
- classmethod add_type_field()#
Automatically place “type” field with model name in the model field dictionary.
- copy(validate: bool = True, **kwargs) Self #
Copy a Tidy3dBaseModel. With
deep=True
as default.
- classmethod from_file(fname: str, **parse_kwargs)#
Loads a
Tidy3dBaseModel
from .yaml or .json file.- Parameters
fname (str) – Full path to the .yaml or .json file to load the
Tidy3dBaseModel
from.**parse_kwargs – Keyword arguments passed to either pydantic’s
parse_file
orparse_raw
methods for.json
and.yaml
file formats, respectively.
- Returns
An instance of the component class calling load.
- Return type
Example
>>> simulation = Simulation.from_file(fname='folder/sim.json')
- classmethod from_json(fname: str, **parse_file_kwargs)#
Load a
Tidy3dBaseModel
from .json file.- Parameters
fname (str) – Full path to the .json file to load the
Tidy3dBaseModel
from.- Returns
Tidy3dBaseModel
– An instance of the component class calling load.**parse_file_kwargs – Keyword arguments passed to pydantic’s
parse_file
method.
Example
>>> simulation = Simulation.from_json(fname='folder/sim.json')
- classmethod from_yaml(fname: str, **parse_raw_kwargs)#
Loads
Tidy3dBaseModel
from .yaml file.- Parameters
fname (str) – Full path to the .yaml file to load the
Tidy3dBaseModel
from.**parse_raw_kwargs – Keyword arguments passed to pydantic’s
parse_raw
method.
- Returns
An instance of the component class calling from_yaml.
- Return type
Example
>>> simulation = Simulation.from_yaml(fname='folder/sim.yaml')
- classmethod generate_docstring() str #
Generates a docstring for a Tidy3D mode and saves it to the __doc__ of the class.
- help(methods: bool = False) None #
Prints message describing the fields and methods of a
Tidy3dBaseModel
.- Parameters
methods (bool = False) – Whether to also print out information about object’s methods.
Example
>>> simulation.help(methods=True)
- to_file(fname: str) None #
Exports
Tidy3dBaseModel
instance to .yaml or .json file- Parameters
fname (str) – Full path to the .yaml or .json file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_file(fname='folder/sim.json')
- to_json(fname: str) None #
Exports
Tidy3dBaseModel
instance to .json file- Parameters
fname (str) – Full path to the .json file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_json(fname='folder/sim.json')
- to_yaml(fname: str) None #
Exports
Tidy3dBaseModel
instance to .yaml file.- Parameters
fname (str) – Full path to the .yaml file to save the
Tidy3dBaseModel
to.
Example
>>> simulation.to_yaml(fname='folder/sim.yaml')