Permalink
Browse files

In Category, explicitly construct a Class of objects.

Also test the way Category stores objects and fix some related doctests.
  • Loading branch information...
1 parent 20c545d commit 313246fd403c1e8673bd34015754c59bd38afbb9 @scolobb committed Jun 12, 2012
Showing with 7 additions and 3 deletions.
  1. +2 −2 sympy/categories/baseclasses.py
  2. +5 −1 sympy/categories/tests/test_baseclasses.py
@@ -550,7 +550,7 @@ def __new__(cls, name, objects=EmptySet(), commutative=EmptySet()):
if not name:
raise ValueError("A Category cannot have an empty name.")
- new_category = Basic.__new__(cls, Symbol(name), objects,
+ new_category = Basic.__new__(cls, Symbol(name), Class(objects),
FiniteSet(commutative))
return new_category
@@ -584,7 +584,7 @@ def objects(self):
>>> B = Object("B")
>>> K = Category("K", FiniteSet(A, B))
>>> K.objects
- {Object("B"), Object("A")}
+ Class({Object("B"), Object("A")})
"""
return self.args[1]
@@ -1,4 +1,5 @@
from sympy.categories import Object, Morphism, IdentityMorphism, Diagram, Category
+from sympy.categories.baseclasses import Class
from sympy.utilities.pytest import XFAIL, raises
from sympy import FiniteSet, EmptySet, Dict, Tuple
@@ -183,6 +184,9 @@ def test_category():
d1 = Diagram([f, g])
d2 = Diagram([f])
- K = Category("K", commutative=[d1, d2])
+ objects = d1.objects | d2.objects
+ K = Category("K", objects, commutative=[d1, d2])
+
+ assert K.objects == Class(objects)
assert K.commutative == FiniteSet(d1, d2)

0 comments on commit 313246f

Please sign in to comment.