Opened 3 years ago
Closed 3 years ago
#24839 closed enhancement (fixed)
py3: an issue about dict iterators
Reported by:  chapoton  Owned by:  

Priority:  major  Milestone:  sage8.2 
Component:  python3  Keywords:  
Cc:  jdemeyer, embray  Merged in:  
Authors:  Frédéric Chapoton  Reviewers:  Erik Bray 
Report Upstream:  N/A  Work issues:  
Branch:  bc7a60c (Commits, GitHub, GitLab)  Commit:  bc7a60c9b4ba16d92a52df09f6930d5424652fb1 
Dependencies:  Stopgaps: 
Description (last modified by )
some sums complain when using python3
File "src/sage/combinat/crystals/multisegments.py", line 432, in sage.combinat.crystals.multisegments.InfinityCrystalOfMultisegments.Element.phi Failed example: mg.f(1).phi(0) Exception raised: Traceback (most recent call last): File "/home/chapoton/sage3/local/lib/python3.6/sitepackages/sage/doctest/forker.py", line 557, in _run self.compile_and_execute(example, compiler, test.globs) File "/home/chapoton/sage3/local/lib/python3.6/sitepackages/sage/doctest/forker.py", line 967, in compile_and_execute exec(compiled, globs) File "<doctest sage.combinat.crystals.multisegments.InfinityCrystalOfMultisegments.Element.phi[5]>", line 1, in <module> mg.f(Integer(1)).phi(Integer(0)) File "/home/chapoton/sage3/local/lib/python3.6/sitepackages/sage/combinat/crystals/multisegments.py", line 436, in phi return self.epsilon(i) + self.weight().scalar(h[i]) File "/home/chapoton/sage3/local/lib/python3.6/sitepackages/sage/combinat/root_system/weight_space.py", line 506, in scalar return BR.sum(self[i] * c for (i, c) in lambdacheck) TypeError: iter() returned noniterator of type 'dict_items'
Change History (17)
comment:1 Changed 3 years ago by
 Branch set to u/chapoton/24839
 Cc tscrim added
 Commit set to 52eee770d21b90ea9616c9d213f73a7da7504612
 Status changed from new to needs_review
comment:2 Changed 3 years ago by
 Status changed from needs_review to needs_work
this is not fixing the issue..
comment:3 Changed 3 years ago by
 Description modified (diff)
 Summary changed from detail in weight space to issue in weight_space
comment:4 Changed 3 years ago by
 Cc jdemeyer added; tscrim removed
 Status changed from needs_work to needs_info
Similar issue here under python3:
sage: d = DisjointSet(4) sage: list(d)  TypeError Traceback (most recent call last) <ipythoninput2d0c0da2e41ad> in <module>() > 1 list(d) TypeError: iter() returned noniterator of type 'dict_values'
where the code is
return (<dict?>self.root_to_elements_dict()).itervalues()
that under python2 returns
sage: d = DisjointSet(4) sage: iter(d) <dictionaryvalueiterator object at 0x7f0306d3f578>
comment:5 Changed 3 years ago by
 Summary changed from issue in weight_space to py3: an issue about dict iterators
comment:6 Changed 3 years ago by
 Component changed from combinatorics to python3
comment:7 Changed 3 years ago by
Sigh... I guess it has to be iter(dict.itervalues())
or yield from dict.itervalues()
but I guess that the former will be faster.
comment:8 Changed 3 years ago by
Eurk. Ugly enough, indeed. No hope that Cython could do that for us ?
How to find all instances of this problem ? Maybe by looking for pyx files containing both __iter__
and .iter[az]
?
comment:9 Changed 3 years ago by
Potential list
crypto/boolean_function.pyx (✓) libs/gap/element.pyx algebras/letterplace/free_algebra_element_letterplace.pyx algebras/lie_algebras/lie_algebra_element.pyx plot/plot3d/index_face_set.pyx ext/fast_eval.pyx numerical/linear_functions.pyx misc/weak_dict.pyx rings/polynomial/polydict.pyx rings/polynomial/laurent_polynomial.pyx rings/polynomial/pbori.pyx rings/polynomial/multi_polynomial.pyx rings/polynomial/polynomial_element.pyx rings/power_series_mpoly.pyx sets/disjoint_set.pyx (todo) quivers/algebra_elements.pyx (✓) modules/with_basis/indexed_element.pyx symbolic/expression.pyx
found using
grep l "def.*__iter__" $(grep l R "\.iter[ivk]" include=*.pyx)
comment:10 Changed 3 years ago by
There is no need to fix everything on one ticket. In any case, doctests will show what is broken.
comment:11 Changed 3 years ago by
 Commit changed from 52eee770d21b90ea9616c9d213f73a7da7504612 to bc7a60c9b4ba16d92a52df09f6930d5424652fb1
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
bc7a60c  py3: fixing some iterators

comment:12 Changed 3 years ago by
 Status changed from needs_info to needs_review
ok, let us content ourselves here with 3 changes
comment:13 Changed 3 years ago by
bot is green
comment:14 Changed 3 years ago by
ping ?
comment:15 Changed 3 years ago by
 Cc embray added
comment:16 Changed 3 years ago by
 Reviewers set to Erik Bray
 Status changed from needs_review to positive_review
comment:17 Changed 3 years ago by
 Branch changed from u/chapoton/24839 to bc7a60c9b4ba16d92a52df09f6930d5424652fb1
 Resolution set to fixed
 Status changed from positive_review to closed
New commits:
trac 24839 changing sums in weight_space