utils¶
ANONYMOUS_ELEMENTS = tuple(itertools.islice(anonymous_element_generator(), 150))
module-attribute
¶
Returns the first 150 values of the anonymous element generator.
ATOMIC_NUMBERS = {}
module-attribute
¶
CHEMICAL_FORMULA_REGEXP = '^([A-Z][a-z]?([2-9]|[1-9]\\d+)?)+$'
module-attribute
¶
CHEMICAL_SYMBOLS = ['H', 'He', 'Li', 'Be', 'B', 'C', 'N', 'O', 'F', 'Ne', 'Na', 'Mg', 'Al', 'Si', 'P', 'S', 'Cl', 'Ar', 'K', 'Ca', 'Sc', 'Ti', 'V', 'Cr', 'Mn', 'Fe', 'Co', 'Ni', 'Cu', 'Zn', 'Ga', 'Ge', 'As', 'Se', 'Br', 'Kr', 'Rb', 'Sr', 'Y', 'Zr', 'Nb', 'Mo', 'Tc', 'Ru', 'Rh', 'Pd', 'Ag', 'Cd', 'In', 'Sn', 'Sb', 'Te', 'I', 'Xe', 'Cs', 'Ba', 'La', 'Ce', 'Pr', 'Nd', 'Pm', 'Sm', 'Eu', 'Gd', 'Tb', 'Dy', 'Ho', 'Er', 'Tm', 'Yb', 'Lu', 'Hf', 'Ta', 'W', 'Re', 'Os', 'Ir', 'Pt', 'Au', 'Hg', 'Tl', 'Pb', 'Bi', 'Po', 'At', 'Rn', 'Fr', 'Ra', 'Ac', 'Th', 'Pa', 'U', 'Np', 'Pu', 'Am', 'Cm', 'Bk', 'Cf', 'Es', 'Fm', 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og']
module-attribute
¶
EXTRA_SYMBOLS = ['X', 'vacancy']
module-attribute
¶
OPTIMADE_SCHEMA_EXTENSION_KEYS = ['support', 'queryable', 'unit', 'sortable']
module-attribute
¶
OPTIMADE_SCHEMA_EXTENSION_PREFIX = 'x-optimade-'
module-attribute
¶
SemanticVersion
¶
A custom type for a semantic version, using the recommended semver regexp from https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string.
Source code in optimade/models/utils.py
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 |
|
regex = re.compile('^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-((?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\\.(?:0|[1-9]\\d*|\\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\\+([0-9a-zA-Z-]+(?:\\.[0-9a-zA-Z-]+)*))?$')
class-attribute
¶
__get_validators__()
classmethod
¶
Source code in optimade/models/utils.py
163 164 165 |
|
__modify_schema__(field_schema)
classmethod
¶
Source code in optimade/models/utils.py
167 168 169 170 171 172 |
|
base_version()
property
¶
The base version string without patch and metadata info.
Source code in optimade/models/utils.py
214 215 216 217 |
|
build_metadata()
property
¶
The build metadata.
Source code in optimade/models/utils.py
209 210 211 212 |
|
major()
property
¶
The major version number.
Source code in optimade/models/utils.py
189 190 191 192 |
|
minor()
property
¶
The minor version number.
Source code in optimade/models/utils.py
194 195 196 197 |
|
patch()
property
¶
The patch version number.
Source code in optimade/models/utils.py
199 200 201 202 |
|
prerelease()
property
¶
The pre-release tag.
Source code in optimade/models/utils.py
204 205 206 207 |
|
validate(v)
classmethod
¶
Source code in optimade/models/utils.py
174 175 176 177 178 179 180 181 182 |
|
StrictFieldInfo
¶
Wraps the standard pydantic FieldInfo
in order
to prefix any custom keys from StrictField
.
Source code in optimade/models/utils.py
37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
__init__(*args, **kwargs)
¶
Source code in optimade/models/utils.py
43 44 45 46 47 48 49 |
|
SupportLevel
¶
OPTIMADE property/field support levels
Source code in optimade/models/utils.py
29 30 31 32 33 34 |
|
OptimadeField(*args, support=None, queryable=None, unit=None, **kwargs)
¶
A wrapper around pydantic.Field
that adds OPTIMADE-specific
field paramters queryable
, support
and unit
, indicating
the corresponding support level in the specification and the
physical unit of the field.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
support |
Optional[SupportLevel]
|
The support level of the field itself, i.e. whether the field can be null or omitted by an implementation. |
None
|
queryable |
Optional[SupportLevel]
|
The support level corresponding to the queryablility of this field. |
None
|
unit |
Optional[str]
|
A string describing the unit of the field. |
None
|
Returns:
Type | Description |
---|---|
Field
|
The pydantic field with extra validation provided by |
Source code in optimade/models/utils.py
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 |
|
StrictField(*args, description=None, **kwargs)
¶
A wrapper around pydantic.Field
that does the following:
- Forbids any "extra" keys that would be passed to
pydantic.Field
, except those used elsewhere to modify the schema in-place, e.g. "uniqueItems", "pattern" and those added by OptimadeField, e.g. "unit", "queryable" and "sortable". - Emits a warning when no description is provided.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args |
Any
|
Positional arguments passed through to |
()
|
description |
str
|
The description of the |
None
|
**kwargs |
Any
|
Extra keyword arguments to be passed to |
{}
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If |
Returns:
Type | Description |
---|---|
StrictFieldInfo
|
The pydantic |
Source code in optimade/models/utils.py
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 |
|
StrictPydanticField(*args, **kwargs)
¶
Wrapper for Field
that uses StrictFieldInfo
instead of
the pydantic FieldInfo
.
Source code in optimade/models/utils.py
52 53 54 55 56 57 58 |
|
anonymous_element_generator()
¶
Generator that yields the next symbol in the A, B, Aa, ... Az naming scheme.
Source code in optimade/models/utils.py
220 221 222 223 224 225 226 227 228 |
|