Skip to content
This repository was archived by the owner on Jul 20, 2025. It is now read-only.

Commit 0bd2d10

Browse files
committed
Update a test script
1 parent 6aaece4 commit 0bd2d10

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

mpds_ml_labs/test_props_client.py

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,39 @@
7070
for prop_id, pdata in prop_models.items():
7171
tpl_query.update({'props': pdata['name']})
7272
try:
73-
resp = client.get_dataframe(tpl_query)
73+
resp = client.get_dataframe(tpl_query, fields={'P': [
74+
'sample.material.chemical_formula',
75+
'sample.material.phase_id',
76+
'sample.measurement[0].property.scalar',
77+
'sample.measurement[0].property.units',
78+
'sample.measurement[0].condition[0].units',
79+
'sample.measurement[0].condition[0].name',
80+
'sample.measurement[0].condition[0].scalar'
81+
]}, columns=['Compound', 'Phase', 'Value', 'Units', 'Cunits', 'Cname', 'Cvalue'])
7482
except APIError as e:
7583
prop_models[prop_id]['factual'] = None
76-
if e.code != 1:
84+
if e.code != 204:
7785
print("While checking against the MPDS an error %s occured" % e.code)
7886
continue
87+
if prop_id not in ['m', 'd']:
88+
to_drop = resp[
89+
(resp['Cname'] == 'Temperature') & (resp['Cunits'] == 'K') & ((resp['Cvalue'] < 200) | (resp['Cvalue'] > 400))
90+
]
91+
resp.drop(to_drop.index, inplace=True)
92+
if resp.empty:
93+
prop_models[prop_id]['factual'] = None
94+
continue
7995

8096
resp['Value'] = resp['Value'].astype('float64') # to treat values out of bounds given as str
8197
resp = resp[resp['Units'] == pdata['units']]
8298
prop_models[prop_id]['factual'] = np.median(resp['Value'])
8399

84100
for prop_id, pdata in answer['prediction'].items():
101+
if prop_id == 't':
102+
# normalization 10**5
103+
pdata['value'] /= 100000
104+
pdata['mae'] /= 100000
105+
85106
print("{0:40} = {1:6}, factual {2:8} (MAE = {3:4}), {4}".format(
86107
prop_models[prop_id]['name'],
87108
'conductor' if pdata['value'] == 0 and prop_id == 'w' else pdata['value'],

0 commit comments

Comments
 (0)