OPTIMADE Data Models¶
This page provides documentation for the optimade.models
submodule, where all the OPTIMADE (and JSON:API)-defined data models are located.
For example, the three OPTIMADE entry types, structures
, references
and links
, are defined primarily through the corresponding attribute models:
As well as validating data types when creating instances of these models, this package defines several OPTIMADE-specific validators that ensure consistency between fields (e.g., the value of nsites
matches the number of positions provided in cartesian_site_positions
).
ATOMIC_NUMBERS = {}
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
¶
Vector3D = Annotated[list[Annotated[float, BeforeValidator(float)]], Field(min_length=3, max_length=3)]
module-attribute
¶
Assembly
¶
Bases: BaseModel
A description of groups of sites that are statistically correlated.
- Examples (for each entry of the assemblies list):
{"sites_in_groups": [[0], [1]], "group_probabilities: [0.3, 0.7]}
: the first site and the second site never occur at the same time in the unit cell. Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.{"sites_in_groups": [[1,2], [3]], "group_probabilities: [0.3, 0.7]}
: the second and third site are either present together or not present; they form the first group of atoms for this assembly. The second group is formed by the fourth site. Sites of the first group (the second and the third) are never present at the same time as the fourth site. 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent).
Source code in optimade/models/structures.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
group_probabilities
instance-attribute
¶
sites_in_groups
instance-attribute
¶
check_self_consistency()
¶
Source code in optimade/models/structures.py
265 266 267 268 269 270 271 272 273 |
|
validate_sites_in_groups(value)
classmethod
¶
Source code in optimade/models/structures.py
253 254 255 256 257 258 259 260 261 262 263 |
|
Attributes
¶
Bases: BaseModel
Members of the attributes object ("attributes") represent information about the resource object in which it's defined. The keys for Attributes MUST NOT be: relationships links id type
Source code in optimade/models/jsonapi.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
AvailableApiVersion
¶
Bases: BaseModel
A JSON object containing information about an available API version
Source code in optimade/models/baseinfo.py
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 |
|
url
instance-attribute
¶
version
instance-attribute
¶
crosscheck_url_and_version()
¶
Check that URL version and API version are compatible.
Source code in optimade/models/baseinfo.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
url_must_be_versioned_base_Url(value)
classmethod
¶
The URL must be a versioned base URL
Source code in optimade/models/baseinfo.py
38 39 40 41 42 43 44 45 46 47 |
|
BaseInfoAttributes
¶
Bases: BaseModel
Attributes for Base URL Info endpoint
Source code in optimade/models/baseinfo.py
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 |
|
api_version
instance-attribute
¶
available_api_versions
instance-attribute
¶
available_endpoints
instance-attribute
¶
entry_types_by_format
instance-attribute
¶
formats = ['json']
class-attribute
instance-attribute
¶
is_index = False
class-attribute
instance-attribute
¶
formats_and_endpoints_must_be_valid()
¶
Source code in optimade/models/baseinfo.py
112 113 114 115 116 117 118 119 120 121 122 |
|
BaseInfoResource
¶
Bases: Resource
Source code in optimade/models/baseinfo.py
125 126 127 128 |
|
attributes
instance-attribute
¶
id = '/'
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'info'
class-attribute
instance-attribute
¶
BaseRelationshipMeta
¶
Bases: Meta
Specific meta field for base relationship resource
Source code in optimade/models/optimade_json.py
405 406 407 408 409 410 411 412 413 |
|
BaseRelationshipResource
¶
Bases: BaseResource
Minimum requirements to represent a relationship resource
Source code in optimade/models/optimade_json.py
416 417 418 419 420 421 422 423 424 |
|
BaseResource
¶
Bases: BaseModel
Minimum requirements to represent a Resource
Source code in optimade/models/jsonapi.py
218 219 220 221 222 223 224 |
|
DataType
¶
Bases: Enum
Optimade Data types
See the section "Data types" in the OPTIMADE API specification for more information.
Source code in optimade/models/optimade_json.py
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 |
|
BOOLEAN = 'boolean'
class-attribute
instance-attribute
¶
DICTIONARY = 'dictionary'
class-attribute
instance-attribute
¶
FLOAT = 'float'
class-attribute
instance-attribute
¶
INTEGER = 'integer'
class-attribute
instance-attribute
¶
LIST = 'list'
class-attribute
instance-attribute
¶
STRING = 'string'
class-attribute
instance-attribute
¶
TIMESTAMP = 'timestamp'
class-attribute
instance-attribute
¶
UNKNOWN = 'unknown'
class-attribute
instance-attribute
¶
from_json_type(json_type)
classmethod
¶
Get OPTIMADE data type from a named JSON type
Source code in optimade/models/optimade_json.py
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 |
|
from_python_type(python_type)
classmethod
¶
Get OPTIMADE data type from a Python type
Source code in optimade/models/optimade_json.py
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 |
|
get_values()
classmethod
¶
Get OPTIMADE data types (enum values) as a (sorted) list
Source code in optimade/models/optimade_json.py
47 48 49 50 |
|
EntryInfoProperty
¶
Bases: BaseModel
Source code in optimade/models/entries.py
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 |
|
EntryInfoResource
¶
Bases: BaseModel
Source code in optimade/models/entries.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
EntryInfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
58 59 60 61 62 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
EntryRelationships
¶
Bases: Relationships
This model wraps the JSON API Relationships to include type-specific top level keys.
Source code in optimade/models/entries.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
references = None
class-attribute
instance-attribute
¶
structures = None
class-attribute
instance-attribute
¶
check_illegal_relationships_fields()
¶
Source code in optimade/models/jsonapi.py
296 297 298 299 300 301 302 303 304 |
|
EntryResource
¶
Bases: Resource
The base model for an entry resource.
Source code in optimade/models/entries.py
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type
instance-attribute
¶
EntryResourceAttributes
¶
Bases: Attributes
Contains key-value pairs representing the entry's properties.
Source code in optimade/models/entries.py
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 |
|
immutable_id = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
EntryResponseMany
¶
Bases: Success
Source code in optimade/models/responses.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
EntryResponseOne
¶
Bases: Success
Source code in optimade/models/responses.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
ErrorLinks
¶
Bases: BaseModel
A Links object specific to Error objects
Source code in optimade/models/jsonapi.py
112 113 114 115 116 117 118 119 120 |
|
about = None
class-attribute
instance-attribute
¶
ErrorResponse
¶
Bases: Response
errors MUST be present and data MUST be skipped
Source code in optimade/models/responses.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
data = None
class-attribute
instance-attribute
¶
errors
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
data_must_be_skipped()
¶
Source code in optimade/models/responses.py
45 46 47 48 49 |
|
either_data_meta_or_errors_must_be_set()
¶
Source code in optimade/models/jsonapi.py
403 404 405 406 407 408 409 410 411 412 |
|
ErrorSource
¶
Bases: BaseModel
an object containing references to the source of the error
Source code in optimade/models/jsonapi.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
Implementation
¶
Bases: BaseModel
Information on the server implementation
Source code in optimade/models/optimade_json.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
homepage = None
class-attribute
instance-attribute
¶
issue_tracker = None
class-attribute
instance-attribute
¶
maintainer = None
class-attribute
instance-attribute
¶
name = None
class-attribute
instance-attribute
¶
source_url = None
class-attribute
instance-attribute
¶
version = None
class-attribute
instance-attribute
¶
ImplementationMaintainer
¶
Bases: BaseModel
Details about the maintainer of the implementation
Source code in optimade/models/optimade_json.py
231 232 233 234 235 236 |
|
email
instance-attribute
¶
IndexInfoAttributes
¶
Bases: BaseInfoAttributes
Attributes for Base URL Info endpoint for an Index Meta-Database
Source code in optimade/models/index_metadb.py
17 18 19 20 21 22 23 24 25 |
|
api_version
instance-attribute
¶
available_api_versions
instance-attribute
¶
available_endpoints
instance-attribute
¶
entry_types_by_format
instance-attribute
¶
formats = ['json']
class-attribute
instance-attribute
¶
is_index = True
class-attribute
instance-attribute
¶
formats_and_endpoints_must_be_valid()
¶
Source code in optimade/models/baseinfo.py
112 113 114 115 116 117 118 119 120 121 122 |
|
IndexInfoResource
¶
Bases: BaseInfoResource
Index Meta-Database Base URL Info endpoint resource
Source code in optimade/models/index_metadb.py
46 47 48 49 50 51 52 53 54 55 56 57 |
|
attributes
instance-attribute
¶
id = '/'
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships
instance-attribute
¶
type = 'info'
class-attribute
instance-attribute
¶
IndexInfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
52 53 54 55 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
IndexRelationship
¶
Bases: BaseModel
Index Meta-Database relationship
Source code in optimade/models/index_metadb.py
34 35 36 37 38 39 40 41 42 43 |
|
data
instance-attribute
¶
InfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
65 66 67 68 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
JsonApi
¶
Bases: BaseModel
An object describing the server's implementation
Source code in optimade/models/jsonapi.py
58 59 60 61 62 63 64 65 66 |
|
Link
¶
Bases: BaseModel
A link MUST be represented as either: a string containing the link's URL or a link object.
Source code in optimade/models/jsonapi.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
LinksResource
¶
Bases: EntryResource
A Links endpoint resource object
Source code in optimade/models/links.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'links'
class-attribute
instance-attribute
¶
relationships_must_not_be_present()
¶
Source code in optimade/models/links.py
116 117 118 119 120 |
|
LinksResourceAttributes
¶
Bases: Attributes
Links endpoint resource object attributes
Source code in optimade/models/links.py
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 |
|
aggregate = Aggregate.OK
class-attribute
instance-attribute
¶
base_url
instance-attribute
¶
description
instance-attribute
¶
homepage
instance-attribute
¶
link_type
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
name
instance-attribute
¶
no_aggregate_reason = None
class-attribute
instance-attribute
¶
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
LinksResponse
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
108 109 110 111 112 113 114 115 116 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
Meta
¶
Bases: BaseModel
Non-standard meta-information that can not be represented as an attribute or relationship.
Source code in optimade/models/jsonapi.py
35 36 37 38 |
|
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
OptimadeError
¶
Bases: Error
detail MUST be present
Source code in optimade/models/optimade_json.py
128 129 130 131 132 133 134 135 136 |
|
code = None
class-attribute
instance-attribute
¶
detail
instance-attribute
¶
id = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
__hash__()
¶
Source code in optimade/models/jsonapi.py
191 192 |
|
Periodicity
¶
Bases: IntEnum
Integer enumeration of dimension_types values
Source code in optimade/models/structures.py
48 49 50 51 52 |
|
Person
¶
Bases: BaseModel
A person, i.e., an author, editor or other.
Source code in optimade/models/references.py
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 |
|
Provider
¶
Bases: BaseModel
Information on the database provider of the implementation.
Source code in optimade/models/optimade_json.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
ReferenceResource
¶
Bases: EntryResource
The references
entries describe bibliographic references.
The following properties are used to provide the bibliographic details:
- address, annote, booktitle, chapter, crossref, edition, howpublished, institution, journal, key, month, note, number, organization, pages, publisher, school, series, title, volume, year: meanings of these properties match the BibTeX specification, values are strings;
- bib_type: type of the reference, corresponding to type property in the BibTeX specification, value is string;
- authors and editors: lists of person objects which are dictionaries with the following keys:
- name: Full name of the person, REQUIRED.
- firstname, lastname: Parts of the person's name, OPTIONAL.
- doi and url: values are strings.
- Requirements/Conventions:
- Support: OPTIONAL support in implementations, i.e., any of the properties MAY be
null
. - Query: Support for queries on any of these properties is OPTIONAL. If supported, filters MAY support only a subset of comparison operators.
- Every references entry MUST contain at least one of the properties.
- Support: OPTIONAL support in implementations, i.e., any of the properties MAY be
Source code in optimade/models/references.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'references'
class-attribute
instance-attribute
¶
validate_attributes(value)
classmethod
¶
Source code in optimade/models/references.py
323 324 325 326 327 328 329 330 331 332 333 |
|
ReferenceResourceAttributes
¶
Bases: EntryResourceAttributes
Model that stores the attributes of a reference.
Many properties match the meaning described in the BibTeX specification.
Source code in optimade/models/references.py
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 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
address = None
class-attribute
instance-attribute
¶
annote = None
class-attribute
instance-attribute
¶
authors = None
class-attribute
instance-attribute
¶
bib_type = None
class-attribute
instance-attribute
¶
booktitle = None
class-attribute
instance-attribute
¶
chapter = None
class-attribute
instance-attribute
¶
crossref = None
class-attribute
instance-attribute
¶
doi = None
class-attribute
instance-attribute
¶
edition = None
class-attribute
instance-attribute
¶
editors = None
class-attribute
instance-attribute
¶
howpublished = None
class-attribute
instance-attribute
¶
immutable_id = None
class-attribute
instance-attribute
¶
institution = None
class-attribute
instance-attribute
¶
journal = None
class-attribute
instance-attribute
¶
key = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
month = None
class-attribute
instance-attribute
¶
note = None
class-attribute
instance-attribute
¶
number = None
class-attribute
instance-attribute
¶
organization = None
class-attribute
instance-attribute
¶
pages = None
class-attribute
instance-attribute
¶
publisher = None
class-attribute
instance-attribute
¶
school = None
class-attribute
instance-attribute
¶
series = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
url = None
class-attribute
instance-attribute
¶
volume = None
class-attribute
instance-attribute
¶
year = None
class-attribute
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
ReferenceResponseMany
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
150 151 152 153 154 155 156 157 158 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
ReferenceResponseOne
¶
Bases: EntryResponseOne
Source code in optimade/models/responses.py
140 141 142 143 144 145 146 147 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
RelatedLinksResource
¶
Bases: BaseResource
A related Links resource object
Source code in optimade/models/index_metadb.py
28 29 30 31 |
|
Relationship
¶
Bases: Relationship
Similar to normal JSON API relationship, but with addition of OPTIONAL meta field for a resource.
Source code in optimade/models/optimade_json.py
427 428 429 430 431 432 433 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
RelationshipLinks
¶
Bases: BaseModel
A resource object MAY contain references to other resource objects ("relationships"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.
Source code in optimade/models/jsonapi.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
related = None
class-attribute
instance-attribute
¶
self = None
class-attribute
instance-attribute
¶
either_self_or_related_must_be_specified()
¶
Source code in optimade/models/jsonapi.py
250 251 252 253 254 255 256 |
|
Relationships
¶
Bases: BaseModel
Members of the relationships object ("relationships") represent references from the resource object in which it's defined to other resource objects. Keys MUST NOT be: type id
Source code in optimade/models/jsonapi.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
check_illegal_relationships_fields()
¶
Source code in optimade/models/jsonapi.py
296 297 298 299 300 301 302 303 304 |
|
Resource
¶
Bases: BaseResource
Resource objects appear in a JSON API document to represent resources.
Source code in optimade/models/jsonapi.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
attributes = None
class-attribute
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type
instance-attribute
¶
ResourceLinks
¶
Bases: BaseModel
A Resource Links object
Source code in optimade/models/jsonapi.py
307 308 309 310 311 312 313 314 315 |
|
self = None
class-attribute
instance-attribute
¶
Response
¶
Bases: BaseModel
A top-level response.
Source code in optimade/models/jsonapi.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Source code in optimade/models/jsonapi.py
403 404 405 406 407 408 409 410 411 412 |
|
ResponseMeta
¶
Bases: Meta
A JSON API meta member that contains JSON API meta objects of non-standard meta-information.
OPTIONAL additional information global to the query that is not specified in this document, MUST start with a database-provider-specific prefix.
Source code in optimade/models/optimade_json.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
api_version
instance-attribute
¶
data_available = None
class-attribute
instance-attribute
¶
data_returned = None
class-attribute
instance-attribute
¶
implementation = None
class-attribute
instance-attribute
¶
last_id = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
more_data_available
instance-attribute
¶
optimade_schema = None
class-attribute
instance-attribute
¶
provider = None
class-attribute
instance-attribute
¶
query
instance-attribute
¶
response_message = None
class-attribute
instance-attribute
¶
time_stamp = None
class-attribute
instance-attribute
¶
warnings = None
class-attribute
instance-attribute
¶
ResponseMetaQuery
¶
Bases: BaseModel
Information on the query that was requested.
Source code in optimade/models/optimade_json.py
188 189 190 191 192 193 194 195 196 197 198 199 |
|
representation
instance-attribute
¶
Species
¶
Bases: BaseModel
A list describing the species of the sites of this structure.
Species can represent pure chemical elements, virtual-crystal atoms representing a statistical occupation of a given site by multiple chemical elements, and/or a location to which there are attached atoms, i.e., atoms whose precise location are unknown beyond that they are attached to that position (frequently used to indicate hydrogen atoms attached to another element, e.g., a carbon with three attached hydrogens might represent a methyl group, -CH3).
- Examples:
[ {"name": "Ti", "chemical_symbols": ["Ti"], "concentration": [1.0]} ]
: any site with this species is occupied by a Ti atom.[ {"name": "Ti", "chemical_symbols": ["Ti", "vacancy"], "concentration": [0.9, 0.1]} ]
: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.[ {"name": "BaCa", "chemical_symbols": ["vacancy", "Ba", "Ca"], "concentration": [0.05, 0.45, 0.5], "mass": [0.0, 137.327, 40.078]} ]
: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.[ {"name": "C12", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [12.0]} ]
: any site with this species is occupied by a carbon isotope with mass 12.[ {"name": "C13", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [13.0]} ]
: any site with this species is occupied by a carbon isotope with mass 13.[ {"name": "CH3", "chemical_symbols": ["C"], "concentration": [1.0], "attached": ["H"], "nattached": [3]} ]
: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.
Source code in optimade/models/structures.py
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 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 |
|
attached = None
class-attribute
instance-attribute
¶
chemical_symbols
instance-attribute
¶
concentration
instance-attribute
¶
mass = None
class-attribute
instance-attribute
¶
name
instance-attribute
¶
nattached = None
class-attribute
instance-attribute
¶
original_name = None
class-attribute
instance-attribute
¶
attached_nattached_mutually_exclusive()
¶
Source code in optimade/models/structures.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
validate_concentration_and_mass(value, info)
¶
Source code in optimade/models/structures.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
validate_minimum_list_length(value)
classmethod
¶
Source code in optimade/models/structures.py
181 182 183 184 185 186 187 188 189 190 191 |
|
StructureFeatures
¶
Bases: Enum
Enumeration of structure_features values
Source code in optimade/models/structures.py
55 56 57 58 59 60 61 |
|
StructureResource
¶
Bases: EntryResource
Representing a structure.
Source code in optimade/models/structures.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'structures'
class-attribute
instance-attribute
¶
StructureResourceAttributes
¶
Bases: EntryResourceAttributes
This class contains the Field for the attributes used to represent a structure, e.g. unit cell, atoms, positions.
Source code in optimade/models/structures.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
assemblies = None
class-attribute
instance-attribute
¶
cartesian_site_positions = None
class-attribute
instance-attribute
¶
chemical_formula_anonymous = None
class-attribute
instance-attribute
¶
chemical_formula_descriptive = None
class-attribute
instance-attribute
¶
chemical_formula_hill = None
class-attribute
instance-attribute
¶
chemical_formula_reduced = None
class-attribute
instance-attribute
¶
dimension_types = None
class-attribute
instance-attribute
¶
elements = None
class-attribute
instance-attribute
¶
elements_ratios = None
class-attribute
instance-attribute
¶
immutable_id = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
lattice_vectors = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
nelements = None
class-attribute
instance-attribute
¶
nperiodic_dimensions = None
class-attribute
instance-attribute
¶
nsites = None
class-attribute
instance-attribute
¶
species = None
class-attribute
instance-attribute
¶
species_at_sites = None
class-attribute
instance-attribute
¶
structure_features
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_anonymous_formula(value)
classmethod
¶
Source code in optimade/models/structures.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
|
check_dimensions_types_dependencies()
¶
Source code in optimade/models/structures.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
check_ordered_formula(value, info)
classmethod
¶
Source code in optimade/models/structures.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
|
check_reduced_formulae(value, info)
classmethod
¶
Source code in optimade/models/structures.py
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
|
elements_must_be_alphabetical(value)
classmethod
¶
Source code in optimade/models/structures.py
951 952 953 954 955 956 957 958 959 |
|
null_values_for_whole_vector(value)
classmethod
¶
Source code in optimade/models/structures.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
|
ratios_must_sum_to_one(value)
classmethod
¶
Source code in optimade/models/structures.py
961 962 963 964 965 966 967 968 969 970 971 972 |
|
validate_nsites()
¶
Source code in optimade/models/structures.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
|
validate_species(value)
classmethod
¶
Source code in optimade/models/structures.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
|
validate_species_at_sites()
¶
Source code in optimade/models/structures.py
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
|
validate_structure_features()
¶
Source code in optimade/models/structures.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
warn_on_missing_correlated_fields()
¶
Emit warnings if a field takes a null value when a value was expected based on the value/nullity of another field.
Source code in optimade/models/structures.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
|
StructureResponseMany
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
129 130 131 132 133 134 135 136 137 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
StructureResponseOne
¶
Bases: EntryResponseOne
Source code in optimade/models/responses.py
119 120 121 122 123 124 125 126 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
Success
¶
Bases: Response
errors are not allowed
Source code in optimade/models/optimade_json.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
SupportLevel
¶
Bases: Enum
OPTIMADE property/field support levels
Source code in optimade/models/utils.py
32 33 34 35 36 37 |
|
ToplevelLinks
¶
Bases: BaseModel
A set of Links objects, possibly including pagination
Source code in optimade/models/jsonapi.py
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 |
|
first = None
class-attribute
instance-attribute
¶
last = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
next = None
class-attribute
instance-attribute
¶
prev = None
class-attribute
instance-attribute
¶
related = None
class-attribute
instance-attribute
¶
self = None
class-attribute
instance-attribute
¶
check_additional_keys_are_links()
¶
The ToplevelLinks
class allows any additional keys, as long as
they are also Links or Urls themselves.
Source code in optimade/models/jsonapi.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
Warnings
¶
Bases: OptimadeError
OPTIMADE-specific warning class based on OPTIMADE-specific JSON API Error.
From the specification:
A warning resource object is defined similarly to a JSON API error object, but MUST also include the field type, which MUST have the value "warning". The field detail MUST be present and SHOULD contain a non-critical message, e.g., reporting unrecognized search attributes or deprecated features.
Note: Must be named "Warnings", since "Warning" is a built-in Python class.
Source code in optimade/models/optimade_json.py
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 |
|
code = None
class-attribute
instance-attribute
¶
detail
instance-attribute
¶
id = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=warnings_json_schema_extra)
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
type = 'warning'
class-attribute
instance-attribute
¶
__hash__()
¶
Source code in optimade/models/jsonapi.py
191 192 |
|
status_must_not_be_specified()
¶
Source code in optimade/models/optimade_json.py
181 182 183 184 185 |
|
baseinfo
¶
VERSIONED_BASE_URL_PATTERN = '^.+/v[0-1](\\.[0-9]+)*/?$'
module-attribute
¶
AvailableApiVersion
¶
Bases: BaseModel
A JSON object containing information about an available API version
Source code in optimade/models/baseinfo.py
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 |
|
url
instance-attribute
¶
version
instance-attribute
¶
crosscheck_url_and_version()
¶
Check that URL version and API version are compatible.
Source code in optimade/models/baseinfo.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
url_must_be_versioned_base_Url(value)
classmethod
¶
The URL must be a versioned base URL
Source code in optimade/models/baseinfo.py
38 39 40 41 42 43 44 45 46 47 |
|
BaseInfoAttributes
¶
Bases: BaseModel
Attributes for Base URL Info endpoint
Source code in optimade/models/baseinfo.py
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 |
|
api_version
instance-attribute
¶
available_api_versions
instance-attribute
¶
available_endpoints
instance-attribute
¶
entry_types_by_format
instance-attribute
¶
formats = ['json']
class-attribute
instance-attribute
¶
is_index = False
class-attribute
instance-attribute
¶
formats_and_endpoints_must_be_valid()
¶
Source code in optimade/models/baseinfo.py
112 113 114 115 116 117 118 119 120 121 122 |
|
BaseInfoResource
¶
Bases: Resource
Source code in optimade/models/baseinfo.py
125 126 127 128 |
|
attributes
instance-attribute
¶
id = '/'
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'info'
class-attribute
instance-attribute
¶
entries
¶
EntryInfoProperty
¶
Bases: BaseModel
Source code in optimade/models/entries.py
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 |
|
EntryInfoResource
¶
Bases: BaseModel
Source code in optimade/models/entries.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 |
|
EntryRelationships
¶
Bases: Relationships
This model wraps the JSON API Relationships to include type-specific top level keys.
Source code in optimade/models/entries.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|
references = None
class-attribute
instance-attribute
¶
structures = None
class-attribute
instance-attribute
¶
check_illegal_relationships_fields()
¶
Source code in optimade/models/jsonapi.py
296 297 298 299 300 301 302 303 304 |
|
EntryResource
¶
Bases: Resource
The base model for an entry resource.
Source code in optimade/models/entries.py
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type
instance-attribute
¶
EntryResourceAttributes
¶
Bases: Attributes
Contains key-value pairs representing the entry's properties.
Source code in optimade/models/entries.py
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 |
|
immutable_id = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
ReferenceRelationship
¶
Bases: TypedRelationship
Source code in optimade/models/entries.py
43 44 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
check_rel_type(data)
classmethod
¶
Source code in optimade/models/entries.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
StructureRelationship
¶
Bases: TypedRelationship
Source code in optimade/models/entries.py
47 48 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
check_rel_type(data)
classmethod
¶
Source code in optimade/models/entries.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
TypedRelationship
¶
Bases: Relationship
Source code in optimade/models/entries.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
check_rel_type(data)
classmethod
¶
Source code in optimade/models/entries.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
index_metadb
¶
IndexInfoAttributes
¶
Bases: BaseInfoAttributes
Attributes for Base URL Info endpoint for an Index Meta-Database
Source code in optimade/models/index_metadb.py
17 18 19 20 21 22 23 24 25 |
|
api_version
instance-attribute
¶
available_api_versions
instance-attribute
¶
available_endpoints
instance-attribute
¶
entry_types_by_format
instance-attribute
¶
formats = ['json']
class-attribute
instance-attribute
¶
is_index = True
class-attribute
instance-attribute
¶
formats_and_endpoints_must_be_valid()
¶
Source code in optimade/models/baseinfo.py
112 113 114 115 116 117 118 119 120 121 122 |
|
IndexInfoResource
¶
Bases: BaseInfoResource
Index Meta-Database Base URL Info endpoint resource
Source code in optimade/models/index_metadb.py
46 47 48 49 50 51 52 53 54 55 56 57 |
|
attributes
instance-attribute
¶
id = '/'
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships
instance-attribute
¶
type = 'info'
class-attribute
instance-attribute
¶
IndexRelationship
¶
Bases: BaseModel
Index Meta-Database relationship
Source code in optimade/models/index_metadb.py
34 35 36 37 38 39 40 41 42 43 |
|
data
instance-attribute
¶
RelatedLinksResource
¶
Bases: BaseResource
A related Links resource object
Source code in optimade/models/index_metadb.py
28 29 30 31 |
|
jsonapi
¶
This module should reproduce JSON API v1.0 https://jsonapi.org/format/1.0/
JsonLinkType = Union[AnyUrl, Link]
module-attribute
¶
Attributes
¶
Bases: BaseModel
Members of the attributes object ("attributes") represent information about the resource object in which it's defined. The keys for Attributes MUST NOT be: relationships links id type
Source code in optimade/models/jsonapi.py
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
|
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
BaseResource
¶
Bases: BaseModel
Minimum requirements to represent a Resource
Source code in optimade/models/jsonapi.py
218 219 220 221 222 223 224 |
|
Error
¶
Bases: BaseModel
An error response
Source code in optimade/models/jsonapi.py
141 142 143 144 145 146 147 148 149 150 151 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 |
|
code = None
class-attribute
instance-attribute
¶
detail = None
class-attribute
instance-attribute
¶
id = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
__hash__()
¶
Source code in optimade/models/jsonapi.py
191 192 |
|
ErrorLinks
¶
Bases: BaseModel
A Links object specific to Error objects
Source code in optimade/models/jsonapi.py
112 113 114 115 116 117 118 119 120 |
|
about = None
class-attribute
instance-attribute
¶
ErrorSource
¶
Bases: BaseModel
an object containing references to the source of the error
Source code in optimade/models/jsonapi.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
|
JsonApi
¶
Bases: BaseModel
An object describing the server's implementation
Source code in optimade/models/jsonapi.py
58 59 60 61 62 63 64 65 66 |
|
Link
¶
Bases: BaseModel
A link MUST be represented as either: a string containing the link's URL or a link object.
Source code in optimade/models/jsonapi.py
41 42 43 44 45 46 47 48 49 50 51 52 |
|
Meta
¶
Bases: BaseModel
Non-standard meta-information that can not be represented as an attribute or relationship.
Source code in optimade/models/jsonapi.py
35 36 37 38 |
|
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
Relationship
¶
Bases: BaseModel
Representation references from the resource object in which it's defined to other resource objects.
Source code in optimade/models/jsonapi.py
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
RelationshipLinks
¶
Bases: BaseModel
A resource object MAY contain references to other resource objects ("relationships"). Relationships may be to-one or to-many. Relationships can be specified by including a member in a resource's links object.
Source code in optimade/models/jsonapi.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 |
|
related = None
class-attribute
instance-attribute
¶
self = None
class-attribute
instance-attribute
¶
either_self_or_related_must_be_specified()
¶
Source code in optimade/models/jsonapi.py
250 251 252 253 254 255 256 |
|
Relationships
¶
Bases: BaseModel
Members of the relationships object ("relationships") represent references from the resource object in which it's defined to other resource objects. Keys MUST NOT be: type id
Source code in optimade/models/jsonapi.py
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 |
|
check_illegal_relationships_fields()
¶
Source code in optimade/models/jsonapi.py
296 297 298 299 300 301 302 303 304 |
|
Resource
¶
Bases: BaseResource
Resource objects appear in a JSON API document to represent resources.
Source code in optimade/models/jsonapi.py
341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 |
|
attributes = None
class-attribute
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type
instance-attribute
¶
ResourceLinks
¶
Bases: BaseModel
A Resource Links object
Source code in optimade/models/jsonapi.py
307 308 309 310 311 312 313 314 315 |
|
self = None
class-attribute
instance-attribute
¶
Response
¶
Bases: BaseModel
A top-level response.
Source code in optimade/models/jsonapi.py
371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Source code in optimade/models/jsonapi.py
403 404 405 406 407 408 409 410 411 412 |
|
ToplevelLinks
¶
Bases: BaseModel
A set of Links objects, possibly including pagination
Source code in optimade/models/jsonapi.py
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 |
|
first = None
class-attribute
instance-attribute
¶
last = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
next = None
class-attribute
instance-attribute
¶
prev = None
class-attribute
instance-attribute
¶
related = None
class-attribute
instance-attribute
¶
self = None
class-attribute
instance-attribute
¶
check_additional_keys_are_links()
¶
The ToplevelLinks
class allows any additional keys, as long as
they are also Links or Urls themselves.
Source code in optimade/models/jsonapi.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
resource_json_schema_extra(schema, model)
¶
Ensure id
and type
are the first two entries in the list required properties.
Note
This requires that id
and type
are the first model fields defined
for all sub-models of BaseResource
.
Source code in optimade/models/jsonapi.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 |
|
links
¶
Aggregate
¶
Bases: Enum
Enumeration of aggregate values
Source code in optimade/models/links.py
25 26 27 28 29 30 31 |
|
LinkType
¶
Bases: Enum
Enumeration of link_type values
Source code in optimade/models/links.py
16 17 18 19 20 21 22 |
|
LinksResource
¶
Bases: EntryResource
A Links endpoint resource object
Source code in optimade/models/links.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'links'
class-attribute
instance-attribute
¶
relationships_must_not_be_present()
¶
Source code in optimade/models/links.py
116 117 118 119 120 |
|
LinksResourceAttributes
¶
Bases: Attributes
Links endpoint resource object attributes
Source code in optimade/models/links.py
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 |
|
aggregate = Aggregate.OK
class-attribute
instance-attribute
¶
base_url
instance-attribute
¶
description
instance-attribute
¶
homepage
instance-attribute
¶
link_type
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
name
instance-attribute
¶
no_aggregate_reason = None
class-attribute
instance-attribute
¶
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
optimade_json
¶
Modified JSON API v1.0 for OPTIMADE API
ValidIdentifier = Annotated[str, Field(pattern=IDENTIFIER_REGEX)]
module-attribute
¶
A type that constrains strings to valid OPTIMADE identifiers (e.g., property names, ID strings).
BaseRelationshipMeta
¶
Bases: Meta
Specific meta field for base relationship resource
Source code in optimade/models/optimade_json.py
405 406 407 408 409 410 411 412 413 |
|
BaseRelationshipResource
¶
Bases: BaseResource
Minimum requirements to represent a relationship resource
Source code in optimade/models/optimade_json.py
416 417 418 419 420 421 422 423 424 |
|
DataType
¶
Bases: Enum
Optimade Data types
See the section "Data types" in the OPTIMADE API specification for more information.
Source code in optimade/models/optimade_json.py
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 |
|
BOOLEAN = 'boolean'
class-attribute
instance-attribute
¶
DICTIONARY = 'dictionary'
class-attribute
instance-attribute
¶
FLOAT = 'float'
class-attribute
instance-attribute
¶
INTEGER = 'integer'
class-attribute
instance-attribute
¶
LIST = 'list'
class-attribute
instance-attribute
¶
STRING = 'string'
class-attribute
instance-attribute
¶
TIMESTAMP = 'timestamp'
class-attribute
instance-attribute
¶
UNKNOWN = 'unknown'
class-attribute
instance-attribute
¶
from_json_type(json_type)
classmethod
¶
Get OPTIMADE data type from a named JSON type
Source code in optimade/models/optimade_json.py
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 |
|
from_python_type(python_type)
classmethod
¶
Get OPTIMADE data type from a Python type
Source code in optimade/models/optimade_json.py
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 |
|
get_values()
classmethod
¶
Get OPTIMADE data types (enum values) as a (sorted) list
Source code in optimade/models/optimade_json.py
47 48 49 50 |
|
Implementation
¶
Bases: BaseModel
Information on the server implementation
Source code in optimade/models/optimade_json.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
homepage = None
class-attribute
instance-attribute
¶
issue_tracker = None
class-attribute
instance-attribute
¶
maintainer = None
class-attribute
instance-attribute
¶
name = None
class-attribute
instance-attribute
¶
source_url = None
class-attribute
instance-attribute
¶
version = None
class-attribute
instance-attribute
¶
ImplementationMaintainer
¶
Bases: BaseModel
Details about the maintainer of the implementation
Source code in optimade/models/optimade_json.py
231 232 233 234 235 236 |
|
email
instance-attribute
¶
OptimadeError
¶
Bases: Error
detail MUST be present
Source code in optimade/models/optimade_json.py
128 129 130 131 132 133 134 135 136 |
|
code = None
class-attribute
instance-attribute
¶
detail
instance-attribute
¶
id = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
__hash__()
¶
Source code in optimade/models/jsonapi.py
191 192 |
|
Provider
¶
Bases: BaseModel
Information on the database provider of the implementation.
Source code in optimade/models/optimade_json.py
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
|
Relationship
¶
Bases: Relationship
Similar to normal JSON API relationship, but with addition of OPTIONAL meta field for a resource.
Source code in optimade/models/optimade_json.py
427 428 429 430 431 432 433 |
|
data = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
at_least_one_relationship_key_must_be_set()
¶
Source code in optimade/models/jsonapi.py
279 280 281 282 283 284 285 |
|
ResponseMeta
¶
Bases: Meta
A JSON API meta member that contains JSON API meta objects of non-standard meta-information.
OPTIONAL additional information global to the query that is not specified in this document, MUST start with a database-provider-specific prefix.
Source code in optimade/models/optimade_json.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 |
|
api_version
instance-attribute
¶
data_available = None
class-attribute
instance-attribute
¶
data_returned = None
class-attribute
instance-attribute
¶
implementation = None
class-attribute
instance-attribute
¶
last_id = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
more_data_available
instance-attribute
¶
optimade_schema = None
class-attribute
instance-attribute
¶
provider = None
class-attribute
instance-attribute
¶
query
instance-attribute
¶
response_message = None
class-attribute
instance-attribute
¶
time_stamp = None
class-attribute
instance-attribute
¶
warnings = None
class-attribute
instance-attribute
¶
ResponseMetaQuery
¶
Bases: BaseModel
Information on the query that was requested.
Source code in optimade/models/optimade_json.py
188 189 190 191 192 193 194 195 196 197 198 199 |
|
representation
instance-attribute
¶
Success
¶
Bases: Response
errors are not allowed
Source code in optimade/models/optimade_json.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
Warnings
¶
Bases: OptimadeError
OPTIMADE-specific warning class based on OPTIMADE-specific JSON API Error.
From the specification:
A warning resource object is defined similarly to a JSON API error object, but MUST also include the field type, which MUST have the value "warning". The field detail MUST be present and SHOULD contain a non-critical message, e.g., reporting unrecognized search attributes or deprecated features.
Note: Must be named "Warnings", since "Warning" is a built-in Python class.
Source code in optimade/models/optimade_json.py
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 |
|
code = None
class-attribute
instance-attribute
¶
detail
instance-attribute
¶
id = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=warnings_json_schema_extra)
class-attribute
instance-attribute
¶
source = None
class-attribute
instance-attribute
¶
status = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
type = 'warning'
class-attribute
instance-attribute
¶
__hash__()
¶
Source code in optimade/models/jsonapi.py
191 192 |
|
status_must_not_be_specified()
¶
Source code in optimade/models/optimade_json.py
181 182 183 184 185 |
|
warnings_json_schema_extra(schema, model)
¶
Update OpenAPI JSON schema model for Warning
.
- Ensure
type
is in the list required properties and in the correct place. - Remove
status
property. This property is not allowed forWarning
, nor is it a part of the OPTIMADE definition of theWarning
object.
Note
Since type
is the last model field defined, it will simply be appended.
Source code in optimade/models/optimade_json.py
139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
references
¶
Person
¶
Bases: BaseModel
A person, i.e., an author, editor or other.
Source code in optimade/models/references.py
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 |
|
ReferenceResource
¶
Bases: EntryResource
The references
entries describe bibliographic references.
The following properties are used to provide the bibliographic details:
- address, annote, booktitle, chapter, crossref, edition, howpublished, institution, journal, key, month, note, number, organization, pages, publisher, school, series, title, volume, year: meanings of these properties match the BibTeX specification, values are strings;
- bib_type: type of the reference, corresponding to type property in the BibTeX specification, value is string;
- authors and editors: lists of person objects which are dictionaries with the following keys:
- name: Full name of the person, REQUIRED.
- firstname, lastname: Parts of the person's name, OPTIONAL.
- doi and url: values are strings.
- Requirements/Conventions:
- Support: OPTIONAL support in implementations, i.e., any of the properties MAY be
null
. - Query: Support for queries on any of these properties is OPTIONAL. If supported, filters MAY support only a subset of comparison operators.
- Every references entry MUST contain at least one of the properties.
- Support: OPTIONAL support in implementations, i.e., any of the properties MAY be
Source code in optimade/models/references.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'references'
class-attribute
instance-attribute
¶
validate_attributes(value)
classmethod
¶
Source code in optimade/models/references.py
323 324 325 326 327 328 329 330 331 332 333 |
|
ReferenceResourceAttributes
¶
Bases: EntryResourceAttributes
Model that stores the attributes of a reference.
Many properties match the meaning described in the BibTeX specification.
Source code in optimade/models/references.py
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 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 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
|
address = None
class-attribute
instance-attribute
¶
annote = None
class-attribute
instance-attribute
¶
authors = None
class-attribute
instance-attribute
¶
bib_type = None
class-attribute
instance-attribute
¶
booktitle = None
class-attribute
instance-attribute
¶
chapter = None
class-attribute
instance-attribute
¶
crossref = None
class-attribute
instance-attribute
¶
doi = None
class-attribute
instance-attribute
¶
edition = None
class-attribute
instance-attribute
¶
editors = None
class-attribute
instance-attribute
¶
howpublished = None
class-attribute
instance-attribute
¶
immutable_id = None
class-attribute
instance-attribute
¶
institution = None
class-attribute
instance-attribute
¶
journal = None
class-attribute
instance-attribute
¶
key = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
month = None
class-attribute
instance-attribute
¶
note = None
class-attribute
instance-attribute
¶
number = None
class-attribute
instance-attribute
¶
organization = None
class-attribute
instance-attribute
¶
pages = None
class-attribute
instance-attribute
¶
publisher = None
class-attribute
instance-attribute
¶
school = None
class-attribute
instance-attribute
¶
series = None
class-attribute
instance-attribute
¶
title = None
class-attribute
instance-attribute
¶
url = None
class-attribute
instance-attribute
¶
volume = None
class-attribute
instance-attribute
¶
year = None
class-attribute
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
responses
¶
EntryInfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
58 59 60 61 62 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
EntryResponseMany
¶
Bases: Success
Source code in optimade/models/responses.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
EntryResponseOne
¶
Bases: Success
Source code in optimade/models/responses.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
|
data = None
class-attribute
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
ErrorResponse
¶
Bases: Response
errors MUST be present and data MUST be skipped
Source code in optimade/models/responses.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
|
data = None
class-attribute
instance-attribute
¶
errors
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
data_must_be_skipped()
¶
Source code in optimade/models/responses.py
45 46 47 48 49 |
|
either_data_meta_or_errors_must_be_set()
¶
Source code in optimade/models/jsonapi.py
403 404 405 406 407 408 409 410 411 412 |
|
IndexInfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
52 53 54 55 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
InfoResponse
¶
Bases: Success
Source code in optimade/models/responses.py
65 66 67 68 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
LinksResponse
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
108 109 110 111 112 113 114 115 116 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
ReferenceResponseMany
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
150 151 152 153 154 155 156 157 158 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
ReferenceResponseOne
¶
Bases: EntryResponseOne
Source code in optimade/models/responses.py
140 141 142 143 144 145 146 147 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
StructureResponseMany
¶
Bases: EntryResponseMany
Source code in optimade/models/responses.py
129 130 131 132 133 134 135 136 137 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
StructureResponseOne
¶
Bases: EntryResponseOne
Source code in optimade/models/responses.py
119 120 121 122 123 124 125 126 |
|
data
instance-attribute
¶
errors = None
class-attribute
instance-attribute
¶
included = None
class-attribute
instance-attribute
¶
jsonapi = None
class-attribute
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta
instance-attribute
¶
model_config = ConfigDict(json_encoders={datetime: lambda v: v.astimezone(timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ')})
class-attribute
instance-attribute
¶
The specification mandates that datetimes must be encoded following RFC3339, which does not support fractional seconds, thus they must be stripped in the response. This can cause issues when the underlying database contains fields that do include microseconds, as filters may return unexpected results.
either_data_meta_or_errors_must_be_set()
¶
Overwriting the existing validation function, since 'errors' MUST NOT be set.
Source code in optimade/models/optimade_json.py
389 390 391 392 393 394 395 396 397 398 399 400 401 402 |
|
structures
¶
CORRELATED_STRUCTURE_FIELDS = ({'dimension_types', 'nperiodic_dimensions'}, {'cartesian_site_positions', 'species_at_sites'}, {'nsites', 'cartesian_site_positions'}, {'species_at_sites', 'species'})
module-attribute
¶
EPS = 2 ** -23
module-attribute
¶
Vector3D = Annotated[list[Annotated[float, BeforeValidator(float)]], Field(min_length=3, max_length=3)]
module-attribute
¶
Vector3D_unknown = Annotated[list[Optional[Annotated[float, BeforeValidator(float)]]], Field(min_length=3, max_length=3)]
module-attribute
¶
Assembly
¶
Bases: BaseModel
A description of groups of sites that are statistically correlated.
- Examples (for each entry of the assemblies list):
{"sites_in_groups": [[0], [1]], "group_probabilities: [0.3, 0.7]}
: the first site and the second site never occur at the same time in the unit cell. Statistically, 30 % of the times the first site is present, while 70 % of the times the second site is present.{"sites_in_groups": [[1,2], [3]], "group_probabilities: [0.3, 0.7]}
: the second and third site are either present together or not present; they form the first group of atoms for this assembly. The second group is formed by the fourth site. Sites of the first group (the second and the third) are never present at the same time as the fourth site. 30 % of times sites 1 and 2 are present (and site 3 is absent); 70 % of times site 3 is present (and sites 1 and 2 are absent).
Source code in optimade/models/structures.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 |
|
group_probabilities
instance-attribute
¶
sites_in_groups
instance-attribute
¶
check_self_consistency()
¶
Source code in optimade/models/structures.py
265 266 267 268 269 270 271 272 273 |
|
validate_sites_in_groups(value)
classmethod
¶
Source code in optimade/models/structures.py
253 254 255 256 257 258 259 260 261 262 263 |
|
Periodicity
¶
Bases: IntEnum
Integer enumeration of dimension_types values
Source code in optimade/models/structures.py
48 49 50 51 52 |
|
Species
¶
Bases: BaseModel
A list describing the species of the sites of this structure.
Species can represent pure chemical elements, virtual-crystal atoms representing a statistical occupation of a given site by multiple chemical elements, and/or a location to which there are attached atoms, i.e., atoms whose precise location are unknown beyond that they are attached to that position (frequently used to indicate hydrogen atoms attached to another element, e.g., a carbon with three attached hydrogens might represent a methyl group, -CH3).
- Examples:
[ {"name": "Ti", "chemical_symbols": ["Ti"], "concentration": [1.0]} ]
: any site with this species is occupied by a Ti atom.[ {"name": "Ti", "chemical_symbols": ["Ti", "vacancy"], "concentration": [0.9, 0.1]} ]
: any site with this species is occupied by a Ti atom with 90 % probability, and has a vacancy with 10 % probability.[ {"name": "BaCa", "chemical_symbols": ["vacancy", "Ba", "Ca"], "concentration": [0.05, 0.45, 0.5], "mass": [0.0, 137.327, 40.078]} ]
: any site with this species is occupied by a Ba atom with 45 % probability, a Ca atom with 50 % probability, and by a vacancy with 5 % probability. The mass of this site is (on average) 88.5 a.m.u.[ {"name": "C12", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [12.0]} ]
: any site with this species is occupied by a carbon isotope with mass 12.[ {"name": "C13", "chemical_symbols": ["C"], "concentration": [1.0], "mass": [13.0]} ]
: any site with this species is occupied by a carbon isotope with mass 13.[ {"name": "CH3", "chemical_symbols": ["C"], "concentration": [1.0], "attached": ["H"], "nattached": [3]} ]
: any site with this species is occupied by a methyl group, -CH3, which is represented without specifying precise positions of the hydrogen atoms.
Source code in optimade/models/structures.py
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 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 |
|
attached = None
class-attribute
instance-attribute
¶
chemical_symbols
instance-attribute
¶
concentration
instance-attribute
¶
mass = None
class-attribute
instance-attribute
¶
name
instance-attribute
¶
nattached = None
class-attribute
instance-attribute
¶
original_name = None
class-attribute
instance-attribute
¶
attached_nattached_mutually_exclusive()
¶
Source code in optimade/models/structures.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
|
validate_concentration_and_mass(value, info)
¶
Source code in optimade/models/structures.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 |
|
validate_minimum_list_length(value)
classmethod
¶
Source code in optimade/models/structures.py
181 182 183 184 185 186 187 188 189 190 191 |
|
StructureFeatures
¶
Bases: Enum
Enumeration of structure_features values
Source code in optimade/models/structures.py
55 56 57 58 59 60 61 |
|
StructureResource
¶
Bases: EntryResource
Representing a structure.
Source code in optimade/models/structures.py
1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 |
|
attributes
instance-attribute
¶
id
instance-attribute
¶
links = None
class-attribute
instance-attribute
¶
meta = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(json_schema_extra=resource_json_schema_extra)
class-attribute
instance-attribute
¶
relationships = None
class-attribute
instance-attribute
¶
type = 'structures'
class-attribute
instance-attribute
¶
StructureResourceAttributes
¶
Bases: EntryResourceAttributes
This class contains the Field for the attributes used to represent a structure, e.g. unit cell, atoms, positions.
Source code in optimade/models/structures.py
284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
assemblies = None
class-attribute
instance-attribute
¶
cartesian_site_positions = None
class-attribute
instance-attribute
¶
chemical_formula_anonymous = None
class-attribute
instance-attribute
¶
chemical_formula_descriptive = None
class-attribute
instance-attribute
¶
chemical_formula_hill = None
class-attribute
instance-attribute
¶
chemical_formula_reduced = None
class-attribute
instance-attribute
¶
dimension_types = None
class-attribute
instance-attribute
¶
elements = None
class-attribute
instance-attribute
¶
elements_ratios = None
class-attribute
instance-attribute
¶
immutable_id = None
class-attribute
instance-attribute
¶
last_modified
instance-attribute
¶
lattice_vectors = None
class-attribute
instance-attribute
¶
model_config = ConfigDict(extra='allow')
class-attribute
instance-attribute
¶
nelements = None
class-attribute
instance-attribute
¶
nperiodic_dimensions = None
class-attribute
instance-attribute
¶
nsites = None
class-attribute
instance-attribute
¶
species = None
class-attribute
instance-attribute
¶
species_at_sites = None
class-attribute
instance-attribute
¶
structure_features
instance-attribute
¶
cast_immutable_id_to_str(value)
classmethod
¶
Convenience validator for casting immutable_id
to a string.
Source code in optimade/models/entries.py
110 111 112 113 114 115 116 117 |
|
check_anonymous_formula(value)
classmethod
¶
Source code in optimade/models/structures.py
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 |
|
check_dimensions_types_dependencies()
¶
Source code in optimade/models/structures.py
974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 |
|
check_illegal_attributes_fields()
¶
Source code in optimade/models/jsonapi.py
330 331 332 333 334 335 336 337 338 |
|
check_ordered_formula(value, info)
classmethod
¶
Source code in optimade/models/structures.py
871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 |
|
check_reduced_formulae(value, info)
classmethod
¶
Source code in optimade/models/structures.py
932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 |
|
elements_must_be_alphabetical(value)
classmethod
¶
Source code in optimade/models/structures.py
951 952 953 954 955 956 957 958 959 |
|
null_values_for_whole_vector(value)
classmethod
¶
Source code in optimade/models/structures.py
1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 |
|
ratios_must_sum_to_one(value)
classmethod
¶
Source code in optimade/models/structures.py
961 962 963 964 965 966 967 968 969 970 971 972 |
|
validate_nsites()
¶
Source code in optimade/models/structures.py
1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 |
|
validate_species(value)
classmethod
¶
Source code in optimade/models/structures.py
1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 |
|
validate_species_at_sites()
¶
Source code in optimade/models/structures.py
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 |
|
validate_structure_features()
¶
Source code in optimade/models/structures.py
1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 |
|
warn_on_missing_correlated_fields()
¶
Emit warnings if a field takes a null value when a value was expected based on the value/nullity of another field.
Source code in optimade/models/structures.py
849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 |
|
types
¶
AnnotatedType = type(ChemicalSymbol)
module-attribute
¶
ChemicalSymbol = Annotated[str, Field(pattern=EXTENDED_CHEMICAL_SYMBOLS_PATTERN)]
module-attribute
¶
ElementSymbol = Annotated[str, Field(pattern=ELEMENT_SYMBOLS_PATTERN)]
module-attribute
¶
NoneType = type(None)
module-attribute
¶
OptionalType = type(Optional[str])
module-attribute
¶
SemanticVersion = Annotated[str, Field(pattern=SEMVER_PATTERN, examples=['0.10.1', '1.0.0-rc.2', '1.2.3-rc.5+develop'])]
module-attribute
¶
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
¶
ELEMENT_SYMBOLS_PATTERN = '(' + '|'.join(CHEMICAL_SYMBOLS) + ')'
module-attribute
¶
EXTENDED_CHEMICAL_SYMBOLS_PATTERN = '(' + '|'.join(CHEMICAL_SYMBOLS + EXTRA_SYMBOLS) + ')'
module-attribute
¶
EXTRA_SYMBOLS = ['X', 'vacancy']
module-attribute
¶
IDENTIFIER_REGEX = '^[a-z_][a-z_0-9]+$'
module-attribute
¶
OPTIMADE_SCHEMA_EXTENSION_KEYS = ['support', 'queryable', 'unit', 'sortable']
module-attribute
¶
OPTIMADE_SCHEMA_EXTENSION_PREFIX = 'x-optimade-'
module-attribute
¶
SEMVER_PATTERN = '^(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-]+)*))?$'
module-attribute
¶
SupportLevel
¶
Bases: Enum
OPTIMADE property/field support levels
Source code in optimade/models/utils.py
32 33 34 35 36 37 |
|
OptimadeField(default=PydanticUndefined, *, 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
|
str | SupportLevel | None
|
The support level of the field itself, i.e. whether the field can be null or omitted by an implementation. |
None
|
queryable
|
str | SupportLevel | None
|
The support level corresponding to the queryablility of this field. |
None
|
unit
|
str | None
|
A string describing the unit of the field. |
None
|
Returns:
Type | Description |
---|---|
Any
|
The pydantic field with extra validation provided by |
Source code in optimade/models/utils.py
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 157 158 159 160 161 162 |
|
StrictField(default=PydanticUndefined, *, 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 |
---|---|---|---|
default
|
Any
|
The only non-keyword argument allowed for Field. |
PydanticUndefined
|
description
|
str | None
|
The description of the |
None
|
**kwargs
|
Any
|
Extra keyword arguments to be passed to |
{}
|
Raises:
Type | Description |
---|---|
RuntimeError
|
If |
Returns:
Type | Description |
---|---|
Any
|
The pydantic |
Source code in optimade/models/utils.py
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 |
|
anonymize_formula(formula)
¶
Takes a string representation of a chemical formula of the form [A-Z][a-z]*[0-9]*
(potentially with whitespace) and
returns the OPTIMADE chemical_formula_anonymous
representation, i.e., a reduced chemical formula comprising of element symbols
drawn from A, B, C... ordered from largest proportion to smallest.
Returns:
Type | Description |
---|---|
str
|
The anonymous chemical formula in the OPTIMADE representation. |
Source code in optimade/models/utils.py
209 210 211 212 213 214 215 216 217 218 |
|
anonymous_element_generator()
¶
Generator that yields the next symbol in the A, B, Aa, ... Az naming scheme.
Source code in optimade/models/utils.py
165 166 167 168 169 170 171 172 173 |
|
reduce_formula(formula)
¶
Takes a string representation of a chemical formula of the form [A-Z][a-z]*[0-9]*
(potentially with whitespace) and
reduces it by the GCD of the proportion integers present in the formula, stripping any leftover "1" values.
Returns:
Type | Description |
---|---|
str
|
The reduced chemical formula in the OPTIMADE representation. |
Source code in optimade/models/utils.py
221 222 223 224 225 226 227 228 229 |
|