Opened 6 years ago
Closed 6 years ago
#21257 closed enhancement (fixed)
py3: do not use ifilterfalse, izip_longest, ifilter
Reported by:  chapoton  Owned by:  

Priority:  major  Milestone:  sage7.4 
Component:  python3  Keywords:  
Cc:  Merged in:  
Authors:  Frédéric Chapoton  Reviewers:  Travis Scrimshaw 
Report Upstream:  N/A  Work issues:  
Branch:  0e12eb0 (Commits, GitHub, GitLab)  Commit:  0e12eb077db56d239a1ab21d91a32b76c06d89ac 
Dependencies:  Stopgaps: 
Description
replace them using six.moves
Change History (9)
comment:1 Changed 6 years ago by
 Branch set to u/chapoton/21257
 Commit set to c7b05ff737e1b6a3f5d70b34a1b639f2a50cc26b
 Status changed from new to needs_review
comment:2 Changed 6 years ago by
 Commit changed from c7b05ff737e1b6a3f5d70b34a1b639f2a50cc26b to 2d80c2547ab5b4034d0140c6f8529cd526d89683
Branch pushed to git repo; I updated commit sha1. New commits:
2d80c25  trac 21257 get rid also of ifilter

comment:3 Changed 6 years ago by
 Summary changed from py3: do not use ifilterfalse and izip_longest to py3: do not use ifilterfalse, izip_longest, ifilter
comment:4 Changed 6 years ago by
Let's go to something avoid six
in permutation.py
:
if k > len(self): return 0  incr_iterator = itertools.ifilter( lambda pos: all( pos[i] < pos[i+1]  for i in range(k1) ),  itertools.combinations(self, k) )  return sum(1 for _ in incr_iterator) + return sum(1 for pos in itertools.combinations(self, k) + if all(pos[i] < pos[i+1] for i in range(k1)))
and in tutorial.py
:
 sage: list(itertools.ifilter(lambda z: z.has_pattern([1,2]),  ....: Permutations(3))) + sage: [z for z in Permutations(3) if z.has_pattern([1,2])]
Also I think it might be good to either outright remove the ifilter
(and imap
) in tutorialcomprehensions.rst
or put a note saying they are no longer supported in Python 3 and to avoid using them because Sage will eventually switch to Python 3.
comment:5 Changed 6 years ago by
 Commit changed from 2d80c2547ab5b4034d0140c6f8529cd526d89683 to 49f6c3594f20de7097434cafa3417f2ea668af24
Branch pushed to git repo; I updated commit sha1. New commits:
49f6c35  trac 21257 some of reviewer's comments

comment:6 Changed 6 years ago by
 Commit changed from 49f6c3594f20de7097434cafa3417f2ea668af24 to 0e12eb077db56d239a1ab21d91a32b76c06d89ac
Branch pushed to git repo; I updated commit sha1. New commits:
0e12eb0  trac 21257 another reviewer suggestion

comment:7 Changed 6 years ago by
I did the change in permutation, and tried to enhance the wording in tutorials.
comment:8 Changed 6 years ago by
 Reviewers set to Travis Scrimshaw
 Status changed from needs_review to positive_review
Thanks.
comment:9 Changed 6 years ago by
 Branch changed from u/chapoton/21257 to 0e12eb077db56d239a1ab21d91a32b76c06d89ac
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
py3: handling ifilterfalse and izip_longest