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 Modules ~> Algebras #16443

Open
sagetrac-elixyre mannequin opened this issue Jun 5, 2014 · 1 comment
Open

Category Modules ~> Algebras #16443

sagetrac-elixyre mannequin opened this issue Jun 5, 2014 · 1 comment

Comments

@sagetrac-elixyre
Copy link
Mannequin

sagetrac-elixyre mannequin commented Jun 5, 2014

Strange problem:

from sage.categories.category_types import Category_over_base_ring

class A(Category_over_base_ring):
    
    def super_categories(self):
        R = self.base_ring()
        return [Algebras(R]
        #return [Modules(R)]
    
class B(UniqueRepresentation, Parent):
    
    def __init__(self, R):
        Parent.__init__(self, category=A(R))

That fails! (6.2 rc 2):

sage: B(QQ)
...
TypeError: None is not in Category of rings

But if I try to change the super categories:

Algebras(R) --> Modules(R)

That works! What's error mean?

CC: @nthiery

Component: categories

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

@sagetrac-elixyre sagetrac-elixyre mannequin added this to the sage-6.3 milestone Jun 5, 2014
@nthiery
Copy link
Contributor

nthiery commented Jun 5, 2014

comment:1

It in fact does not work either: a parent in Modules(...) should
implement a base_ring method. This method just turns out not to be
called upon initialization if B is just in Modules() instead of
Algebras(), so the problem goes undetected, so far ...

It indeed feels a bit redundant to have to specify the base ring in
the category and in the base_ring method. The thing is that, in the
category, one can now specify something like Algebras(Rings()); I'd
say it's even recommended. So one can't recover the base ring from the
just the category. It's not so bad, because more often than not, when
implementing a module, one inherits from some preexisting module that
implements base_ring for us.

Now, yes, definitely, this all might not be stated explicitly in the
documentation; and the error message is not informative ...

Step that can be taken right away:

  • add a base_ring abstract method in Modules.ParentMethods

Steps that are a bit more tricky (I tried and dropped the case; but I
had to act fast then to get #10963 in):

  • Remove the base_ring method from CategoryObject (it has nothing to
    do there).

  • Implement a base_ring method for all the existing modules
    (polynomials, ...), putting it in common abstract super classes
    whenever possible.

Cheers,
Nicolas

@sagetrac-vbraun-spam sagetrac-vbraun-spam mannequin modified the milestones: sage-6.3, sage-6.4 Aug 10, 2014
@mkoeppe mkoeppe removed this from the sage-6.4 milestone Dec 29, 2022
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

2 participants