pylab_ml.common.projectsetup.diclist
- class diclist(**kwargs)[source]
Bases:
listClass for a list of dictionaries, which is used to create the setup-dictionary from the setup-file.
Methods
__init__(**kwargs)append(object, /)Append object to the end of the list.
clear()Remove all items from list.
copy()Return a shallow copy of the list.
count(value, /)Return number of occurrences of value.
extend(iterable, /)Extend list by appending elements from the iterable.
index(value[, start, stop])Return first index of value.
insert(index, object, /)Insert object before index.
keys()Get the keys from the list of dictionaries.
pop([index])Remove and return item at index (default last).
remove(value, /)Remove first occurrence of value.
reverse()Reverse IN PLACE.
run(**kwargs)Call the runmacro from the parent.
sort(*[, key, reverse])Sort the list in ascending order and return None.
values([key])Get the value(s) from the key found in mylist.
- append(object, /)
Append object to the end of the list.
- clear()
Remove all items from list.
- copy()
Return a shallow copy of the list.
- count(value, /)
Return number of occurrences of value.
- extend(iterable, /)
Extend list by appending elements from the iterable.
- index(value, start=0, stop=9223372036854775807, /)
Return first index of value.
Raises ValueError if the value is not present.
- insert(index, object, /)
Insert object before index.
- keys()[source]
Get the keys from the list of dictionaries.
- eg. mylist = [{‘voltage’: 0}, {‘i_clamp’: 0.2}] –> return [‘voltage’, ‘i_clamp’]
mylist = [{‘smu’: [{‘voltage’: 0}, {‘i_clamp’: 0.2}]}] –> return [‘smu’]
- Parameters:
mylist (list) – The list of dictionaries to get the keys from.
- Returns:
result – A list of keys found in the list of dictionaries.
- Return type:
list
- pop(index=-1, /)
Remove and return item at index (default last).
Raises IndexError if list is empty or index is out of range.
- remove(value, /)
Remove first occurrence of value.
Raises ValueError if the value is not present.
- reverse()
Reverse IN PLACE.
- run(**kwargs)[source]
Call the runmacro from the parent.
- Parameters:
mylist (list) – The list of dictionaries to run the macro from.
**kwargs (dict) – Additional keyword arguments to pass to the runmacro function.
- Returns:
result – The result of the runmacro function, or None if the macro could not be run.
- Return type:
any
- sort(*, key=None, reverse=False)
Sort the list in ascending order and return None.
The sort is in-place (i.e. the list itself is modified) and stable (i.e. the order of two equal elements is maintained).
If a key function is given, apply it once to each list item and sort them, ascending or descending, according to their function values.
The reverse flag can be set to sort in descending order.
- values(key=None)[source]
Get the value(s) from the key found in mylist.
- eg. mylist = [{‘voltage’: 0}, {‘i_clamp’: 0.2}] –> values(mylist, ‘voltage’) return 0
mylist = [{‘smu’: [{‘voltage’: 0}, {‘i_clamp’: 0.2}]}] –> values(mylist, ‘smu’) return [{‘voltage’: 0}, {‘i_clamp’: 0.2}]
- Parameters:
mylist (list) – The list of dictionaries to search for the key.
key (str, optional) – The key to search for in the list of dictionaries. If None, all values are returned.
- Returns:
value(s) – The value(s) associated with the key found in the list of dictionaries, or None if the key is not found.
- Return type:
any