Opened 10 months ago
Closed 10 months ago
#26659 closed enhancement (fixed)
py3: Fix some doctests errors in sets module for python3
Reported by:  vklein  Owned by:  

Priority:  major  Milestone:  sage8.5 
Component:  python3  Keywords:  thursdaysbdx 
Cc:  slabbe  Merged in:  
Authors:  Vincent Klein  Reviewers:  Sébastien Labbé 
Report Upstream:  N/A  Work issues:  
Branch:  b29f12e (Commits)  Commit:  b29f12e9db52552df0b6403642fa1dae91630df2 
Dependencies:  Stopgaps: 
Description
Fix doctests errors and / or output order issues.
Change History (10)
comment:1 Changed 10 months ago by
 Keywords thursdaysbdx added
comment:2 Changed 10 months ago by
 Cc slabbe added
comment:3 Changed 10 months ago by
comment:4 Changed 10 months ago by
 Branch set to u/vklein/py3__fix_sets_module_for_python3
comment:5 Changed 10 months ago by
 Commit set to b29f12e9db52552df0b6403642fa1dae91630df2
@reviewer: Related to boussica comment:3. The test : sage: [next(it_breadth) for _ in range(10)]
line 70 file recursively_enumerated_set.pyx
give different results in py2 and py3 because of that problem.
For now i have modified the test on 13 elements instead of 10 in order to have all elements "of depth 2 and less" in all cases.
New commits:
b29f12e  Trac #26659: Py3 Fix doctests in sets module

comment:6 Changed 10 months ago by
 Summary changed from py3: Fix sets module for python3 to py3: Fix some doctests errors in sets module for python3
comment:7 Changed 10 months ago by
comment:8 Changed 10 months ago by
 Status changed from new to needs_review
comment:9 Changed 10 months ago by
 Reviewers set to Sébastien Labbé
 Status changed from needs_review to positive_review
comment:10 Changed 10 months ago by
 Branch changed from u/vklein/py3__fix_sets_module_for_python3 to b29f12e9db52552df0b6403642fa1dae91630df2
 Resolution set to fixed
 Status changed from positive_review to closed
Note: See
TracTickets for help on using
tickets.
@slabbe In the method breadth_first_search_iterator(self,max_depth=None), the algorithm uses a python set to determine the next elements to discover. As we have no information on those elements, it is correct to use generic set. The problem is that python3 is not determinist when it iterates on elements of a set.
This feature make the tests complex : we need to guess all the possibilities and accept all the correct answers.
A solution is to have a parameter 'order=None'. If the parameter is None, the implementation doesn't change. If order is a function giving a total order on the elements of the set, then, the algorithm will discover all the elements by choosing elements (when needed) with the help of that order.