From 2a63511d87922bc6f71e17535317ff828719addd Mon Sep 17 00:00:00 2001 From: Junho Lee Date: Fri, 1 Sep 2023 17:40:42 -0400 Subject: [PATCH] Add type guards for random_state --- dataprofiler/labelers/data_processing.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dataprofiler/labelers/data_processing.py b/dataprofiler/labelers/data_processing.py index 1ef95587e..b8d3b34c8 100644 --- a/dataprofiler/labelers/data_processing.py +++ b/dataprofiler/labelers/data_processing.py @@ -1555,8 +1555,7 @@ def __init__( random_state = random.Random(random_state) elif isinstance(random_state, (list, tuple)) and len(random_state) == 3: # tuple required for random state to be set, lists do not work - if isinstance(random_state[1], list): - random_state = list(random_state) + if isinstance(random_state[1], list) and isinstance(random_state, list): random_state[1] = tuple(random_state[1]) if isinstance(random_state, list): random_state = tuple(random_state) @@ -1895,8 +1894,7 @@ def __init__( random_state = random.Random(random_state) elif isinstance(random_state, (list, tuple)) and len(random_state) == 3: # tuple required for random state to be set, lists do not work - if isinstance(random_state[1], list): - random_state = list(random_state) + if isinstance(random_state[1], list) and isinstance(random_state, list): random_state[1] = tuple(random_state[1]) if isinstance(random_state, list): random_state = tuple(random_state)