Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Category membership, without arguments #9469

Closed
nthiery opened this issue Jul 10, 2010 · 11 comments
Closed

Category membership, without arguments #9469

nthiery opened this issue Jul 10, 2010 · 11 comments

Comments

@nthiery
Copy link
Contributor

nthiery commented Jul 10, 2010

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)

CC: @sagetrac-sage-combinat

Component: categories

Keywords: Cernay2012

Author: Nicolas M. Thiéry

Reviewer: Florent Hivert

Merged: sage-5.0.beta6

Issue created by migration from https://trac.sagemath.org/ticket/9469

@nthiery nthiery added this to the sage-5.0 milestone Jul 10, 2010
@nthiery nthiery self-assigned this Jul 10, 2010
@nthiery

This comment has been minimized.

@nthiery
Copy link
Contributor Author

nthiery commented Feb 9, 2012

Changed keywords from none to Cernay2012

@nthiery
Copy link
Contributor Author

nthiery commented Feb 9, 2012

comment:4

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

@nthiery
Copy link
Contributor Author

nthiery commented Feb 9, 2012

comment:5

Florent wants to add a pointer to the feature elsewhere

@hivert
Copy link

hivert commented Feb 10, 2012

comment:7

The new patch is Ok with me.

@nthiery
Copy link
Contributor Author

nthiery commented Feb 18, 2012

comment:8

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?

@nthiery
Copy link
Contributor Author

nthiery commented Feb 18, 2012

comment:10

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

@nthiery
Copy link
Contributor Author

nthiery commented Feb 21, 2012

@nthiery
Copy link
Contributor Author

nthiery commented Feb 21, 2012

comment:11

I backported here your fix to the Category object link

@hivert
Copy link

hivert commented Feb 21, 2012

comment:12

The new version is Ok with me !

@jdemeyer
Copy link

Merged: sage-5.0.beta6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants