base_classes
based_base
BasedBase
Bases: SerializerComponent
Source code in src/easyscience/base_classes/based_base.py
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
__copy__()
Return a copy of the object.
Source code in src/easyscience/base_classes/based_base.py
199 200 201 202 203 | |
__dir__()
This creates auto-completion and helps out in iPython notebooks.
:return: list of function and parameter names for auto- completion
Source code in src/easyscience/base_classes/based_base.py
189 190 191 192 193 194 195 196 197 | |
__reduce__()
Make the class picklable. Due to the nature of the dynamic class definitions special measures need to be taken.
:return: Tuple consisting of how to make the object :rtype: tuple
Source code in src/easyscience/base_classes/based_base.py
56 57 58 59 60 61 62 63 64 65 | |
as_dict(skip=None)
Convert an object into a full dictionary using
SerializerDict. This is a shortcut for
obj.encode(encoder=SerializerDict)
:param skip: List of field names as strings to skip when forming the dictionary :return: encoded object containing all information to reform an EasyScience object.
Source code in src/easyscience/base_classes/based_base.py
205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
generate_bindings()
Generate or re-generate bindings to an interface (if exists)
:raises: AttributeError
Source code in src/easyscience/base_classes/based_base.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | |
get_fit_parameters()
Get all objects which can be fitted (and are not fixed) as a list.
:return: List of Parameter objects which can be used in fitting.
Source code in src/easyscience/base_classes/based_base.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 | |
get_parameters()
Get all parameter objects as a list.
:return: List of Parameter objects.
Source code in src/easyscience/base_classes/based_base.py
148 149 150 151 152 153 154 155 156 157 158 159 | |
interface
property
writable
Get the current interface of the object.
name
property
writable
Get the common name of the object.
:return: Common name of the object
switch_interface(new_interface_name)
Switch or create a new interface.
Source code in src/easyscience/base_classes/based_base.py
139 140 141 142 143 144 145 146 | |
unique_name
property
writable
Get the unique name of the object.
collection_base
CollectionBase
Bases: BasedBase, MutableSequence
This is the base class for which all higher level classes are built off of.
NOTE: This object is serializable only if parameters are supplied as:
ObjBase(a=value, b=value). For Parameter or Descriptor objects we can
cheat with ObjBase(*[Descriptor(...), Parameter(...), ...]).
Source code in src/easyscience/base_classes/collection_base.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
__delitem__(key)
Try to delete an idem by key.
:param key: :type key: :return: :rtype:
Source code in src/easyscience/base_classes/collection_base.py
185 186 187 188 189 190 191 192 193 194 195 196 | |
__getitem__(idx)
Get an item in the collection based on its index.
:param idx: index or slice of the collection.
:type idx: Union[int, slice]
:return: Object at index idx
:rtype: Union[Parameter, Descriptor, ObjBase, 'CollectionBase']
Source code in src/easyscience/base_classes/collection_base.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |
__init__(name, *args, interface=None, unique_name=None, **kwargs)
Set up the base collection class.
:param name: Name of this object :type name: str :param args: selection of :param _kwargs: Fields which this class should contain :type _kwargs: dict
Source code in src/easyscience/base_classes/collection_base.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | |
__len__()
Get the number of items in this collection.
:return: Number of items in this collection. :rtype: int
Source code in src/easyscience/base_classes/collection_base.py
198 199 200 201 202 203 204 | |
__setitem__(key, value)
Set an item via it's index.
:param key: Index in self. :type key: int :param value: Value which index key should be set to. :type value: Any
Source code in src/easyscience/base_classes/collection_base.py
156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | |
data
property
The data function returns a tuple of the keyword arguments passed to the constructor. This is useful for when you need to pass in a dictionary of data to other functions, such as with matplotlib's plot function.
:param self: Access attributes of the class within the method :return: The values of the attributes in a tuple :doc-author: Trelent
insert(index, value)
Insert an object into the collection at an index.
:param index: Index for EasyScience object to be inserted. :type index: int :param value: Object to be inserted. :type value: Union[BasedBase, DescriptorBase, NewBase] :return: None :rtype: None
Source code in src/easyscience/base_classes/collection_base.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
sort(mapping, reverse=False)
Sort the collection according to the given mapping.
:param mapping: mapping function to sort the collection. i.e. lambda parameter: parameter.value :type mapping: Callable :param reverse: Reverse the sorting. :type reverse: bool
Source code in src/easyscience/base_classes/collection_base.py
236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 | |
easy_list
EasyList
Bases: NewBase, MutableSequence[ProtectedType_]
Source code in src/easyscience/base_classes/easy_list.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
__delitem__(idx)
Delete an item by index, slice, or name.
:param idx: Index, slice, or name of item to delete
Source code in src/easyscience/base_classes/easy_list.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
__getitem__(idx)
__getitem__(idx: int) -> ProtectedType_
__getitem__(idx: slice) -> 'EasyList[ProtectedType_]'
__getitem__(idx: str) -> ProtectedType_
Get an item by index, slice, or unique_name.
:param idx: Index, slice, or unique_name of the item :return: The item or a new EasyList for slices
Source code in src/easyscience/base_classes/easy_list.py
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
__init__(*args, protected_types=None, unique_name=None, display_name=None, **kwargs)
Initialize the EasyList.
:param args: Initial items to add to the list :param protected_types: Types that are allowed in the list. Can be a single NewBase subclass or a list of them. If None, defaults to [NewBase]. :param unique_name: Optional unique name for the list :param display_name: Optional display name for the list
Source code in src/easyscience/base_classes/easy_list.py
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
__len__()
Return the number of items in the collection.
Source code in src/easyscience/base_classes/easy_list.py
163 164 165 | |
__setitem__(idx, value)
__setitem__(idx: int, value: ProtectedType_) -> None
__setitem__(
idx: slice, value: Iterable[ProtectedType_]
) -> None
Set an item at an index.
:param idx: Index to set :param value: New value
Source code in src/easyscience/base_classes/easy_list.py
107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 | |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
:param obj_dict: dictionary containing the serialized contents (from SerializerDict) of an EasyScience object
:return: Reformed EasyScience object
Source code in src/easyscience/base_classes/easy_list.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 | |
insert(index, value)
Insert an item at an index.
:param index: Index to insert at :param value: Item to insert
Source code in src/easyscience/base_classes/easy_list.py
167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
pop(index=-1)
Remove and return an item at the given index or unique_name.
:param index: Index or unique_name of the item to remove :return: The removed item
Source code in src/easyscience/base_classes/easy_list.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 | |
sort(key=None, reverse=False)
Sort the collection according to the given key function.
:param key: Mapping function to sort by :param reverse: Whether to reverse the sort
Source code in src/easyscience/base_classes/easy_list.py
209 210 211 212 213 214 215 | |
to_dict()
Convert the EasyList to a dictionary for serialization.
:return: Dictionary representation of the EasyList
Source code in src/easyscience/base_classes/easy_list.py
245 246 247 248 249 250 251 252 253 254 255 256 257 | |
model_base
ModelBase
Bases: NewBase
This is the base class for all model classes in EasyScience. It provides methods to get parameters for fitting and analysis as well as proper serialization/deserialization for DescriptorNumber/Parameter attributes.
It assumes that Parameters/DescriptorNumbers are assigned as properties with the getters returning the parameter but the setter only setting the value of the parameter. e.g.
@property
def my_param(self) -> Parameter:
return self._my_param
@my_param.setter
def my_param(self, new_value: float) -> None:
self._my_param.value = new_value
Source code in src/easyscience/base_classes/model_base.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
from_dict(obj_dict)
classmethod
Re-create an EasyScience object with DescriptorNumber attributes from a full encoded dictionary.
:param obj_dict: dictionary containing the serialized contents (from SerializerDict) of an EasyScience object
:return: Reformed EasyScience object
Source code in src/easyscience/base_classes/model_base.py
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | |
get_all_parameters()
Get all Parameter objects as a list.
:return: List of Parameter objects.
Source code in src/easyscience/base_classes/model_base.py
60 61 62 63 64 65 | |
get_all_variables()
Get all Descriptor and Parameter objects as a list.
:return: List of Descriptor and Parameter objects.
Source code in src/easyscience/base_classes/model_base.py
46 47 48 49 50 51 52 53 54 55 56 57 58 | |
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.
Source code in src/easyscience/base_classes/model_base.py
82 83 84 85 86 87 88 | |
get_fittable_parameters()
Get all parameters which can be fitted as a list.
:return: List of Parameter objects.
Source code in src/easyscience/base_classes/model_base.py
67 68 69 70 71 72 | |
get_free_parameters()
Get all parameters which are currently free to be fitted as a list.
:return: List of Parameter objects.
Source code in src/easyscience/base_classes/model_base.py
74 75 76 77 78 79 80 | |
new_base
NewBase
This is the new base class for easyscience objects.
It provides serialization capabilities as well as unique naming and display naming.
Source code in src/easyscience/base_classes/new_base.py
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
__copy__()
Return a copy of the object.
Source code in src/easyscience/base_classes/new_base.py
145 146 147 148 149 | |
__dir__()
This creates auto-completion and helps out in iPython notebooks.
:return: list of function and parameter names for auto- completion
Source code in src/easyscience/base_classes/new_base.py
135 136 137 138 139 140 141 142 143 | |
display_name
property
writable
Get a pretty display name.
:return: The pretty display name.
from_dict(obj_dict)
classmethod
Re-create an EasyScience object from a full encoded dictionary.
:param obj_dict: dictionary containing the serialized contents (from SerializerDict) of an EasyScience object
:return: Reformed EasyScience object
Source code in src/easyscience/base_classes/new_base.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
to_dict(skip=None)
Convert an EasyScience object into a full dictionary using
SerializerBases generic convert_to_dict method.
:param skip: List of field names as strings to skip when forming the dictionary :return: encoded object containing all information to reform an EasyScience object.
Source code in src/easyscience/base_classes/new_base.py
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
unique_name
property
writable
Get the unique name of the object.
obj_base
ObjBase
Bases: BasedBase
This is the base class for which all higher level classes are built off of.
NOTE: This object is serializable only if parameters are supplied as:
ObjBase(a=value, b=value). For Parameter or Descriptor objects we can
cheat with ObjBase(*[Descriptor(...), Parameter(...), ...]).
Source code in src/easyscience/base_classes/obj_base.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 | |
__init__(name, unique_name=None, *args, **kwargs)
Set up the base class.
:param name: Name of this object :param args: Any arguments? :param kwargs: Fields which this class should contain
Source code in src/easyscience/base_classes/obj_base.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | |