Skip to content
Snippets Groups Projects

Feat: Optimace CalDB requests

Merged Mikhail Karnevskiy requested to merge feat/update_plotCalDB into master
1 unresolved thread
Files
6
@@ -135,6 +135,50 @@ def recursively_save_dict_contents_to_group(h5file, path, dic):
raise ValueError('Cannot save %s type.' % type(item))
def combine_lists(*args, names=None):
"""
Combine several lists to a list of dictionary or a list of lists
Each dictionary contain a set of elements, one from each list
:param args: several lists to be combined
:param names: list of names (the length equal to the number of args)
:return: list of dictionary of list of lists
Example:
.. code-block:: python
# define input lists
a = [100,200]
b = [0,1,2]
c = [25]
comb = combine_lists(a,b,c)
# comb: [[100, 0, 25], [100, 1, 25], [100, 2, 25],
# [200, 0, 25], [200, 1, 25], [200, 2, 25]]
comb = combine_lists(a,b,c, names=['Voltage', 'Gain', 'Temperature'])
# comb: [{'Voltage': 100, 'Gain': 0, 'Temperature': 25},
# {'Voltage': 100, 'Gain': 1, 'Temperature': 25},
# {'Voltage': 100, 'Gain': 2, 'Temperature': 25},
# {'Voltage': 200, 'Gain': 0, 'Temperature': 25},
# {'Voltage': 200, 'Gain': 1, 'Temperature': 25},
# {'Voltage': 200, 'Gain': 2, 'Temperature': 25}]
"""
params = list(map(tuple, args))
possible_params = [[]]
for param in params:
possible_params = [x + [y] for x in possible_params for y in param]
if isinstance(names, (list, tuple)):
assert len(names) == len(args)
d_possible_params = []
for par in possible_params:
d_possible_params.append(dict(zip(names, par)))
return d_possible_params
return possible_params
def combine_constants(ctimes_a, ctimes_b):
"""
Combine two numpy arrays of timestamp
Loading