Opened 8 years ago

Closed 8 years ago

#7403 closed enhancement (fixed)

adds FiniteEnumeratedSet

Reported by: nthiery Owned by: hivert
Priority: major Milestone: sage-4.3
Component: combinatorics Keywords: finite enumerated sets
Cc: sage-combinat Merged in: sage-4.3.alpha0
Authors: Florent Hivert Reviewers: Nicolas M. Thiéry
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

This patch adds sage.sets.finite_enumerated_set.FiniteEnumeratedSet?

depends on #5891

Attachments (3)

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

Download all attachments as: .zip

Change History (10)

comment:1 Changed 8 years ago by nthiery

  • Status changed from new to needs_review

comment:2 Changed 8 years ago by nthiery

  • Status changed from needs_review to positive_review

Changed 8 years ago by nthiery

Changed 8 years ago by nthiery

Apply only this one (ignore the next one)

comment:3 Changed 8 years 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 8 years ago by hivert

comment:4 Changed 8 years 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

comment:5 Changed 8 years ago by nthiery

  • Status changed from needs_review to positive_review

comment:6 Changed 8 years ago by hivert

  • Owner changed from mhansen to hivert

comment:7 Changed 8 years ago by mhansen

  • Merged in set to sage-4.3.alpha0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.