tidy3d.plugins.design.Result#
- class Result[source]#
- Bases: - Tidy3dBaseModel- Stores the result of a run over a - DesignSpace. Can be converted to- pandas.DataFramewith- Result.to_dataframe()for post processing.- Parameters:
- attrs (dict = {}) β Dictionary storing arbitrary metadata for a Tidy3D object. This dictionary can be freely used by the user for storing data without affecting the operation of Tidy3D as it is not used internally. Note that, unlike regular Tidy3D fields, - attrsare mutable. For example, the following is allowed for setting an- attr- obj.attrs['foo'] = bar. Also note that Tidy3D` will raise a- TypeErrorif- attrscontain objects that can not be serialized. One can check if- attrsare serializable by calling- obj.json().
- dims (Tuple[str, ...] = ()) β The dimensions of the design variables (indexed by βnameβ). 
- values (Tuple[Any, ...] = ()) β The return values from the design problem function. 
- coords (Tuple[Tuple[Any, ...], ...] = ()) β The values of the coordinates corresponding to each of the dims.Note: shaped (D, N) where D is the - len(dims)and N is the- len(values)
- output_names (Optional[Tuple[str, ...]] = None) β Names for each of the outputs stored in - values. If not specified, default values are assigned.
- fn_source (Optional[str] = None) β Source code for the function evaluated in the parameter sweep. 
- task_names (Optional[list] = None) β Task name of every simulation run during - DesignSpace.run. Only available if the parameter sweep function is split into pre and post processing, otherwise is- None. Stored in the same format as the output of fn_pre i.e. if pre outputs a dict, this output is a dict with the keys preserved.
- task_paths (Optional[list] = None) β Task paths of every simulation run during - DesignSpace.run. Useful for loading download- SimulationDatahdf5 files.Only available if the parameter sweep function is split into pre and post processing, otherwise is- None. Stored in the same format as the output of fn_pre i.e. if pre outputs a dict, this output is a dict with the keys preserved.
- aux_values (Optional[Tuple[Any, ...]] = None) β The auxiliary return values from the design problem function. This is the collection of objects returned alongside the float value used for the optimization. These werenβt used to inform the optimizer, if one was used. 
- optimizer (Optional[Any] = None) β The optimizer returned at the end of an optimizer run. Can be used to analyze and plot how the optimization progressed. Attributes depend on the optimizer used; a full explaination of the optimizer can be found on associated library doc pages. Will be - Nonefor sampling based methods.
 
 - Example - >>> import tidy3d.plugins.design as tdd >>> result = tdd.Result( ... dims=('x', 'y', 'z'), ... values=(1, 2, 3, 4), ... coords=((0,1,2), (1,2,3), (2,3,4), (3,4,5)), ... output_names=("output",), ... ) >>> df = result.to_dataframe() >>> # df.head() # print out first 5 elements of data - Attributes - Methods - add(fn_args,Β value)- Add a specific argument and value the result. - combine(other)- Combine data from two results into a new result (also works with '+'). - default_value_keys(value)- The default keys for a given value. - delete(fn_args)- Delete a specific set of arguments from the result. - from_dataframe(df[,Β dims])- Load a result directly from a pandas.DataFrame object. - get_index(fn_args)- Get index into the data for a specific set of arguments. - get_value(coords)- Get a data element indexing by function arg tuple. - items()- Iterate through coordinates (args) and values (outputs) one by one. - sel(**kwargs)- Get a data element by function kwargs.. - to_dataframe([include_aux])- Data as a - pandas.DataFrame.- value_as_dict(value)- How to convert an output function value as a dictionary. - Inherited Common Usage - dims#
 - values#
 - coords#
 - output_names#
 - fn_source#
 - task_names#
 - task_paths#
 - aux_values#
 - optimizer#
 - property data#
- Dict mapping tuple of fn args to their value. 
 - to_dataframe(include_aux=False)[source]#
- Data as a - pandas.DataFrame.- Output a - pandas.DataFrameof the- Result. Can include auxiliary data if- include_auxis- Trueand auxiliary data is found in the- Result. If auxiliary data is in a dictionary the keys will be used as column names, otherwise they will be labeled- aux_key_Xfor X auxiliary columns.- Parameters:
- include_aux (bool = False) β Toggle to include auxiliary values in the dataframe. Requires auxiliary values in the - Result.
- Returns:
- pandas.DataFramecorresponding to the- Result.
- Return type:
- pandas.DataFrame 
 
 - classmethod from_dataframe(df, dims=None)[source]#
- Load a result directly from a pandas.DataFrame object. - Parameters:
- df ( - pandas.DataFrame) β- `DataFrameobject to load into a- Result.
- dims (List[str] = None) β Set of dimensions corresponding to the function arguments. Not required if this dataframe was generated directly from a - Resultwithout modification. In that case, it contains the dims in its- .attrsmetadata.
 
- Returns:
- Result loaded from this - DataFrame.
- Return type:
 
 - delete(fn_args)[source]#
- Delete a specific set of arguments from the result. - Parameters:
- fn_args (Dict[str, float]) β - dictcontaining the function arguments one wishes to delete.
- Returns:
- Copy of the result with that element removed. 
- Return type:
 
 - add(fn_args, value)[source]#
- Add a specific argument and value the result. - Parameters:
- fn_args (Dict[str, float]) β - dictcontaining the function arguments one wishes to add.
- value (Any) β Data point value corresponding to these arguments. 
 
- Returns:
- Copy of the result with that element added. 
- Return type:
 
 - __getitem__(data_index)[source]#
- Implement the accessor function to index into the coordinates and values of the result. 
 - __hash__()#
- Hash method.