Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-28 Thread Travis Scrimshaw
Because it is not a public method and nobody added the automethod to the class to make sure it is included. That is my guess. Should be simple to fix. Best, Travis On Friday, September 27, 2019 at 8:42:43 PM UTC+10, Salvatore Stella wrote: > > Indeed it seems to be documented. Why is this not

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-27 Thread VulK
Indeed it seems to be documented. Why is this not in the online documentation? S. * Travis Scrimshaw [2019-09-26 17:59:38]: There is also an example of this inheritance and discussion in one of the sage.structure.unique_representation examples. Best, Travis On Friday, September 27, 2019

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread Travis Scrimshaw
There is also an example of this inheritance and discussion in one of the sage.structure.unique_representation examples. Best, Travis On Friday, September 27, 2019 at 10:57:52 AM UTC+10, Travis Scrimshaw wrote: > > > The prototype does, now I have to implement the real thing. >>> >>> Is there

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread Travis Scrimshaw
> The prototype does, now I have to implement the real thing. >> >> Is there any way to add this info to the documentation? It took me a lot >> of >> trial and error to figure out how to do what I wanted. >> S. >> >> Definitely. The topical place would be in sage.misc.classcall_metaclass,

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread Nils Bruin
On Thursday, September 26, 2019 at 3:14:07 PM UTC-7, Salvatore Stella wrote: > > The prototype does, now I have to implement the real thing. > > Is there any way to add this info to the documentation? It took me a lot > of > trial and error to figure out how to do what I wanted. > S. > >

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread VulK
The prototype does, now I have to implement the real thing. Is there any way to add this info to the documentation? It took me a lot of trial and error to figure out how to do what I wanted. S. * Travis Scrimshaw [2019-09-26 15:11:07]: So it works now, correct? Best, Travis On Friday,

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread Travis Scrimshaw
So it works now, correct? Best, Travis On Friday, September 27, 2019 at 12:42:23 AM UTC+10, Salvatore Stella wrote: > > Oops, I think that I figured out where the mistake was. Here is the > correct > code: > > class OldFoo(UniqueRepresentation): > > @staticmethod > def

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread VulK
Oops, I think that I figured out where the mistake was. Here is the correct code: class OldFoo(UniqueRepresentation): @staticmethod def __classcall__(self, data, **kwargs): hashable_data = tuple(data) kwargs['some_default_option'] = 'bar' return super(OldFoo,

Re: [sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-26 Thread VulK
Thank you Travis for your reply. Here is an attempt at implementing your suggestion that does not work: it looks like OldFoo.__classcall__ is skipped and OldFoo.__init__ is run directly instead. This is not what I want: I would like the preparsing in OldFoo to still be performed after the

[sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-25 Thread Travis Scrimshaw
Although it almost sounds like you should be doing the NewFoo preparsing inside NewFoo.__classcall__ (or NewFoo.__classcall_private__), which then should get passed up and handled by OldFoo.__classcall__. You might need some extra *args or **kwds to the __init__ and/or __classcall__ to handle

[sage-devel] Re: UniqueRepresentation inheritance and __classcall__

2019-09-25 Thread Travis Scrimshaw
Make OldFoo.__classcall_private__, then it is not inherited. Best, Travis On Thursday, September 26, 2019 at 8:22:23 AM UTC+10, Salvatore Stella wrote: > > Dear All, > I would like to make a new class inheriting from a class based on > UniqueRepresentation. My goal, among other things, is to