Thanks a lot for the help!
Il giorno martedì 3 marzo 2020 10:31:19 UTC+1, Kalevi Suominen ha scritto:
>
> IndexedBase has no `__init__` method of its own. It inherits
> `object.__init__` that accepts no arguments and does nothing. Instead,
> IndexedBase has a `__new__` method that accepts arguments. The custom class
> will automatically inherit it. It is not necessary to define `__init__` at
> all. As to 2), I believe that your way is correct.
>
> Kalevi Suominen
>
> On Tuesday, March 3, 2020 at 9:42:14 AM UTC+2, Lorenzo Monacelli wrote:
>>
>> Dear all,
>> I am manipulating an IndexedBase object, and I would like to modify its
>> behavior when differentiated.
>>
>> I thought to do something like this:
>> class custom(sy.IndexedBase):
>> def __init__(self, *args, **kwargs):
>> sy.IndexedBase.__init__(self, *args, **kwargs)
>>
>> def diff(self, *args):
>> # Do some stuff
>> pass
>>
>> However, when I initialize the object:
>> b = custom("b")
>>
>> It gives the error:
>> object.__init__() takes no arguments
>>
>> However, it works if I do:
>> b = sy.IndexedBase("b")
>>
>>
>> I have two questions:
>> 1) How can I create an object derivated from IndexedBase?
>> 2) Is my way of doing correct to redefine the behaviour of the
>> derivative? (It must work if I derivate a whole expression that contains
>> the object)
>>
>> Thanks for your attention,
>> Bests,
>> Lorenzo
>>
>
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/sympy/7cf0f692-b0e3-493e-991c-b25e4394f91e%40googlegroups.com.