Opened 7 years ago

Closed 5 years ago

#9469 closed enhancement (fixed)

Category membership, without arguments

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

Description (last modified by nthiery)

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 nthiery 5 years ago.

Download all attachments as: .zip

Change History (14)

comment:1 Changed 7 years ago by nthiery

  • Status changed from new to needs_review

comment:2 Changed 7 years ago by nthiery

  • Status changed from needs_review to needs_work

comment:3 Changed 5 years ago by nthiery

  • Description modified (diff)
  • Keywords Cernay2012 added
  • Status changed from needs_work to needs_review

comment:4 Changed 5 years ago by nthiery

  • Status changed from needs_review to positive_review

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

comment:5 Changed 5 years ago by nthiery

  • Status changed from positive_review to needs_work

Florent wants to add a pointer to the feature elsewhere

comment:6 Changed 5 years ago by nthiery

  • Status changed from needs_work to needs_review

comment:7 Changed 5 years ago by hivert

  • Status changed from needs_review to positive_review

The new patch is Ok with me.

comment:8 Changed 5 years ago by nthiery

  • Status changed from positive_review to needs_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 5 years ago by nthiery

  • Status changed from needs_work to needs_review

comment:10 Changed 5 years ago by nthiery

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

comment:11 Changed 5 years ago by nthiery

I backported here your fix to the Category object link

comment:12 Changed 5 years ago by hivert

  • Status changed from needs_review to positive_review

The new version is Ok with me !

comment:13 Changed 5 years ago by jdemeyer

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