custom_types
Additional type definitions and hints for Pydantic models.
BaseModel2DTM
Bases: BaseModel
Implementation of a Pydantic BaseModel with additional, useful methods.
Currently, only additional import/export methods are implemented and this
class can effectively be treated as the pydantic.BaseModel
class.
Attributes:
Name | Type | Description |
---|---|---|
None |
|
Methods:
Name | Description |
---|---|
from_json |
Load a BaseModel2DTM subclass from a serialized JSON file. |
from_yaml |
Load a BaseModel2DTM subclass from a serialized YAML file. |
to_json |
Serialize the BaseModel2DTM subclass to a JSON file. |
to_yaml |
Serialize the BaseModel2DTM subclass to a YAML file. |
Source code in src/leopard_em/pydantic_models/custom_types.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 |
|
from_json(json_path)
classmethod
Load a MatchTemplateManager from a serialized JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_path
|
str | PathLike
|
Path to the JSON file to load. |
required |
Returns:
Type | Description |
---|---|
BaseModel2DTM
|
Instance of the BaseModel2DTM subclass loaded from the JSON file. |
Source code in src/leopard_em/pydantic_models/custom_types.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
from_yaml(yaml_path)
classmethod
Load a MatchTemplateManager from a serialized YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_path
|
str | PathLike
|
Path to the YAML file to load. |
required |
Returns:
Type | Description |
---|---|
BaseModel2DTM
|
Instance of the BaseModel2DTM subclass loaded from the YAML file. |
Source code in src/leopard_em/pydantic_models/custom_types.py
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
to_json(json_path)
Serialize the MatchTemplateManager to a JSON file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
json_path
|
str | PathLike
|
Path to the JSON file to save. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/leopard_em/pydantic_models/custom_types.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
|
to_yaml(yaml_path)
Serialize the MatchTemplateManager to a YAML file.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
yaml_path
|
str | PathLike
|
Path to the YAML file to save. |
required |
Returns:
Type | Description |
---|---|
None
|
|
Source code in src/leopard_em/pydantic_models/custom_types.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
|