#15289: Implement indexed monoids
-------------------------------------+-------------------------------------
       Reporter:  tscrim             |        Owner:  sage-combinat
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-6.3
      Component:  algebra            |   Resolution:
       Keywords:  days54             |    Merged in:
        Authors:  Travis Scrimshaw   |    Reviewers:
Report Upstream:  N/A                |  Work issues:
         Branch:                     |       Commit:
  public/monoids/15289-indexed       |  1ff1a0483f5e61959a432371b701f593a5dee599
   Dependencies:  #15309 #15169      |     Stopgaps:
-------------------------------------+-------------------------------------
Changes (by tscrim):

 * cc: SimonKing (added)


Comment:

 Fixed everything mentioned above except I've run into a ''major'' pickling
 issue with `UniqueFactory` (which is why I've cc-ed Simon).

 There is some precedence for creating a generator from an index:
 {{{
 sage: C = CombinatorialFreeModule(ZZ, ['a','b','c'])
 sage: C('a')
 B['a']
 }}}
 So I'd like to leave that in for now. However I made things like `F(1)`
 only return `F[1]`.

 I changed the input for `Monoids().free(...)` but I left `FreeMonoid(...)`
 as I had it before because I don't want to deal with deprecations there in
 this ticket (this is #16330). I'll do the cleanup of the factory functions
 in the followup #16329.

 I'm not doing anything to `FreeMonoid` or `FreeAbelianMonoid` other than
 redirecting input, so I'm not going to make these changes here:

 > * Now or later: __repr__ -> _repr_, __call__ -> _element_constructor_.
 The custom __contains__ might not be needed.
 > * Now or later: initialize the category

 We could probably also fit that in #16329 or another followup.

 Simon, so I've changed the `UniqueFactory` object `FreeMonoid` to a new
 factory function since it returns a class which I've designed as a
 `UniqueRepresentation`. However unpickling old `FreeMonoid` objects fails
 because of the unpickling mechanism of `UniqueFactory` redirects to
 `generic_factory_unpickle()` and has `FreeMonoid` from the global
 namespace as the first object. It is expecting it to be a `UniqueFactory`
 instance, so it errors out here. Furthermore because of the structure of
 the pickle, I'm unable to use `register_unpickle_override` or see anyway
 to redirect that specific pickle without changing the behavior of
 `generic_factory_unpickle()`.

 I'm thinking the best thing to do is to change
 `generic_factory_unpickle()` to accept a general object as input and if
 the first input is no longer a `UniqueFactory`, then call it with the
 arguments given as part of the pickle. Another option I see is to override
 `UniqueFactory.__call__`, but I really don't want to do that. The last
 option I see, and I absolutely don't like this, is to make my new factory
 function into a different name temporarily (or deprecate `FreeMonoid`
 construction altogether).  Any ideas?

 I'm also thinking we should change this behavior so we don't keep running
 into this problem.

--
Ticket URL: <http://trac.sagemath.org/ticket/15289#comment:36>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

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

Reply via email to