sagemath/sage

map_reduce failing on IntegerVectorsModPermutationGroup

Opened this issue · 1 comments

IntegerVectorsModPermutationGroup elements are generated recursively
along a search tree. Alas, the map_reduce feature of
RecursivelyEnumeratedSets/SearchForest is broken:

sage: G = CyclicPermutationGroup(5)
sage: V = IntegerVectorsModPermutationGroup(G)
sage: V.map_reduce(lambda x: 1, operator.add, 0)
...
AttributeError: 'IntegerVectorsModPermutationGroup_All_with_category'
object has no attribute '_roots'

That seems to be because the SearchForest structure in V is not fully
initialized, or alternatively SearchForest and RESetMapReduce don't
quite agree on the API to recover the roots: f.roots() or f._roots.

Let's fix that for now:

sage: V._roots = V.roots()

Still does not work:

sage: V.map_reduce(lambda x: 1, operator.add, 0)
Process RESetMapReduceWorker-4:
Traceback (most recent call last):
...
assert max(self) <= self.parent()._max_part,
'Entries of %s must be inferiors to %s'%(self, self.parent()._max_part)
...

Plausibly that's because the postprocessing is not initialized
properly; so internal nodes in the trees get converted into end
results when they should not.

CC: @hivert @sagetrac-nborie @seblabbe @slel

Component: combinatorics

Issue created by migration from https://trac.sagemath.org/ticket/22184

slel commented

Description changed:

--- 
+++ 
@@ -3,35 +3,37 @@
 `RecursivelyEnumeratedSets/SearchForest` is broken:
 
 ```
-    sage: G = CyclicPermutationGroup(5)
-    sage: V = IntegerVectorsModPermutationGroup(G)
-    sage: V.map_reduce(lambda x: 1, operator.add, 0)
-    ...
-    AttributeError: 'IntegerVectorsModPermutationGroup_All_with_category' object has no attribute '_roots'
+sage: G = CyclicPermutationGroup(5)
+sage: V = IntegerVectorsModPermutationGroup(G)
+sage: V.map_reduce(lambda x: 1, operator.add, 0)
+...
+AttributeError: 'IntegerVectorsModPermutationGroup_All_with_category'
+object has no attribute '_roots'
 ```
 
-That seems to be because the SearchForest structure in V is not fully
-initialized (or alternatively SearchForest and RESetMapReduce don't
-quite agree on the API to recover the roots: f.roots() or f._roots).
+That seems to be because the `SearchForest` structure in `V` is not fully
+initialized, or alternatively `SearchForest` and `RESetMapReduce` don't
+quite agree on the API to recover the roots: `f.roots()` or `f._roots`.
 
 Let's fix that for now:
 
 ```
-    sage: V._roots = V.roots()
+sage: V._roots = V.roots()
 ```
 
 Still does not work:
 
 ```
-    sage: V.map_reduce(lambda x: 1, operator.add, 0)
-    Process RESetMapReduceWorker-4:
-    Traceback (most recent call last):
-    ...
-    assert max(self) <= self.parent()._max_part, 'Entries of %s must be inferiors to %s'%(self, self.parent()._max_part)
+sage: V.map_reduce(lambda x: 1, operator.add, 0)
+Process RESetMapReduceWorker-4:
+Traceback (most recent call last):
+...
+assert max(self) <= self.parent()._max_part,
+'Entries of %s must be inferiors to %s'%(self, self.parent()._max_part)
 ...
 ```
 
 Plausibly that's because the postprocessing is not initialized
 properly; so internal nodes in the trees get converted into end
-results when the should not.
+results when they should not.