Skip to content
This repository was archived by the owner on Jan 30, 2023. It is now read-only.

Commit a81fcc1

Browse files
committedSep 24, 2013
Make _test_construction pass in the thematic tutorial
1 parent 2bb2cf2 commit a81fcc1

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎src/doc/en/thematic_tutorials/coercion_and_categories.rst

+14-5
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,9 @@ default implementation. Hence:
12721272

12731273
- Next, we implement a new version of the "usual" fraction field functor, having the same rank, but returning our new implementation.
12741274
- We make our new implementation the default, by virtue of a merge method.
1275+
- Since our fraction fields accept an optional argument ``category``, we pass
1276+
the optional arguments to the construction functor, which will in turn use
1277+
it to create a fraction field.
12751278

12761279
.. WARNING::
12771280

@@ -1283,10 +1286,12 @@ default implementation. Hence:
12831286
sage: from sage.categories.pushout import ConstructionFunctor
12841287
sage: class MyFracFunctor(ConstructionFunctor):
12851288
....: rank = 5
1286-
....: def __init__(self):
1289+
....: def __init__(self, args=None, kwds=None):
1290+
....: self.args = args or ()
1291+
....: self.kwds = kwds or {}
12871292
....: ConstructionFunctor.__init__(self, IntegralDomains(), Fields())
12881293
....: def _apply_functor(self, R):
1289-
....: return MyFrac(R)
1294+
....: return MyFrac(R,*self.args,**self.kwds)
12901295
....: def merge(self, other):
12911296
....: if isinstance(other, (type(self), sage.categories.pushout.FractionField)):
12921297
....: return self
@@ -1325,14 +1330,18 @@ We verify that our functor can really be used to construct our implementation of
13251330

13261331
.. end of output
13271332
1328-
There remains to let our new fraction fields know about the new construction functor:
1329-
1333+
There remains to let our new fraction fields know about the new construction
1334+
functor. The arguments that were used when creating the fraction field are
1335+
stored as an attribute---this is a feature provided by
1336+
:class:`~sage.structure.unique_representation.CachedRepresentation`. We pass
1337+
all but the first of these arguments to the construction functor, such that
1338+
the construction functor is able to reconstruct the fraction field.
13301339

13311340
::
13321341

13331342
sage: class MyFrac(MyFrac):
13341343
....: def construction(self):
1335-
....: return MyFracFunctor(), self.base()
1344+
....: return MyFracFunctor(self._reduction[1][1:], self._reduction[2]), self.base()
13361345

13371346

13381347
.. end of output

0 commit comments

Comments
 (0)
This repository has been archived.