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

TensorProductsCategory fails to work in 6.3 #16831

Open
cnassau opened this issue Aug 15, 2014 · 2 comments
Open

TensorProductsCategory fails to work in 6.3 #16831

cnassau opened this issue Aug 15, 2014 · 2 comments

Comments

@cnassau
Copy link

cnassau commented Aug 15, 2014

The following code used to work in Sage 6.0 (up to Sage 6.2 possibly, but can't test it right now):

from sage.categories.category_types import Category_over_base_ring
from sage.categories.tensor import TensorProductsCategory, tensor

class TestCat(Category_over_base_ring):
    @cached_method
    def super_categories(self):
        return []
    class ParentMethods:
        def mytestmthd(self):
            return "ok"
    class TensorProducts(TensorProductsCategory):
        @cached_method
        def extra_super_categories(self):
            return [self.base_category()]
        class ParentMethods:
            def tenstestmthd(self):
                return "ok"

O=CombinatorialFreeModule(RDF,ZZ,category=(ModulesWithBasis(RDF),TestCat(RDF)))
print "O.cats=", O.categories()

OO=tensor((O,O))
print "OO.cats=", OO.categories()

C=O.category()
print C
#print TensorProductsCategory(C)

J=OO.category()
print "OO.category=",J

print O.mytestmthd()
print OO.mytestmthd()
print OO.tenstestmthd()

Here "works" means that the last three print statements produce an "ok".

It no longer works in Sage 6.3:

  • the print TensorProductsCategory(C) raises an error in _repr_
  • the tensor product OO is no longer in the TestCat.TensorProducts category

The _repr_ error seems to relate to the new Axiom-framework.

CC: @nthiery

Component: categories

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

@cnassau cnassau added this to the sage-6.4 milestone Aug 15, 2014
@cnassau
Copy link
Author

cnassau commented Aug 15, 2014

comment:1

Here is the backtrace from print TensorProductsCategory(C):

ValueError                                Traceback (most recent call last)
<ipython-input-1-713356a36280> in <module>()
     25 C=O.category()
     26 print C
---> 27 print TensorProductsCategory(C)
     28 
     29 J=OO.category()

/waste/cn/sage-6.3/local/lib/python2.7/site-packages/sage/structure/sage_object.so in sage.structure.sage_object.SageObject.__repr__ (build/cythonized/sage/structure/sage_object.c:1999)()

/waste/cn/sage-6.3/local/lib/python2.7/site-packages/sage/categories/category.pyc in _repr_(self)
    609             Category of sets
    610         """
--> 611         return "Category of {}".format(self._repr_object_names())
    612 
    613     def _latex_(self):

/waste/cn/sage-6.3/local/lib/python2.7/site-packages/sage/categories/covariant_functorial_construction.pyc in _repr_object_names(self)
    421             Category of subquotients of semigroups
    422         """
--> 423         return "%s of %s"%(Category._repr_object_names(self), self.base_category()._repr_object_names())
    424 
    425     def _latex_(self):

/waste/cn/sage-6.3/local/lib/python2.7/site-packages/sage/categories/category.pyc in _repr_object_names(self)
   2860         """
   2861         from sage.categories.category_with_axiom import CategoryWithAxiom
-> 2862         return CategoryWithAxiom._repr_object_names_static(self._without_axioms(named=True), self.axioms())
   2863 
   2864     def _repr_(self, as_join = False):

/waste/cn/sage-6.3/local/lib/python2.7/site-packages/sage/categories/category.pyc in _without_axioms(self, named)
   2816             if category._with_axioms(axioms) is self:
   2817                 return category._without_axioms(named=named)
-> 2818         raise ValueError("This join category isn't built by adding axioms"
   2819                          " to a single category")
   2820 

ValueError: This join category isn't built by adding axioms to a single category

@cnassau
Copy link
Author

cnassau commented Aug 15, 2014

comment:3

It turns out this problem can be circumvented by making TensorProducts a method, rather than a subclass:

class TestCat(Category_over_base_ring):
    @cached_method
    def super_categories(self):
        return []
    class ParentMethods:
        def mytestmthd(self):
            return "ok"
    def TensorProducts(self):
        return TestCat_TensorProducts(self)

class TestCat_TensorProducts(TensorProductsCategory):
        def _repr_(self):
            return "my tensor tst category" 
        @cached_method
        def extra_super_categories(self):
            return [self.base_category()]
        class ParentMethods:
            def tenstestmthd(self):
                return "ok"

Seems I've been hit by black-category-magic once again...

But even with this "fix" the TensorProductsCategory(C) still throws an error.

@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