Bases: Protocol
A protocol class representing an analysis of one or more magnetometry
experiments.
Attributes:
Name |
Type |
Description |
results |
Any
|
The results of the analysis. For results more complicated than a simple value,
it is recommended that a dataclass be used, and that the dataclass have an
as_dict method.
|
Notes
While not yet enforced, it is strongly recommended that any class that implements
this protocol have an __init__
method which takes the following arguments:
dataset
: a Magnetometry
object
parsing_args
: an object with attributes that specify how to parse the data;
these arguments may be used as arguments to be passed to various Magnetometry
methods. It is recommended that this object be a dataclass with an as_dict
method.
fitting_args
: an object with attributes that specify how to fit the data;
these arguments may include, e.g., starting values, bounds, constraints, etc.
It is recommended that this object be a dataclass with an as_dict
method.
The __init__
method should perform the analysis and store the results in the
results
attribute.
Source code in magnetopy\magnetometry.py
| class Analysis(Protocol):
"""A protocol class representing an analysis of one or more magnetometry
experiments.
Attributes
----------
results : Any
The results of the analysis. For results more complicated than a simple value,
it is recommended that a `dataclass` be used, and that the `dataclass` have an
`as_dict` method.
Notes
-----
While not yet enforced, it is strongly recommended that any class that implements
this protocol have an `__init__` method which takes the following arguments:
- `dataset`: a `Magnetometry` object
- `parsing_args`: an object with attributes that specify how to parse the data;
these arguments may be used as arguments to be passed to various `Magnetometry`
methods. It is recommended that this object be a dataclass with an `as_dict`
method.
- `fitting_args`: an object with attributes that specify how to fit the data;
these arguments may include, e.g., starting values, bounds, constraints, etc.
It is recommended that this object be a dataclass with an `as_dict` method.
The `__init__` method should perform the analysis and store the results in the
`results` attribute.
"""
def as_dict(self) -> dict[str, Any]:
"""Return a dictionary representation of the analysis. Should include the
results of the analysis along with any parsing and fitting arguments used.
The dictionary must include a field "_class_" with the name of the class of
the analysis object (e.g. "MvsHAnalysis", "ZFCAnalysis", etc.).
Returns
-------
dict[str, Any]
"""
...
|
as_dict()
Return a dictionary representation of the analysis. Should include the
results of the analysis along with any parsing and fitting arguments used.
The dictionary must include a field "class" with the name of the class of
the analysis object (e.g. "MvsHAnalysis", "ZFCAnalysis", etc.).
Returns:
Type |
Description |
dict[str, Any]
|
|
Source code in magnetopy\magnetometry.py
| def as_dict(self) -> dict[str, Any]:
"""Return a dictionary representation of the analysis. Should include the
results of the analysis along with any parsing and fitting arguments used.
The dictionary must include a field "_class_" with the name of the class of
the analysis object (e.g. "MvsHAnalysis", "ZFCAnalysis", etc.).
Returns
-------
dict[str, Any]
"""
...
|