Ticket #7403 (closed enhancement: fixed)

Opened 4 months ago

Last modified 4 months ago

adds FiniteEnumeratedSet

Reported by: nthiery Owned by: hivert
Priority: major Milestone: sage-4.3
Component: combinatorics Keywords: finite enumerated sets
Cc: sage-combinat Author(s): Florent Hivert
Report Upstream: Reviewer(s): Nicolas M. Thiéry
Merged in: sage-4.3.alpha0 Work issues:

Description

This patch adds sage.sets.finite_enumerated_set.FiniteEnumeratedSet?

depends on #5891

Attachments

trac_7403-finite-enumeratedsets-fh.2.patch Download (6.1 KB) - added by nthiery 4 months ago.
trac_7403-finite-enumeratedsets-fh.patch Download (6.1 KB) - added by nthiery 4 months ago.
Apply only this one (ignore the next one)
trac_7403-finite-enumeratedsets-fh.3.patch Download (6.3 KB) - added by hivert 4 months ago.

Change History

Changed 4 months ago by nthiery

  • status changed from new to needs_review

Changed 4 months ago by nthiery

  • status changed from needs_review to positive_review

Changed 4 months ago by nthiery

Changed 4 months ago by nthiery

Apply only this one (ignore the next one)

Changed 4 months ago by hivert

  • status changed from positive_review to needs_work

Since it's not yet integrated, I take the chance to solve this stupid bug:

sage: FiniteEnumeratedSet([1])
{1,}

I'm re-uploading a patch with the following folded in

diff --git a/sage/sets/finite_enumerated_set.py b/sage/sets/finite_enumerated_set.py
--- a/sage/sets/finite_enumerated_set.py
+++ b/sage/sets/finite_enumerated_set.py
@@ -123,8 +123,13 @@ class FiniteEnumeratedSet(UniqueRepresen
             sage: S = FiniteEnumeratedSet([1,2,3])
             sage: repr(S)
             '{1, 2, 3}'
+            sage: S = FiniteEnumeratedSet([1])
+            sage: repr(S)
+            '{1}'
         """
-        return "{"+str(self._elements)[1:-1] + '}'
+        if len(self._elements) == 1: # avoid printing '{1,}'
+            return "{" + str(self._elements[0]) + '}'
+        return "{" + str(self._elements)[1:-1] + '}'
 
     def __contains__(self, x):
         """

Florent

Changed 4 months ago by hivert

Changed 4 months ago by hivert

  • status changed from needs_work to needs_review

Please Nicolas (or anyone else re-view the small change.

Only trac_7403-finite-enumeratedsets-fh.3.patch should be applied on top of #5891

Cheers,

Florent

Changed 4 months ago by nthiery

  • status changed from needs_review to positive_review

Changed 4 months ago by hivert

  • owner changed from mhansen to hivert

Changed 4 months ago by mhansen

  • status changed from positive_review to closed
  • resolution set to fixed
  • merged set to sage-4.3.alpha0
Note: See TracTickets for help on using tickets.