diff --git a/openflexure_microscope/__init__.py b/openflexure_microscope/__init__.py index 35033908..0b72e60d 100644 --- a/openflexure_microscope/__init__.py +++ b/openflexure_microscope/__init__.py @@ -2,4 +2,5 @@ __all__ = ['Microscope', 'config'] __version__ = "0.1.0" from .microscope import Microscope -from . import config \ No newline at end of file +from . import config +from . import utilities \ No newline at end of file diff --git a/openflexure_microscope/api/utilities.py b/openflexure_microscope/api/utilities.py index 90262048..cfe9ea20 100644 --- a/openflexure_microscope/api/utilities.py +++ b/openflexure_microscope/api/utilities.py @@ -43,24 +43,6 @@ class JsonPayload: return val -def axes_to_array(coordinate_dictionary, axis_keys=['x', 'y', 'z'], base_array=None): - """Takes key-value pairs of a JSON value, and maps onto an array""" - # If no base array is given - if not base_array: - # Create an array of zeros - base_array = [0]*len(axis_keys) - else: - # Create a copy of the passed base_array - base_array = copy.copy(base_array) - - # Do the mapping - for axis, key in enumerate(axis_keys): - if key in coordinate_dictionary: - base_array[axis] = coordinate_dictionary[key] - - return base_array - - def gen(camera): """Video streaming generator function.""" while True: diff --git a/openflexure_microscope/utilities.py b/openflexure_microscope/utilities.py new file mode 100644 index 00000000..4e01a85f --- /dev/null +++ b/openflexure_microscope/utilities.py @@ -0,0 +1,18 @@ +import copy + +def axes_to_array(coordinate_dictionary, axis_keys=['x', 'y', 'z'], base_array=None): + """Takes key-value pairs of a JSON value, and maps onto an array""" + # If no base array is given + if not base_array: + # Create an array of zeros + base_array = [0]*len(axis_keys) + else: + # Create a copy of the passed base_array + base_array = copy.copy(base_array) + + # Do the mapping + for axis, key in enumerate(axis_keys): + if key in coordinate_dictionary: + base_array[axis] = coordinate_dictionary[key] + + return base_array \ No newline at end of file