Reference class
ReferenceClass
Class whose attributes can by references to other attributes
Source code in quam/utils/reference_class.py
7 8 9 10 11 12 13 14 15 16 17 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 |
|
__post_init__()
Post init function
Source code in quam/utils/reference_class.py
12 13 14 |
|
_get_referenced_value(attr)
Get the value of an attribute by reference
This function should generally be overwritten by subclasses
Source code in quam/utils/reference_class.py
16 17 18 19 20 21 |
|
_is_reference(attr)
Check if an attribute is a reference
This function should generally be overwritten by subclasses
Source code in quam/utils/reference_class.py
23 24 25 26 27 28 |
|
_is_valid_setattr(attr, value, error_on_False=False)
Check if an attribute can be set to a value
This will be called by setattr to check if the attribute can be set to the given value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
attr
|
str
|
The attribute to set |
required |
value
|
Any
|
The value to set the attribute to |
required |
error_on_False
|
bool
|
If True, raise an error if the attribute cannot be set to the value. If False, return False if the attribute cannot be set to the value. |
False
|
Returns:
Type | Description |
---|---|
bool
|
True if |
bool
|
|
bool
|
|
bool
|
|
bool
|
|
bool
|
False otherwise, in particular if the previous value is a reference and the |
bool
|
new value is not and is also not None. |
Raises:
Type | Description |
---|---|
ValueError
|
If error_on_False is True and the attribute cannot be set to the value. |
Source code in quam/utils/reference_class.py
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 |
|
get_unreferenced_value(attr)
Get the raw value of an attribute, returning the reference if it is one
Source code in quam/utils/reference_class.py
30 31 32 |
|