From 123e0282fdb1684295f67d9f4fcc3e404b19a439 Mon Sep 17 00:00:00 2001 From: Shyam Dwaraknath Date: Thu, 30 Jan 2020 17:34:12 -0800 Subject: [PATCH] fix query string --- src/mp_api/xas/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/mp_api/xas/api.py b/src/mp_api/xas/api.py index df55c02b..03da2a96 100644 --- a/src/mp_api/xas/api.py +++ b/src/mp_api/xas/api.py @@ -65,7 +65,7 @@ async def search_xas( store.connect() query = { "edge": edge.value if edge else None, - "absorbing_element": absorbing_element, + "absorbing_element": str(absorbing_element) if absorbing_element else None, "chemsys": chemsys, "elements": {"$all": [str(e) for e in elements]} if elements else None, } @@ -77,11 +77,12 @@ async def search_xas( print(e) # Return HTTP error? - query = {k: str(v) for k, v in query.items() if v} + query = {k: v for k, v in query.items() if v} if int(limit) > 500: limit = 500 + print(query) to_return = [ XASSearchResponse( task_id=d["task_id"], @@ -122,7 +123,7 @@ async def count_xas( store.connect() query = { "edge": edge.value if edge else None, - "absorbing_element": absorbing_element, + "absorbing_element": str(absorbing_element) if absorbing_element else None, "chemsys": chemsys, "elements": {"$all": [str(e) for e in elements]} if elements else None, } @@ -134,7 +135,7 @@ async def count_xas( print(e) # Return HTTP error? - query = {k: str(v) for k, v in query.items() if v} + query = {k: v for k, v in query.items() if v} return store.count(query)