@@ -1272,6 +1272,9 @@ default implementation. Hence:
1272
1272
1273
1273
- Next, we implement a new version of the "usual" fraction field functor, having the same rank, but returning our new implementation.
1274
1274
- 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.
1275
1278
1276
1279
.. WARNING ::
1277
1280
@@ -1283,10 +1286,12 @@ default implementation. Hence:
1283
1286
sage: from sage.categories.pushout import ConstructionFunctor
1284
1287
sage: class MyFracFunctor(ConstructionFunctor):
1285
1288
....: rank = 5
1286
- ....: def __init__(self):
1289
+ ....: def __init__(self, args=None, kwds=None):
1290
+ ....: self.args = args or ()
1291
+ ....: self.kwds = kwds or {}
1287
1292
....: ConstructionFunctor.__init__(self, IntegralDomains(), Fields())
1288
1293
....: def _apply_functor(self, R):
1289
- ....: return MyFrac(R)
1294
+ ....: return MyFrac(R,*self.args,**self.kwds )
1290
1295
....: def merge(self, other):
1291
1296
....: if isinstance(other, (type(self), sage.categories.pushout.FractionField)):
1292
1297
....: return self
@@ -1325,14 +1330,18 @@ We verify that our functor can really be used to construct our implementation of
1325
1330
1326
1331
.. end of output
1327
1332
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.
1330
1339
1331
1340
::
1332
1341
1333
1342
sage: class MyFrac(MyFrac):
1334
1343
....: def construction(self):
1335
- ....: return MyFracFunctor(), self.base()
1344
+ ....: return MyFracFunctor(self._reduction[1][1:], self._reduction[2] ), self.base()
1336
1345
1337
1346
1338
1347
.. end of output
0 commit comments