General Helper Functions

user_errors_group

autoprotocol_utilities.misc_helpers.user_errors_group(error_msgs, info=None)[source]

Takes a list error messages and neatly displays as a single UserError

Will automatically remove instances of None and only report errors if list is not empty.

Parameters:error_msgs (list) – List of strings that are the error messages
Raises:ValueError – If error_msgs is not of type list

char_limit

autoprotocol_utilities.misc_helpers.char_limit(label, length=22, trunc=False, clip=False)[source]

Enforces a string limit on the label provided

Can either throw an error message if length is exceeded or correct the string and return the corrected string.

Parameters:
  • label (str) – String to test.
  • length (int, optional) – Maximum label length for this string. Default: 22.
  • trunc (bool, optional) – Truncate the label if it is too long. Default: False.
  • clip (bool, optional) – Clip the label (remove from beginning of the string) if it is too long Default: False. If both trunc and clip are True, trunc will take effect and not clip.
Returns:

label (str) and error_message (string) that is empty on success label is the unmodified, truncated to clipped label as indicated

Return type:

namedtuple

Raises:

ValueError – If label is not of type string

det_new_group

autoprotocol_utilities.misc_helpers.det_new_group(i, base=0)[source]

Determine if new_group should be added to pipetting operation.

Helper to determine if new_group should be added. Returns true when ‘i’ matches the base, which defaults to 0.

Parameters:
  • i (int) – The iteration you are on.
  • base (int, optional) – The value at which you want to trigger a new group. Default: 0.
Returns:

True if iteration equals base case.

Return type:

bool

Raises:
  • ValueError – If i is not of type integer
  • ValueError – If base is not of type integer

printdatetime

autoprotocol_utilities.misc_helpers.printdatetime()[source]

Generate a datetime string.

Returns:The current date and time formatted as: YYYY-MM-DD_HH-MM-SS
Return type:str

printdate

autoprotocol_utilities.misc_helpers.printdate()[source]

Generate a date string.

Returns:The current date formatted as: YYYY-MM-DD
Return type:str

make_list

autoprotocol_utilities.misc_helpers.make_list(my_str, integer=False)[source]

Return a list of strings (or ints) from a string containing comma separated elements.

Parameters:
  • my_str (str) – String with individual elements separated by comma.
  • interger (bool) – If true list of integers instead of list of strings is returned. Default: False.
Returns:

List of strings or integers

Return type:

list

Raises:

ValueError – If my_str is not of type string

flatten_list

autoprotocol_utilities.misc_helpers.flatten_list(l)[source]

Flatten a list recursively without for loops or additional modules

Example Usage:

from autoprotocol_utilities.misc_helpers import flatten_list

l = [-1, 0, [1,2], "string", [3, [4, 5]]]
flatten_list(l)

Returns:

[-1, 0, 1, 2, 'string', 3, 4, 5]
Parameters:l (list, list of WellGroup) – List or list of WellGroups to flatten
Returns:Flat list
Return type:list
Raises:ValueError – If l is not of type list