Closed fchapoton closed 6 years ago
Branch: u/chapoton/24839
this is not fixing the issue..
Description changed:
---
+++
@@ -1 +1,20 @@
-changing some sums that cause issue when using python3
+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/site-packages/sage/doctest/forker.py", line 557, in _run
+ self.compile_and_execute(example, compiler, test.globs)
+ File "/home/chapoton/sage3/local/lib/python3.6/site-packages/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/site-packages/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/site-packages/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 non-iterator of type 'dict_items'
+```
Similar issue here under python3:
sage: d = DisjointSet(4)
sage: list(d)
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-2-d0c0da2e41ad> in <module>()
----> 1 list(d)
TypeError: iter() returned non-iterator 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)
<dictionary-valueiterator object at 0x7f0306d3f578>
Sigh... I guess it has to be iter(dict.itervalues())
or yield from dict.itervalues()
but I guess that the former will be faster.
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[a-z]
?
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)
There is no need to fix everything on one ticket. In any case, doctests will show what is broken.
Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:
bc7a60c | py3: fixing some iterators |
ok, let us content ourselves here with 3 changes
bot is green
ping ?
Reviewer: Erik Bray
Changed branch from u/chapoton/24839 to bc7a60c
some sums complain when using python3
CC: @jdemeyer @embray
Component: python3
Author: Frédéric Chapoton
Branch/Commit:
bc7a60c
Reviewer: Erik Bray
Issue created by migration from https://trac.sagemath.org/ticket/24839