#27582 closed enhancement (fixed)

py3: fix bug in all_paths

Reported by: dcoudert Owned by:
Priority: major Milestone: sage-8.8
Component: graph theory Keywords: py3, graph
Cc: gh-rajat1433 Merged in:
Authors: David Coudert Reviewers: Frédéric Chapoton
Report Upstream: N/A Work issues:
Branch: 934c54d (Commits) Commit: 934c54da862f86d3844b4a7a0f5830f21514a95b
Dependencies: Stopgaps:

Description

With #27501, we introduced an error in all_paths for Python 3. Indeed, my_dict.keys() returns a list in Python 2 but it is an iterator in Python 3, so the following code breaks as the size of the dictionary change during iteration.

                for u, v in my_dict.keys():
                    my_dict[v, u] = my_dict[u, v]

We fix this issue using list(my_dict.keys()). On the way, we also rename my_dict to edge_labels.

Change History (10)

comment:1 Changed 16 months ago by dcoudert

  • Branch set to public/graphs/27582_all_paths
  • Commit set to 4324b87cdad0c79baba49d2565f1689f4b35595e
  • Status changed from new to needs_review

New commits:

4324b87trac #27582: fix bug and rename my_dict as edge_labels

comment:2 Changed 16 months ago by chapoton

you can also remove the .keys()

comment:3 Changed 16 months ago by git

  • Commit changed from 4324b87cdad0c79baba49d2565f1689f4b35595e to 4483ba60722f020ea5b3111497dc02a489cbe271

Branch pushed to git repo; I updated commit sha1. New commits:

4483ba6trac #27582: remove .keys()

comment:4 Changed 16 months ago by dcoudert

Right, done.

comment:5 Changed 16 months ago by chapoton

some .keys() are still there

comment:6 Changed 16 months ago by git

  • Commit changed from 4483ba60722f020ea5b3111497dc02a489cbe271 to 934c54da862f86d3844b4a7a0f5830f21514a95b

Branch pushed to git repo; I updated commit sha1. New commits:

934c54dtrac #27582: remove .keys()

comment:7 Changed 16 months ago by dcoudert

Should be OK now. Thanks.

comment:8 Changed 16 months ago by chapoton

good to go if the patchbot is green

comment:9 Changed 16 months ago by chapoton

  • Reviewers set to Frédéric Chapoton
  • Status changed from needs_review to positive_review

comment:10 Changed 16 months ago by vbraun

  • Branch changed from public/graphs/27582_all_paths to 934c54da862f86d3844b4a7a0f5830f21514a95b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.