Serialization
serialization
DecoratorDict
Bases: UserDict[Hashable, Any]
Hashable decorator for a dictionary.
Source code in kfactory/serialization.py
40 41 42 43 44 45 46 47 48 | |
__hash__
__hash__() -> int
Hash the dictionary.
Source code in kfactory/serialization.py
43 44 45 | |
DecoratorList
Bases: UserList[Any]
Hashable decorator for a list.
Source code in kfactory/serialization.py
29 30 31 32 33 34 35 36 37 | |
__hash__
__hash__() -> int
Hash the list.
Source code in kfactory/serialization.py
32 33 34 | |
cell_name_hash
cell_name_hash(name: str) -> str
Return 8-char hash of a cell name.
Source code in kfactory/serialization.py
84 85 86 | |
check_metadata_type
check_metadata_type(value: Any) -> MetaData
Recursively check an info value whether it can be stored.
Source code in kfactory/serialization.py
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 | |
clean_dict
clean_dict(d: dict[str, Any]) -> dict[str, Any]
Cleans dictionary recursively.
Source code in kfactory/serialization.py
51 52 53 54 55 56 | |
clean_name
clean_name(name: str) -> str
Ensures that gds cells are composed of [a-zA-Z0-9_-].
only a few characters are currently replaced.
This function has been updated only on case-by-case basis
Source code in kfactory/serialization.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
clean_value
clean_value(
value: float
| float64
| dict[Any, Any]
| AnyKCell
| Callable[..., Any],
) -> str
Makes sure a value is representable in a limited character_space.
Source code in kfactory/serialization.py
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 | |
convert_metadata_type
convert_metadata_type(value: Any) -> MetaData
Recursively clean up a MetaData for KCellSettings.
Source code in kfactory/serialization.py
218 219 220 221 222 223 224 225 226 227 228 229 230 | |
deserialize_setting
deserialize_setting(setting: JSONSerializable) -> MetaData
Deserialize a setting.
Source code in kfactory/serialization.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 | |
dict2name
dict2name(
prefix: str | None = None, **kwargs: dict[str, Any]
) -> str
Returns name from a dict.
Source code in kfactory/serialization.py
207 208 209 210 211 212 213 214 215 | |
get_cell_name
get_cell_name(
cell_type: str,
max_cellname_length: int | None = None,
**kwargs: dict[str, Any],
) -> str
Convert a cell to a string.
Source code in kfactory/serialization.py
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 | |
hashable_to_original
hashable_to_original(
udl: DecoratorDict,
) -> dict[Hashable, Any]
hashable_to_original(udl: DecoratorList) -> list[Hashable]
hashable_to_original(udl: Any) -> Any
hashable_to_original(
udl: DecoratorDict | DecoratorList | Any,
) -> dict[str, Any] | list[Any] | Any
Convert DecoratorDict to dict.
Source code in kfactory/serialization.py
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |
join_first_letters
join_first_letters(name: str) -> str
Join the first letter of a name separated with underscores.
Example::
"TL" == join_first_letters("taper_length")
Source code in kfactory/serialization.py
197 198 199 200 201 202 203 204 | |
serialize_setting
serialize_setting(setting: MetaData) -> JSONSerializable
Serialize a setting.
Source code in kfactory/serialization.py
252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
to_hashable
to_hashable(d: dict[Hashable, Any]) -> DecoratorDict
to_hashable(d: list[Any]) -> DecoratorList
to_hashable(
d: dict[Hashable, Any] | list[Any],
) -> DecoratorDict | DecoratorList
Convert a dict to a DecoratorDict.
Source code in kfactory/serialization.py
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | |