Opened 12 years ago

Closed 11 years ago

#9469 closed enhancement (fixed)

Category membership, without arguments

Reported by: Nicolas M. Thiéry Owned by: Nicolas M. Thiéry
Priority: major Milestone: sage-5.0
Component: categories Keywords: Cernay2012
Cc: Sage Combinat CC user Merged in: sage-5.0.beta6
Authors: Nicolas M. Thiéry Reviewers: Florent Hivert
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Nicolas M. Thiéry)

Currently one can do:

    sage: F = FreeModule(QQ,3)
    sage: F in VectorSpaces(QQ)
    True

This patch implements:

    sage: F in VectorSpaces
    True

(and does a couple closeby minor improvements to the doc)

Attachments (1)

trac_9469-category-membership_without_arguments-nt.patch (5.8 KB) - added by Nicolas M. Thiéry 11 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 12 years ago by Nicolas M. Thiéry

Status: newneeds_review

comment:2 Changed 12 years ago by Nicolas M. Thiéry

Status: needs_reviewneeds_work

comment:3 Changed 11 years ago by Nicolas M. Thiéry

Description: modified (diff)
Keywords: Cernay2012 added
Status: needs_workneeds_review

comment:4 Changed 11 years ago by Nicolas M. Thiéry

Status: needs_reviewpositive_review

Patch reviewed by Florent on the Sage-Combinat queue. Positive review on his behalf.

comment:5 Changed 11 years ago by Nicolas M. Thiéry

Status: positive_reviewneeds_work

Florent wants to add a pointer to the feature elsewhere

comment:6 Changed 11 years ago by Nicolas M. Thiéry

Status: needs_workneeds_review

comment:7 Changed 11 years ago by Florent Hivert

Status: needs_reviewpositive_review

The new patch is Ok with me.

comment:8 Changed 11 years ago by Nicolas M. Thiéry

Status: positive_reviewneeds_work

I just stumbled upon the following hunk later in the queue, and thought we might as well fold it into this patch:

diff --git a/sage/categories/category.py b/sage/categories/category.py
--- a/sage/categories/category.py
+++ b/sage/categories/category.py
@@ -627,8 +627,19 @@ class Category(UniqueRepresentation, Sag
 
             sage: F in Algebras
             False
+
+        TESTS:
+
+        Non category object shall be handled properly::
+
+            sage: [1,2] in Algebras
+            False
         """
-        return any(isinstance(cat, cls) for cat in x.categories())
+        try:
+            c = x.categories()
+        except AttributeError:
+            return False
+        return any(isinstance(cat, cls) for cat in c)
 
     def is_abelian(self):
         """

I am running the tests now. Florent: shall I reinstate the positive review if the test pass?

comment:9 Changed 11 years ago by Nicolas M. Thiéry

Status: needs_workneeds_review

comment:10 Changed 11 years ago by Nicolas M. Thiéry

Note: I fixed the missing 's' in 'Non category objects'.

Changed 11 years ago by Nicolas M. Thiéry

comment:11 Changed 11 years ago by Nicolas M. Thiéry

I backported here your fix to the Category object link

comment:12 Changed 11 years ago by Florent Hivert

Status: needs_reviewpositive_review

The new version is Ok with me !

comment:13 Changed 11 years ago by Jeroen Demeyer

Merged in: sage-5.0.beta6
Resolution: fixed
Status: positive_reviewclosed
Note: See TracTickets for help on using tickets.