On Jun 20, 'Travis Scrimshaw' via sage-devel wrote:
>That definitely is not a bug in CombinatorialFreeModule, so there shouldn't be
>anything changed there. It is doing what it is told: that its indexing set is
>in finite sets. I would say the bug is purely in the
>DisjointUnionEnumeratedSets not doing a full check of its member sets.
I think so too, but I thought that the behaviour for the disjoint union was
intended as this.
Now looking at the code it seems that it wasn't. The checks are for a couple
of reasonable cases, but some corner cases make them fail on both ways.
An infinite union of empty sets is infinite:
sage: F = Family(ZZ, lambda i: Set())
sage: C = DisjointUnionEnumeratedSets(F)
sage: C.category()
Category of facade infinite enumerated sets
In the case of finite families the following simple change seems to check
correctly. But I suppose this can break something, there must've been a reason
to check only the last set.
sage: C = DisjointUnionEnumeratedSets([NonNegativeIntegers(), Family([1,2,3])])
sage: C.category()
Category of facade infinite enumerated sets
$ git diff src/sage/sets/disjoint_union_enumerated_sets.py
diff --git a/src/sage/sets/disjoint_union_enumerated_sets.py b/src/sage/sets/disjoint_union_enumerated_sets.py
index c6d35ea8bd..f5fdba7119 100644
--- a/src/sage/sets/disjoint_union_enumerated_sets.py
+++ b/src/sage/sets/disjoint_union_enumerated_sets.py
@@ -302,7 +302,7 @@ class DisjointUnionEnumeratedSets(UniqueRepresentation, Parent):
# try to guess if the result is infinite or not.
if self._family in InfiniteEnumeratedSets():
category = InfiniteEnumeratedSets()
- elif self._family.last().cardinality() == Infinity:
+ elif any(x.cardinality() == Infinity for x in self._family):
category = InfiniteEnumeratedSets()
else:
category = FiniteEnumeratedSets()
I can't think of a reasonable way of checking against the infinite union of
empty sets.
Best,
R.
> >To view this discussion on the web visit [2][1]
https://groups.google.com/d
> /msgid/
> >sage-devel/aeb3c3ba-c804-428d-9119-2629950be6cbo%[2]
40googlegroups.com.
> >
> >References:
> >
> >[1] mailto:
sage-devel+...@googlegroups.com
> >[2] [3]
https://groups.google.com/d/msgid/sage-devel/
> aeb3c3ba-c804-428d-9119-2629950be6cbo%
40googlegroups.com?utm_medium=email&
> utm_source=footer
>
>
>--
>You received this message because you are subscribed to the Google Groups
>"sage-devel" group.
>To unsubscribe from this group and stop receiving emails from it, send an email
>to [4]
sage-devel+...@googlegroups.com.
>To view this discussion on the web visit [5]
https://groups.google.com/d/msgid/
>sage-devel/9460d061-39db-44b9-90e7-5d348e706bben%
40googlegroups.com.
>
>References:
>
>[1]
https://groups.google.com/d/msgid/
>[2]
http://40googlegroups.com/
>[3]
https://groups.google.com/d/msgid/sage-devel/aeb3c3ba-c804-428d-9119-2629950be6cbo%40googlegroups.com?utm_medium=email&utm_source=footer
>[4] mailto:
sage-devel+...@googlegroups.com
>[5]
https://groups.google.com/d/msgid/sage-devel/9460d061-39db-44b9-90e7-5d348e706bben%40googlegroups.com?utm_medium=email&utm_source=footer