Skip to content

Commit 64ed09b

Browse files
authored
Merge pull request #123 from CitrineInformatics/feature/multi-unit
Modify Strehlow & Cook to have heterogeneous units
2 parents 2602f73 + 18eb705 commit 64ed09b

File tree

2 files changed

+20
-5
lines changed

2 files changed

+20
-5
lines changed

gemd/demo/strehlow_and_cook.py

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
from gemd.enumeration.origin import Origin
3030

31+
from gemd.units import convert_units
3132

3233
# For now, module constant, though likely this should get promoted to a package level
3334
DEMO_TEMPLATE_SCOPE = 'citrine-demo-sac-template'
@@ -204,10 +205,24 @@ def make_strehlow_objects(table=None, template_scope=DEMO_TEMPLATE_SCOPE):
204205
def real_mapper(prop):
205206
"""Mapping methods for RealBounds."""
206207
if 'uncertainty' in prop['scalars'][0]:
207-
val = NormalReal(mean=float(prop['scalars'][0]['value']),
208-
units=prop['units'],
209-
std=float(prop['scalars'][0]['uncertainty'])
210-
)
208+
if prop['units'] == 'eV': # Arbitrarily convert to attojoules
209+
mean = convert_units(value=float(prop['scalars'][0]['value']),
210+
starting_unit=prop['units'],
211+
final_unit='aJ'
212+
)
213+
std = convert_units(value=float(prop['scalars'][0]['value']),
214+
starting_unit=prop['units'],
215+
final_unit='aJ'
216+
)
217+
val = NormalReal(mean=mean,
218+
units='aJ',
219+
std=std
220+
)
221+
else:
222+
val = NormalReal(mean=float(prop['scalars'][0]['value']),
223+
units=prop['units'],
224+
std=float(prop['scalars'][0]['uncertainty'])
225+
)
211226
else:
212227
val = NominalReal(nominal=float(prop['scalars'][0]['value']),
213228
units=prop['units']

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def run(self):
3636

3737

3838
setup(name='gemd',
39-
version='0.14.2',
39+
version='0.14.3',
4040
url='http://github.com/CitrineInformatics/gemd-python',
4141
description="Python binding for Citrine's GEMD data model",
4242
author='Max Hutchinson',

0 commit comments

Comments
 (0)