zospy.analyses.old.base.AnalysisResult#

class zospy.analyses.old.base.AnalysisResult#

Bases: AttrDict

Methods

clear()

copy()

from_dict(dictionary[, convert_nested, method])

Create an AttrDict from a standard dict.

from_json(json_string)

Creates an AnalysisResult object from a JSON string.

fromkeys(iterable[, value])

Create a new dictionary with keys from iterable and values set to value.

get(key[, default])

Return the value for key if key is in the dictionary, else default.

items()

keys()

pop(key[, default])

If the key is not found, return the default if given; otherwise, raise a KeyError.

popitem(/)

Remove and return a (key, value) pair as a 2-tuple.

setdefault(key[, default])

Insert key with a value of default if key is not in the dictionary.

to_dict([convert_nested, method])

Convert the AttrDict to a standard dict.

to_json()

Serializes the analysis result to JSON.

update([E, ]**F)

If E is present and has a .keys() method, then does: for k in E: D[k] = E[k] If E is present and lacks a .keys() method, then does: for k, v in E: D[k] = v In either case, this is followed by: for k in F: D[k] = F[k]

values()

__init__(analysistype: str, data: Any = None, settings: Series = None, metadata: AnalysisMetadata = None, headerdata: list[str] = None, messages: list[AnalysisMessage] = None, **kwargs)#

A class designed to hold an OpticStudio analysis.

The class is basically a dict with attribute level access. However, for an AnalysisResult, certain keys are often present and thus automatically set.

Parameters:
analysistypestr

The type of analysis that has been performed. Will be assigned to AnalysisResult.AnalysisType (also available through AnalysisResult[‘AnalysisType’].

dataAny, optional

The analysis data, can be any of the native python datatypes, a pd.Series, pd.DataFrame, np.ndarray or AnalysisData. Will be assigned to AnalysisResult.Data (also available through AnalysisResult[‘Data’]. Defaults to None.

settingspd.Series, optional

The analysis settings. Will be assigned to AnalysisResult.Settings (also available through AnalysisResult[‘Settings’]. Defaults to None.

metadataAnalysisMetadata, optional

The analysis metadata. Will be assigned to AnalysisResult.MetaData (also available through AnalysisResult[‘MetaData’]. Defaults to None.

headerdatalist[str], optional

The analysis headerdata. Will be assigned to AnalysisResult.HeaderData (also available through AnalysisResult[‘HeaderData’]. Defaults to None.

messageslist[AnalysisMessage], optional:

The analysis messages. Will be assigned to AnalysisResult.Messages (also available through AnalysisResult[‘Messages’]. Defaults to None.

kwargs:

Any supplied kwarg will be assigned as an attribute (also available as AnalysisResult[kwarg]. Note that ‘AnalysisType’, ‘Data’, ‘Settings’ ‘MetaData’, ‘HeaderData’ and ‘Messages’ are not available to be set.

Returns:
AnalysisResult:

A dict with attribute-like access

Raises:
SyntaxError:

If any of the following kwargs is specified ‘AnalysisType’, ‘Data’, ‘Settings’ ‘MetaData’, ‘HeaderData’ or ‘Messages’. These are to be set through the default arguments.

classmethod from_json(json_string: str) AnalysisResult#

Creates an AnalysisResult object from a JSON string.

This method should only be used with JSON strings created with AnalysisResult.to_json.

Parameters:
json_stringstr

JSON representation of an AnalysisResult object, created with to_json.

Returns:
resultAnalysisResult

The reconstructed AnalysisResult.

to_json() str#

Serializes the analysis result to JSON.

Returns:
json_stringstr

A JSON representation of the analysis result.