Commit f5f6b644 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Fixed handling for nperiodic_dimensions = 0. #461

parent 0b0c4750
......@@ -140,10 +140,7 @@ class ElasticsearchStructureCollection(EntryCollection):
def include(key):
return response_fields is None or (key in response_fields) or not key.startswith('_')
attrs = {
key: value
for key, value in entry.dft.optimade.m_to_dict().items()
if include(key)}
attrs = entry.dft.optimade.m_to_dict()
if include('immutable_id'):
attrs['immutable_id'] = calc_id
......@@ -165,6 +162,8 @@ class ElasticsearchStructureCollection(EntryCollection):
elif isinstance(dimension_types, list):
attrs['nperiodic_dimensions'] = sum(dimension_types)
attrs = {key: value for key, value in attrs.items() if include(key)}
if response_fields is not None:
for request_field in response_fields:
if not request_field.startswith('_nmd_'):
......
......@@ -51,7 +51,9 @@ def transform_to_v1(entry: EntryMetadata) -> EntryMetadata:
optimade.chemical_formula_hill = optimade_chemical_formula_hill(optimade.chemical_formula_hill)
optimade.chemical_formula_descriptive = optimade.chemical_formula_hill
dimension_types = optimade.dimension_types
if isinstance(dimension_types, int):
if dimension_types is None:
optimade.dimension_types = [0, 0, 0]
elif isinstance(dimension_types, int):
optimade.dimension_types = [1] * dimension_types + [0] * (3 - dimension_types)
return entry
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment