Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#26684 closed enhancement (fixed)

py3: fixing round in random graph generator

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.5
Component: python3 Keywords:
Cc: dcoudert Merged in:
Authors: Frédéric Chapoton Reviewers: David Coudert
Report Upstream: N/A Work issues:
Branch: 44f639c (Commits, GitHub, GitLab) Commit:
Dependencies: Stopgaps:

Status badges


Change History (6)

comment:1 Changed 4 years ago by chapoton

  • Branch set to u/chapoton/26684
  • Commit set to 44f639ccd0f6618e98715f86479f56890a935225
  • Status changed from new to needs_review

New commits:

44f639cpy3: fixing round in random graph generator

comment:2 Changed 4 years ago by dcoudert

  • Reviewers set to David Coudert

Why do we need to convert to float before rounding ?

comment:3 Changed 4 years ago by chapoton

because in python3, round calls __round__ which only exists for float. Sigh.

comment:4 Changed 4 years ago by dcoudert

  • Status changed from needs_review to positive_review

Ok... I suspect that in Python4 we will have to declare types :P


comment:5 Changed 4 years ago by vbraun

  • Branch changed from u/chapoton/26684 to 44f639ccd0f6618e98715f86479f56890a935225
  • Resolution set to fixed
  • Status changed from positive_review to closed

comment:6 Changed 4 years ago by chapoton

  • Commit 44f639ccd0f6618e98715f86479f56890a935225 deleted

I am getting this on 8.5.b6:

sage -t --long --warn-long 55.0 src/sage/graphs/generators/
File "src/sage/graphs/generators/", line 907, in sage.graphs.generators.random.connecting_nodes
Failed example:
    S = connecting_nodes(T, 5)
Exception raised:
    Traceback (most recent call last):
      File "/home/chapoton/sage/local/lib/python2.7/site-packages/sage/doctest/", line 671, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/chapoton/sage/local/lib/python2.7/site-packages/sage/doctest/", line 1086, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.graphs.generators.random.connecting_nodes[2]>", line 1, in <module>
        S = connecting_nodes(T, Integer(5))
      File "/home/chapoton/sage/local/lib/python2.7/site-packages/sage/graphs/generators/", line 973, in connecting_nodes
    UnboundLocalError: local variable 'Ti' referenced before assignment
Version 0, edited 4 years ago by chapoton (next)
Note: See TracTickets for help on using tickets.