Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
janssenhenning committed Nov 21, 2022
1 parent 752471c commit 9f746ec
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
11 changes: 6 additions & 5 deletions aiida/storage/sqlite_zip/orm.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,15 @@ def _cast_json_type(comparator: JSON.Comparator, value: Any) -> Tuple[ColumnElem
if isinstance(value, (list, dict)):
return case((type_filter, casted_entity == func.json(json.dumps(value))), else_=False)
if isinstance(value, complex):
return case(
(type_filter, casted_entity == func.json(json.dumps({
return case((
type_filter, casted_entity
== func.json(json.dumps({
'__complex__': True,
'real': value.real,
'imag': value.imag
}))),
else_=False
)
}))
),
else_=False)
# to-do not working for dict
return case((type_filter, casted_entity == value), else_=False)
if operator == '>':
Expand Down
4 changes: 2 additions & 2 deletions tests/orm/nodes/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,11 +474,11 @@ def test_attribute_complex(self):
self.node.store()
# ensure the returned node is a complex number
assert self.node.base.attributes.get('a_val') == 1.1 + 2.1j

def test_extra_complex(self):
"""Test that the `Node.set_attribute` method supports complex."""
self.node.base.extras.set('a_val', 1.1 + 2.1j)
self.node.store() #Only when stored the complex number is serialized
self.node.store() #Only when stored the complex number is serialized
# ensure the returned node is a complex number
assert self.node.base.extras.get('a_val') == 1.1 + 2.1j

Expand Down

0 comments on commit 9f746ec

Please sign in to comment.