Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 52b91c8

Browse files
author
Release Manager
committed
Trac #31012: Modify RandomChordalGraph according a deprecation warning introduced in Python 3.9
Python 3.9 deprecates the use `sample(population, k)` when `population` is a `set`. {{{ sage: G = graphs.RandomChordalGraph(100) /Users/dcoudert/sage/local/lib/python3.9/site- packages/sage/misc/prandom.py:179: DeprecationWarning: Sampling from a set deprecated since Python 3.9 and will be removed in a subsequent version. return _pyrand().sample(population, k) }}} It was used in `graphs.RandomChordalGraph(...)`, so we change that. URL: https://trac.sagemath.org/31012 Reported by: dcoudert Ticket author(s): David Coudert Reviewer(s): Frédéric Chapoton
2 parents 660cac4 + f5bc021 commit 52b91c8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/sage/graphs/generators/random.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,7 @@ def growing_subtrees(T, k):
867867
sage: len(S)
868868
10
869869
"""
870-
from sage.misc.prandom import sample
870+
from sage.misc.prandom import choice
871871
n = T.order()
872872
S = []
873873
for _ in range(n):
@@ -880,7 +880,7 @@ def growing_subtrees(T, k):
880880
neighbors = set(T.neighbor_iterator(x))
881881
for j in range(ki - 1):
882882
# Select a random neighbor z outside of Ti and add it to Ti
883-
z = sample(neighbors, 1)[0]
883+
z = choice(tuple(neighbors))
884884
Ti.add(z)
885885
neighbors.update(y for y in T.neighbor_iterator(z) if y not in Ti)
886886
Vi = frozenset(Ti)

0 commit comments

Comments
 (0)