Ticket #9106: trac_9106-UniqueRep_sphinx_fix-fh.patch

File trac_9106-UniqueRep_sphinx_fix-fh.patch, 4.9 KB (added by hivert, 10 years ago)
  • sage/misc/classcall_metaclass.py

    # HG changeset patch
    # User Florent Hivert <Florent.Hivert@univ-rouen.fr>
    # Date 1275469999 -7200
    # Node ID 1baf368a884d3772a8b369de5cf085832fb13f02
    # Parent  101010790ec8a62e1b9fa2508e7dde4b61998b5a
    #9106: Wrong sphinx markup in UniqueRepresentation
    
    diff --git a/sage/misc/classcall_metaclass.py b/sage/misc/classcall_metaclass.py
    a b class ClasscallMetaclass(NestedClassMeta 
    3131     - ``.__classget__`` for customizing the binding behavior in
    3232       ``foo.cls`` (analogue of ``.__get__``).
    3333
    34     See the documentation of :meth:`.__call__`` and of
    35     :meth:`.__get__`` for the description of the respective protocols.
     34    See the documentation of :meth:`.__call__` and of :meth:`.__get__`
     35    for the description of the respective protocols.
    3636
    3737    TODO: find a good name for this metaclass.
    3838
  • sage/structure/unique_representation.py

    diff --git a/sage/structure/unique_representation.py b/sage/structure/unique_representation.py
    a b  
    11r"""
    2 UniqueRepresentation
     2Unique Representation
    33"""
    44#*****************************************************************************
    55#  Copyright (C) 2008 Nicolas M. Thiery <nthiery at users.sf.net>
    class UniqueRepresentation: 
    2727    EXAMPLES:
    2828
    2929    The short story: to construct a class whose instances have a
    30     unique representation behavior one just have to do::
     30    unique representation behavior one just has to do::
    3131
    3232        sage: class MyClass(UniqueRepresentation):
    3333        ...       # all the rest as usual
    class UniqueRepresentation: 
    6161    on a small set of elements (say the multiplication table of a
    6262    small group), and access this cache as quickly as possible.
    6363
    64     The :class:`UniqueRepresentation` and :class:`UniqueFactory` classes
     64    The :class:`UniqueRepresentation` and
     65    :class:`~sage.structure.factory.UniqueFactory` classes
    6566    provide two alternative implementations of this design pattern. Both
    6667    implementations have their own merits. :class:`UniqueRepresentation` is
    6768    very easy to use: a class just needs to derive from it, or make sure some
    class UniqueRepresentation: 
    187188    ``MyClass2([1,2,3])`` triggers a call to
    188189    ``MyClass2.__classcall__(MyClass2, [1,2,3])``. This is an extension of
    189190    the standard Python behavior, needed by :class:`UniqueRepresentation`,
    190     and implemented by the ``ClasscallMetaclass``. Then,
     191    and implemented by the
     192    :class:`~sage.misc.classcall_metaclass.ClasscallMetaclass`. Then,
    191193    ``MyClass2.__classcall__`` does the desired transformations on the
    192194    arguments. Finally, it uses ``super`` to call the default
    193195    implementation of ``__classcall__`` provided by
    class UniqueRepresentation: 
    279281
    280282    Caveat: the default implementation of :meth:`__reduce__` in
    281283    :class:`UniqueRepresentation` requires to store the constructor's
    282     arguments in the instance dictionary upon construction:
     284    arguments in the instance dictionary upon construction::
    283285
    284286        sage: x.__dict__
    285287        {'_reduction': (<class '__main__.MyClass'>, (), {'value': 1}), 'value': 1}
    class UniqueRepresentation: 
    287289    It is often easy in a derived subclass to reconstruct the
    288290    constructors arguments from the instance data structure. When this
    289291    is the case, :meth:`__reduce__` should be overridden; automagically
    290     the arguments won't be stored anymore:
     292    the arguments won't be stored anymore::
    291293
    292294        sage: class MyClass3(UniqueRepresentation):
    293295        ...       def __init__(self, value):
    class UniqueRepresentation: 
    303305        sage: x.__dict__
    304306        {'value': 1}
    305307
    306     .. rubric:: Migrating classes to ``UniqueRepresentation`` and unpickling
     308    .. rubric:: Migrating classes to :class:`UniqueRepresentation` and unpickling
    307309
    308     We check that, when migrating a class to ``UniqueRepresentation``,
     310    We check that, when migrating a class to :class:`UniqueRepresentation`,
    309311    older pickle can still be reasonably unpickled. Let us create a
    310312    (new style) class, and pickle one of its instances::
    311313
    class UniqueRepresentation: 
    322324        sage: y.value
    323325        1
    324326
    325     Now, we upgrade the class to derive from ``UniqueRepresentation``::
     327    Now, we upgrade the class to derive from :class:`UniqueRepresentation`::
    326328
    327329        sage: class MyClass4(UniqueRepresentation, object):
    328330        ...       def __init__(self, value):
    class UniqueRepresentation: 
    382384    .. rubric:: Rationale for the current implementation
    383385
    384386    :class:`UniqueRepresentation` and derived classes use the
    385     ``ClasscallMetaclass`` of the standard Python type. The following
    386     example explains why.
     387    :class:`~sage.misc.classcall_metaclass.ClasscallMetaclass`
     388    of the standard Python type. The following example explains why.
    387389
    388390    We define a variant of ``MyClass`` where the calls to :meth:`__init__`
    389391    are traced::