axes_to_array defaults to converting to int

This commit is contained in:
Joel Collins 2019-02-12 11:27:42 +00:00
parent c86d194c8c
commit 35041af234

View file

@ -26,7 +26,7 @@ def set_properties(obj, **kwargs):
setattr(obj, k, v)
def axes_to_array(coordinate_dictionary, axis_keys=('x', 'y', 'z'), base_array=None):
def axes_to_array(coordinate_dictionary, axis_keys=('x', 'y', 'z'), base_array=None, asint=True):
"""Takes key-value pairs of a JSON value, and maps onto an array"""
# If no base array is given
if not base_array:
@ -39,7 +39,7 @@ def axes_to_array(coordinate_dictionary, axis_keys=('x', 'y', 'z'), base_array=N
# Do the mapping
for axis, key in enumerate(axis_keys):
if key in coordinate_dictionary:
base_array[axis] = coordinate_dictionary[key]
base_array[axis] = int(coordinate_dictionary[key]) if asint else coordinate_dictionary[key]
return base_array