Skip to content

Commit d0a3fb5

Browse files
committed
Deepcopy before use
1 parent cae9113 commit d0a3fb5

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/simdec/visualization.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import copy
12
import functools
23
import itertools
34
from typing import Literal
@@ -227,16 +228,17 @@ def tableau(
227228
table.rename(columns={"index": "colour"}, inplace=True)
228229

229230
# Default states for 2 or 3
230-
for i, state in enumerate(states):
231+
states_ = copy.deepcopy(states)
232+
for i, state in enumerate(states_):
231233
if isinstance(state, int):
232-
states: list
234+
states_: list
233235
if state == 2:
234-
states[i] = ["low", "high"]
236+
states_[i] = ["low", "high"]
235237
elif state == 3:
236-
states[i] = ["low", "medium", "high"]
238+
states_[i] = ["low", "medium", "high"]
237239

238240
# get the list of states
239-
gen_states = [range(x) if isinstance(x, int) else x for x in states]
241+
gen_states = [range(x) if isinstance(x, int) else x for x in states_]
240242
states_ = np.asarray(list(itertools.product(*gen_states)))
241243
for i, var_name in enumerate(var_names):
242244
table.insert(loc=i + 1, column=var_name, value=states_[:, i])

0 commit comments

Comments
 (0)