CategoryObject vs. Parent

97 views
Skip to first unread message

Jeroen Demeyer

unread,
May 5, 2015, 4:41:47 AM5/5/15
to sage-devel
Hello,

what are the types CategoryObject and Parent supposed to represent? For
example, I don't understand why generators and names are dealt with on
the level of CategoryObject but constructing elements is dealt with on
the level of Parent.

In fact, in all of Sage, there is only a single class which is a
CategoryObject but not a Parent:

class SimplicialComplex(CategoryObject, GenericCellComplex)

David Roe

unread,
May 5, 2015, 4:53:18 AM5/5/15
to sage-devel
Parent should represent an object in a category that has a forgetful functor to sets; CategoryObject an object in an arbitrary category.  I have no objection to moving the generator and name code to Parent.
David



--
You received this message because you are subscribed to the Google Groups "sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-devel+...@googlegroups.com.
To post to this group, send email to sage-...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-devel.
For more options, visit https://groups.google.com/d/optout.

Nicolas M. Thiery

unread,
May 5, 2015, 5:00:21 AM5/5/15
to sage-...@googlegroups.com
Parents are supposed to model sets (typically with some structure),
when CategoryObject can be more general. Simplicial complexes are
typical examples, where we want to model instead a collection of sets
with some structure. This feature has indeed not been used much yet
(which also reflects in the fact that almost all categories are
subcategories of `Sets()` rather than of `Objects()`).

Very much like for Parent, there probably are things that are in
CategoryObject for very old legacy reasons (typically pre-categories!)
and really do not belong there; this could typically be the case for
generators and names.

Cheers,
Nicolas
--
Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

Vincent Delecroix

unread,
May 5, 2015, 6:44:08 AM5/5/15
to sage-...@googlegroups.com
IMHO, they do not belong either to parents. A set has generators?

sage: Partitions(5).gens_dict()
Traceback (most recent call last):
...
AttributeError: 'StandardPermutations_n_with_category' object
has no attribute 'gens'AttributeError: 'Partitions_n_with_category'

Vincent

Nicolas M. Thiery

unread,
May 5, 2015, 9:05:43 AM5/5/15
to sage-...@googlegroups.com
On Tue, May 05, 2015 at 12:44:00PM +0200, Vincent Delecroix wrote:
> > Very much like for Parent, there probably are things that are in
> > CategoryObject for very old legacy reasons (typically pre-categories!)
> > and really do not belong there; this could typically be the case for
> > generators and names.
>
> IMHO, they do not belong either to parents. A set has generators?
>
> sage: Partitions(5).gens_dict()
> Traceback (most recent call last):
> ...
> AttributeError: 'StandardPermutations_n_with_category' object
> has no attribute 'gens'AttributeError: 'Partitions_n_with_category'

+1

Simon King

unread,
May 5, 2015, 9:34:08 AM5/5/15
to sage-...@googlegroups.com
Hi!

On 2015-05-05, David Roe <roed...@gmail.com> wrote:
> Parent should represent an object in a category that has a forgetful
> functor to sets; CategoryObject an object in an arbitrary category. I have
> no objection to moving the generator and name code to Parent.

Perhaps not the name code (if you are talking about the string
representation of the object itself), but I think the generator stuff
could indeed be moved.

Cheers,
Simon


Eric Gourgoulhon

unread,
May 5, 2015, 5:10:38 PM5/5/15
to sage-...@googlegroups.com
Hi,


Le mardi 5 mai 2015 12:44:08 UTC+2, vdelecroix a écrit :

IMHO, they do not belong either to parents. A set has generators?

sage: Partitions(5).gens_dict()
Traceback (most recent call last):
...
AttributeError: 'StandardPermutations_n_with_category' object
has no attribute 'gens'AttributeError: 'Partitions_n_with_category'


In the same vein, shouldn't base_ring be removed from Parent as well ?

sage: Set([1,2,3]).base_ring()

The return value is None, which is arguably correct, for a generic set has no base ring, but it might be surprising when using tab completion to discover functionalities to see that a base_ring() method exists for such objects.

Eric.

Robert Bradshaw

unread,
May 6, 2015, 1:30:51 AM5/6/15
to sage-devel
As Parents have Elements, this is also the root of operations that
deal with coercion (arithmetic between elements of unequal Parents).
Some functions like base_ring are used for coercion, though arguments
could be made that it could be moved elsewhere and called dynamically
iff it exists.

Nathann Cohen

unread,
May 6, 2015, 3:36:11 AM5/6/15
to sage-...@googlegroups.com
In the same vein, shouldn't base_ring be removed from Parent as well ?

sage: Set([1,2,3]).base_ring()

The return value is None, which is arguably correct, for a generic set has no base ring, but it might be surprising when using tab completion to discover functionalities to see that a base_ring() method exists for such objects.

+1 to that. Many other methods of Parent should be moved somewhere else (is_exact, inject_variables,gens_dict*

Moreover, many method names shoulf be changed (made longer, more explicit): while the meaning of Parent.a_method can be clear, it is at times very difficult, when listing the methods of a more specific object, to understand what the same method does. Because then it is not obvious at all that a_method refers to the object 'understood as a Parent'. When you have a poset or a group in yours hands, your think of it as a group, and not necessarily as "a parent".

Nathann

Nicolas M. Thiery

unread,
May 12, 2015, 2:43:29 AM5/12/15
to sage-...@googlegroups.com
On Tue, May 05, 2015 at 10:30:18PM -0700, Robert Bradshaw wrote:
> > Eric:
> > In the same vein, shouldn't base_ring be removed from Parent as well ?

Yes indeed.

> As Parents have Elements, this is also the root of operations that
> deal with coercion (arithmetic between elements of unequal Parents).
> Some functions like base_ring are used for coercion, though arguments
> could be made that it could be moved elsewhere and called dynamically
> iff it exists.

David Roe and I investigated what had to be done for this at PyCon'15,
and he then worked on it. If I remember well, he had a mostly working
branch. This is #18196.

David Roe

unread,
May 12, 2015, 4:01:58 AM5/12/15
to sage-devel
On Tue, May 12, 2015 at 2:43 AM, Nicolas M. Thiery <Nicolas...@u-psud.fr> wrote:
On Tue, May 05, 2015 at 10:30:18PM -0700, Robert Bradshaw wrote:
> > Eric:
> > In the same vein, shouldn't base_ring be removed from Parent as well ?

Yes indeed.

> As Parents have Elements, this is also the root of operations that
> deal with coercion (arithmetic between elements of unequal Parents).
> Some functions like base_ring are used for coercion, though arguments
> could be made that it could be moved elsewhere and called dynamically
> iff it exists.

David Roe and I investigated what had to be done for this at PyCon'15,
and he then worked on it. If I remember well, he had a mostly working
branch. This is #18196.

Not yet!  Still working on it....
David

Cheers,
                                Nicolas
--
Nicolas M. Thiéry "Isil" <nth...@users.sf.net>
http://Nicolas.Thiery.name/

Reply all
Reply to author
Forward
0 new messages