Skip to content

RuntimeError: dictionary changed size during iteration#2

Open
antoniosarosi wants to merge 1 commit into
DavidLlorens:masterfrom
antoniosarosi:duplicates
Open

RuntimeError: dictionary changed size during iteration#2
antoniosarosi wants to merge 1 commit into
DavidLlorens:masterfrom
antoniosarosi:duplicates

Conversation

@antoniosarosi
Copy link
Copy Markdown

@antoniosarosi antoniosarosi commented Nov 19, 2020

Al crear un WeightingFunction que sea symmetrical con claves duplicadas, intenta borrar claves del mapa mientras itera sobre keys():

for (u, v) in self._map.keys():
    if (v, u) in self._map:
        # ...
        if v != u: del self._map[v, u]

Ejemplo:

wf = WeightingFunction({('A', 'B'): 1, ('B', 'A'): 1, ('C', 'D'): 2}, symmetrical=True)
# RuntimeError: dictionary changed size during iteration

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant