ParamsDict
Bases: dict
A dictionary subclass that ensures all keys are strings and supports multiple key- value assignments at once, with validation against a list of valid keys.
This class is designed to be used for passing parameters to HTTP requests and extends the base dictionary class, ensuring that insertion order is preserved.
Source code in yeastdnnexplorer/interface/ParamsDict.py
4 5 6 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 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 |
|
valid_keys: list[str]
property
writable
¶
Get the list of valid keys.
__delitem__(key)
¶
Delete a parameter by key.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The parameter key. |
required |
Raises:
Type | Description |
---|---|
KeyError
|
If |
Source code in yeastdnnexplorer/interface/ParamsDict.py
79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
__getitem__(key)
¶
Get a parameter value or a new ParamsDict with specified keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str | list[str]
|
The parameter key or a list of parameter keys. |
required |
Returns:
Type | Description |
---|---|
any | ParamsDict
|
The parameter value or a new ParamsDict with the specified keys. |
Raises:
Type | Description |
---|---|
KeyError
|
If |
Source code in yeastdnnexplorer/interface/ParamsDict.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
|
__init__(params={}, valid_keys=[])
¶
Initialize the ParamsDict with optional initial parameters and valid keys.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
params |
dict[str, Any]
|
A dictionary of initial parameters. All keys must be strings. |
{}
|
valid_keys |
list[str]
|
A list of valid keys for validation. |
[]
|
Raises:
Type | Description |
---|---|
ValueError
|
If |
Source code in yeastdnnexplorer/interface/ParamsDict.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
__repr__()
¶
Return a string representation of the ParamsDict.
Returns:
Type | Description |
---|---|
str
|
A string representation of the ParamsDict. |
Source code in yeastdnnexplorer/interface/ParamsDict.py
93 94 95 96 97 98 99 100 101 |
|
__setitem__(key, value)
¶
Set a parameter value or multiple parameter values.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str | list[str]
|
The parameter key or a list of parameter keys. |
required |
value |
Any | list[Any]
|
The parameter value or a list of parameter values. |
required |
Raises:
Type | Description |
---|---|
ValueError
|
If the length of |
KeyError
|
If |
Source code in yeastdnnexplorer/interface/ParamsDict.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 |
|
__str__()
¶
Return a human-readable string representation of the ParamsDict.
Returns:
Type | Description |
---|---|
str
|
A human-readable string representation of the ParamsDict. |
Source code in yeastdnnexplorer/interface/ParamsDict.py
103 104 105 106 107 108 109 110 111 |
|
as_dict()
¶
Convert the ParamsDict to a standard dictionary.
Returns:
Type | Description |
---|---|
dict
|
A standard dictionary with the same items as the ParamsDict. |
Source code in yeastdnnexplorer/interface/ParamsDict.py
130 131 132 133 134 135 136 137 138 |
|
update(*args, **kwargs)
¶
Update the ParamsDict with the key/value pairs from other, overwriting existing keys.
Source code in yeastdnnexplorer/interface/ParamsDict.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
|