From 982fc6f638d05378b5f558ddfb37ca77e90f0078 Mon Sep 17 00:00:00 2001
From: leufen1 <l.leufen@fz-juelich.de>
Date: Tue, 1 Dec 2020 15:36:08 +0100
Subject: [PATCH] helper to list can now transform sets to lists in addition

---
 mlair/helpers/helpers.py | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mlair/helpers/helpers.py b/mlair/helpers/helpers.py
index 36470ebc..d07d8cf1 100644
--- a/mlair/helpers/helpers.py
+++ b/mlair/helpers/helpers.py
@@ -12,13 +12,15 @@ from typing import Dict, Callable, Union, List, Any
 
 def to_list(obj: Any) -> List:
     """
-    Transform given object to list if obj is not already a list.
+    Transform given object to list if obj is not already a list. Sets are also transformed to a list.
 
     :param obj: object to transform to list
 
     :return: list containing obj, or obj itself (if obj was already a list)
     """
-    if not isinstance(obj, list):
+    if isinstance(obj, set):
+        obj = list(obj)
+    elif not isinstance(obj, list):
         obj = [obj]
     return obj
 
@@ -99,7 +101,7 @@ def remove_items(obj: Union[List, Dict], items: Any):
         raise TypeError(f"{inspect.stack()[0][3]} does not support type {type(obj)}.")
 
 
-def select_from_dict(dict_obj: dict, sel_list: str):
+def select_from_dict(dict_obj: dict, sel_list: Any):
     """
     Extract all key values pairs whose key is contained in the sel_list.
 
-- 
GitLab