From 325bd733f2d1af8ed861d865d24cbad98b552007 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel <birte.friesel@uos.de> Date: Thu, 11 Jan 2024 08:24:03 +0100 Subject: I need more coffee --- lib/utils.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'lib') diff --git a/lib/utils.py b/lib/utils.py index 8fb1f47..40d8b69 100644 --- a/lib/utils.py +++ b/lib/utils.py @@ -219,6 +219,24 @@ def remove_index_from_tuple(parameters, index): return (*parameters[:index], *parameters[index + 1 :]) +def remove_indexes_from_tuple(parameters, indexes): + """ + Remove the elements at `indexes` from tuple `parameters`. + + :param parameters: tuple + :param indexes: list or tuple: indexes of element which are to be removed + :returns: parameters tuple without the elements at indexes + """ + indexes = sorted(indexes) + ret = list() + last_index = 0 + for index in indexes: + ret.extend(parameters[last_index:index]) + last_index = index + 1 + ret.extend(parameters[last_index:]) + return tuple(ret) + + def param_slice_eq(a, b, index): """ Check if by_param keys a and b are identical, ignoring the parameter at index. -- cgit v1.2.3