base_classes
Modules:
| Name | Description |
|---|---|
easydynamics_base |
|
easydynamics_list |
|
easydynamics_modelbase |
|
name_mixin |
|
Classes:
| Name | Description |
|---|---|
EasyDynamicsBase |
Base class for all EasyDynamics classes. |
EasyDynamicsModelBase |
Base class for all EasyDynamics models. |
Classes
EasyDynamicsBase(*args, name='MyEasyDynamicsModel', display_name=None, unique_name=None, **kwargs)
Base class for all EasyDynamics classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Positional arguments to pass to the parent class. |
()
|
name
|
str
|
Name of the model. |
'MyEasyDynamicsModel'
|
display_name
|
str | None
|
Display name of the model. If None, the name will be used. |
None
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
**kwargs
|
object
|
Additional keyword arguments to pass to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If name is not a string. |
Methods:
| Name | Description |
|---|---|
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object from a full encoded dictionary. |
__copy__ |
Return a copy of the object. |
Attributes:
| Name | Type | Description |
|---|---|---|
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
Attributes
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
Returns:
| Type | Description |
|---|---|
str
|
The pretty display name. |
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
Methods:
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip
|
Optional[List[str]]
|
List of field names as strings to skip when forming the dictionary. By default, None. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Encoded object containing all information to reform an EasyScience object. |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_dict
|
Dict[str, Any]
|
Dictionary containing the serialized contents (from
|
required |
Returns:
| Type | Description |
|---|---|
NewBase
|
Reformed EasyScience object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input dictionary does not describe the expected class. |
__copy__()
Return a copy of the object.
EasyDynamicsModelBase(*args, x_unit='meV', y_unit='dimensionless', name='MyEasyDynamicsModel', display_name=None, unique_name=None, **kwargs)
Base class for all EasyDynamics models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Positional arguments to pass to the parent class. |
()
|
x_unit
|
str | sc.Unit
|
Unit of the x-axis. |
'meV'
|
y_unit
|
str | sc.Unit
|
Unit of the y-axis. |
'dimensionless'
|
name
|
str
|
Name of the model. |
'MyEasyDynamicsModel'
|
display_name
|
str | None
|
Display name of the model. If None, the name will be used. |
None
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
**kwargs
|
object
|
Additional keyword arguments to pass to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If name is not a string. |
Methods:
| Name | Description |
|---|---|
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object with DescriptorNumber attributes |
__copy__ |
Return a copy of the object. |
get_all_variables |
Get all |
get_all_parameters |
Get all |
get_fittable_parameters |
Get all parameters which can be fitted as a list. |
get_free_parameters |
Get all parameters which are currently free to be fitted as a |
get_fit_parameters |
This is an alias for |
Attributes:
| Name | Type | Description |
|---|---|---|
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
x_unit |
str | sc.Unit | None
|
Get the unit of the x-axis. |
y_unit |
str | sc.Unit | None
|
Get the unit of the model output. |
Attributes
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
Returns:
| Type | Description |
|---|---|
str
|
The pretty display name. |
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
x_unit
property
writable
y_unit
property
writable
Get the unit of the model output.
Returns:
| Type | Description |
|---|---|
str | sc.Unit | None
|
The unit of the y-axis. |
Methods:
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip
|
Optional[List[str]]
|
List of field names as strings to skip when forming the dictionary. By default, None. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Encoded object containing all information to reform an EasyScience object. |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object with DescriptorNumber attributes from a full encoded dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_dict
|
Dict[str, Any]
|
Dictionary containing the serialized contents (from
|
required |
Returns:
| Type | Description |
|---|---|
ModelBase
|
Reformed EasyScience object. |
Raises:
| Type | Description |
|---|---|
SyntaxError
|
If a deserialized parameter cannot be attached back to the class definition. |
ValueError
|
If the input dictionary does not describe the expected class. |
__copy__()
Return a copy of the object.
get_all_variables()
Get all Descriptor and Parameter objects as a list.
Returns:
| Type | Description |
|---|---|
List[DescriptorBase]
|
List of |
get_all_parameters()
Get all Parameter objects as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fittable_parameters()
Get all parameters which can be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_free_parameters()
Get all parameters which are currently free to be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fit_parameters()
This is an alias for get_free_parameters.
To be removed when fully moved to new base classes and minimizer can be changed.
Modules
easydynamics_base
Classes:
| Name | Description |
|---|---|
EasyDynamicsBase |
Base class for all EasyDynamics classes. |
Classes
EasyDynamicsBase(*args, name='MyEasyDynamicsModel', display_name=None, unique_name=None, **kwargs)
Base class for all EasyDynamics classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Positional arguments to pass to the parent class. |
()
|
name
|
str
|
Name of the model. |
'MyEasyDynamicsModel'
|
display_name
|
str | None
|
Display name of the model. If None, the name will be used. |
None
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
**kwargs
|
object
|
Additional keyword arguments to pass to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If name is not a string. |
Methods:
| Name | Description |
|---|---|
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object from a full encoded dictionary. |
__copy__ |
Return a copy of the object. |
Attributes:
| Name | Type | Description |
|---|---|---|
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
Attributes
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
Returns:
| Type | Description |
|---|---|
str
|
The pretty display name. |
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
Methods:
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip
|
Optional[List[str]]
|
List of field names as strings to skip when forming the dictionary. By default, None. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Encoded object containing all information to reform an EasyScience object. |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_dict
|
Dict[str, Any]
|
Dictionary containing the serialized contents (from
|
required |
Returns:
| Type | Description |
|---|---|
NewBase
|
Reformed EasyScience object. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input dictionary does not describe the expected class. |
__copy__()
Return a copy of the object.
easydynamics_list
Classes:
| Name | Description |
|---|---|
EasyDynamicsList |
Base class for all EasyDynamics lists. |
Classes
EasyDynamicsList(*args, protected_types=None, display_name=None, unique_name=None, **kwargs)
Base class for all EasyDynamics lists.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
ProtectedType_ | list[ProtectedType_]
|
Initial items to add to the list. Can be a single item or a list of items. Each item must be an instance of one of the protected types. |
()
|
protected_types
|
list[type[ProtectedType_]] | type[ProtectedType_] | None
|
Types that are allowed in the list. Can be a single EasyDynamicsBase or EasyDynamicsModelBase subclass or a list of them. If None, defaults to [EasyDynamicsBase]. |
None
|
display_name
|
str | None
|
Display name of the list. If None, the name will be used. |
None
|
unique_name
|
str | None
|
Unique name of the list. If None, a unique name will be generated. |
None
|
**kwargs
|
object
|
Additional keyword arguments to pass to the EasyList constructor. |
{}
|
Methods:
| Name | Description |
|---|---|
insert |
Insert an item into the list at a specific index. |
append |
Append an item to the end of the list. |
pop |
Remove and return an item at a specific index or name. |
sort |
Sort the list in place according to the given key function. |
get_names |
Get a list of the names of all items in the list. |
get_duplicate_names |
Get a list of duplicate names in the list. |
__getitem__ |
Get an item by index, slice, or unique_name. |
__setitem__ |
Set an item (or slice of items) in the list. |
__delitem__ |
Delete an item by index, slice, or name. |
to_dict |
Convert the EasyList to a dictionary for serialization. |
from_dict |
Re-create an EasyScience object from a full encoded dictionary. |
__copy__ |
Return a copy of the object. |
get_all_variables |
Get all |
get_all_parameters |
Get all |
get_fittable_parameters |
Get all parameters which can be fitted as a list. |
get_free_parameters |
Get all parameters which are currently free to be fitted as a |
get_fit_parameters |
This is an alias for |
__len__ |
Return the number of items in the collection. |
Attributes:
| Name | Type | Description |
|---|---|---|
version |
int
|
Get the mutation version of the list. |
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
Attributes
version
property
Get the mutation version of the list.
Starts at 0 for a freshly constructed list and is incremented by every mutating operation (append, insert, extend, remove, pop, clear, sort, item assignment and deletion). Consumers can record the version and later compare it to detect in-place mutations without callbacks. Read-only; reading never mutates the list.
Returns:
| Type | Description |
|---|---|
int
|
The current mutation version. |
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
Returns:
| Type | Description |
|---|---|
str
|
The pretty display name. |
Methods:
insert(index, value)
Insert an item into the list at a specific index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int
|
The index at which to insert the item. |
required |
value
|
ProtectedType_
|
The item to insert. Must be an instance of one of the protected types. |
required |
append(value)
Append an item to the end of the list.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
ProtectedType_
|
The item to append. Must be an instance of one of the protected types. |
required |
pop(index=-1)
Remove and return an item at a specific index or name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
index
|
int | str
|
The index or name at which to pop the item. |
-1
|
Returns:
| Type | Description |
|---|---|
ProtectedType_
|
The item that was popped. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If index is not an int or str. |
KeyError
|
If index is a str and no item with that name is found. |
sort(key=None, reverse=False)
Sort the list in place according to the given key function.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
object
|
Mapping function to sort by. |
None
|
reverse
|
bool
|
Whether to reverse the sort order. |
False
|
get_names()
Get a list of the names of all items in the list.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of the names of all items in the list. |
get_duplicate_names()
Get a list of duplicate names in the list.
Returns:
| Type | Description |
|---|---|
list[str]
|
A list of duplicate names in the list. |
__getitem__(idx)
Get an item by index, slice, or unique_name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int | slice | str
|
|
required |
Returns:
| Type | Description |
|---|---|
ProtectedType_ | EasyDynamicsList[ProtectedType_]
|
The item at the specified index or name, or a new EasyDynamicsList if a slice is provided. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If idx is not an int, slice, or str. |
KeyError
|
If idx is a str and no item with that name is found. |
AmbiguousNameError
|
If idx is a str and multiple items with that name are found. |
__setitem__(idx, value)
Set an item (or slice of items) in the list.
Mirrors the duplicate handling of append/insert: assigning an item that is already in the list (to a different position) warns and is ignored.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int | slice
|
The index or slice to assign to. |
required |
value
|
ProtectedType_ | list[ProtectedType_]
|
The new item (or items, for a slice) to assign. Items must be instances of one of the protected types. |
required |
Notes
A TypeError propagates from the type validation or the base assignment if idx or value
has an invalid type, and a ValueError propagates from the base assignment if slice
assignment changes the slice length.
__delitem__(idx)
Delete an item by index, slice, or name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
idx
|
int | slice | str
|
Index, slice, or name of the item to delete. |
required |
Notes
A KeyError propagates from the base deletion if idx is a string that does not match any
item, and a TypeError propagates from it if idx is not an int, slice, or string.
to_dict()
Convert the EasyList to a dictionary for serialization.
Returns:
| Type | Description |
|---|---|
dict
|
Dictionary representation of the EasyList. |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_dict
|
Dict[str, Any]
|
Dictionary containing the serialized contents (from
|
required |
Returns:
| Type | Description |
|---|---|
NewBase
|
Reformed EasyScience object. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If a protected type cannot be imported. |
ValueError
|
If the input dictionary does not describe an EasyList. |
__copy__()
Return a copy of the object.
get_all_variables()
Get all Descriptor and Parameter objects from all
elements that are derived from ModelBase.
For each element that is a ModelBase instance, the element's
own get_all_variables() method is called and the results are
collected into a single flat list.
Returns:
| Type | Description |
|---|---|
List[DescriptorBase]
|
Flat list of all |
get_all_parameters()
Get all Parameter objects as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fittable_parameters()
Get all parameters which can be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_free_parameters()
Get all parameters which are currently free to be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fit_parameters()
This is an alias for get_free_parameters.
To be removed when fully moved to new base classes and minimizer can be changed.
__len__()
Return the number of items in the collection.
easydynamics_modelbase
Classes:
| Name | Description |
|---|---|
EasyDynamicsModelBase |
Base class for all EasyDynamics models. |
Classes
EasyDynamicsModelBase(*args, x_unit='meV', y_unit='dimensionless', name='MyEasyDynamicsModel', display_name=None, unique_name=None, **kwargs)
Base class for all EasyDynamics models.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Positional arguments to pass to the parent class. |
()
|
x_unit
|
str | sc.Unit
|
Unit of the x-axis. |
'meV'
|
y_unit
|
str | sc.Unit
|
Unit of the y-axis. |
'dimensionless'
|
name
|
str
|
Name of the model. |
'MyEasyDynamicsModel'
|
display_name
|
str | None
|
Display name of the model. If None, the name will be used. |
None
|
unique_name
|
str | None
|
Unique name of the model. If None, a unique name will be generated. |
None
|
**kwargs
|
object
|
Additional keyword arguments to pass to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If name is not a string. |
Methods:
| Name | Description |
|---|---|
to_dict |
Convert an EasyScience object into a full dictionary using |
from_dict |
Re-create an EasyScience object with DescriptorNumber attributes |
__copy__ |
Return a copy of the object. |
get_all_variables |
Get all |
get_all_parameters |
Get all |
get_fittable_parameters |
Get all parameters which can be fitted as a list. |
get_free_parameters |
Get all parameters which are currently free to be fitted as a |
get_fit_parameters |
This is an alias for |
Attributes:
| Name | Type | Description |
|---|---|---|
x_unit |
str | sc.Unit | None
|
Get the unit of the x-axis. |
y_unit |
str | sc.Unit | None
|
Get the unit of the model output. |
unique_name |
str
|
Get the unique name of the object. |
display_name |
str
|
Get a pretty display name. |
name |
str
|
Get the name of the model. |
Attributes
x_unit
property
writable
y_unit
property
writable
Get the unit of the model output.
Returns:
| Type | Description |
|---|---|
str | sc.Unit | None
|
The unit of the y-axis. |
unique_name
property
writable
Get the unique name of the object.
display_name
property
writable
Get a pretty display name.
Returns:
| Type | Description |
|---|---|
str
|
The pretty display name. |
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |
Methods:
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skip
|
Optional[List[str]]
|
List of field names as strings to skip when forming the dictionary. By default, None. |
None
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
Encoded object containing all information to reform an EasyScience object. |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object with DescriptorNumber attributes from a full encoded dictionary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
obj_dict
|
Dict[str, Any]
|
Dictionary containing the serialized contents (from
|
required |
Returns:
| Type | Description |
|---|---|
ModelBase
|
Reformed EasyScience object. |
Raises:
| Type | Description |
|---|---|
SyntaxError
|
If a deserialized parameter cannot be attached back to the class definition. |
ValueError
|
If the input dictionary does not describe the expected class. |
__copy__()
Return a copy of the object.
get_all_variables()
Get all Descriptor and Parameter objects as a list.
Returns:
| Type | Description |
|---|---|
List[DescriptorBase]
|
List of |
get_all_parameters()
Get all Parameter objects as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fittable_parameters()
Get all parameters which can be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_free_parameters()
Get all parameters which are currently free to be fitted as a list.
Returns:
| Type | Description |
|---|---|
List[Parameter]
|
List of |
get_fit_parameters()
This is an alias for get_free_parameters.
To be removed when fully moved to new base classes and minimizer can be changed.
name_mixin
Classes:
| Name | Description |
|---|---|
NameMixin |
Mixin class to add name functionality to EasyDynamics classes. |
Classes
NameMixin(*args, name='MyEasyDynamicsModel', **kwargs)
Mixin class to add name functionality to EasyDynamics classes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args
|
object
|
Positional arguments to pass to the parent class. |
()
|
name
|
str
|
Name of the model. |
'MyEasyDynamicsModel'
|
**kwargs
|
object
|
Keyword arguments to pass to the parent class. |
{}
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If name is not a string. |
Attributes:
| Name | Type | Description |
|---|---|---|
name |
str
|
Get the name of the model. |
Attributes
name
property
writable
Get the name of the model.
Returns:
| Type | Description |
|---|---|
str
|
The name of the model. |