Okay I made it work with __richcmp__ as suggested.
Please review :-) .
On Tuesday, October 24, 2017 at 7:53:46 AM UTC+2, Simon Brandhorst wrote:
>
> Ahhh
>
> On Monday, October 23, 2017 at 6:09:02 PM UTC+2, David Roe wrote:
>>
>>
>>
>> On Mon, Oct 23, 2017 at 8:24 AM, Simon Brandhorst
>> wrot
Ahhh
On Monday, October 23, 2017 at 6:09:02 PM UTC+2, David Roe wrote:
>
>
>
> On Mon, Oct 23, 2017 at 8:24 AM, Simon Brandhorst > wrote:
>
>> I am aware of this. It is just unexpected that other.__eq__(self) calls
>> self._eq(other)
>>
>> As a user of that rich cmp method I would have expected i
> I am aware of this. It is just unexpected that other.__eq__(self) calls
>> self._eq(other)
>>
>> As a user of that rich cmp method I would have expected it to call
>> other._eq(self).
>>
>> Raising a not implemented error seems nice. :)
>>
>
> Note that it should return NotImplemented (a built
On Mon, Oct 23, 2017 at 8:24 AM, Simon Brandhorst
wrote:
> I am aware of this. It is just unexpected that other.__eq__(self) calls
> self._eq(other)
>
> As a user of that rich cmp method I would have expected it to call
> other._eq(self).
>
> Raising a not implemented error seems nice. :)
>
Note
I am aware of this. It is just unexpected that other.__eq__(self) calls
self._eq(other)
As a user of that rich cmp method I would have expected it to call
other._eq(self).
Raising a not implemented error seems nice. :)
Anyways I believe it should be better documented if you want people to use
th
This is an infinite loop:
: if type(other)!=type(self):
: #other knows how to do the comparison
: return other.__eq__(self)
The correct Python thing to do is to return NotImplemented in this case.
--
You received this message because you are subscribe
Mhh okay, I can see that point.
On Monday, October 23, 2017 at 6:23:50 AM UTC+2, Travis Scrimshaw wrote:
>
>
>
> On Thursday, October 19, 2017 at 8:59:17 PM UTC-5, Simon Brandhorst wrote:
>>
>> Well richcmp allows you to define just one method. But it does not save
>> you any work at all if the o
On Thursday, October 19, 2017 at 8:59:17 PM UTC-5, Simon Brandhorst wrote:
>
> Well richcmp allows you to define just one method. But it does not save
> you any work at all if the order is partial.
> Because then you have to distinguish the cases op = op_LE , op_GE, op_LT
> ... etc. so al
from sage.structure.richcmp import richcmp_by_eq_and_lt,richcmp_method
@richcmp_method
class A(object):
def __init__(self,x):
self._x = x
__richcmp__ = richcmp_by_eq_and_lt("_eq","_lt")
def _eq(self,other):
if type(other)!=type(self):
#other knows how to do
If you say that something does not work, it would be good to show a
simple example of what you did. It is impossible for me to understand
why your code doesn't work without seeing your code.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To uns
/home/simon/sage/src/sage/structure/richcmp.pyx in
sage.structure.richcmp.richcmp_by_eq_and_lt.richcmp
(build/cythonized/sage/structure/richcmp.c:2172)()
317 if equal_types:
318 other_eq = getattr(other, eq_attr)
--> 319 if other_eq(self):
320
Well richcmp allows you to define just one method. But it does not save you
any work at all if the order is partial.
Because then you have to distinguish the cases op = op_LE , op_GE, op_LT
... etc. so all that you save is documentation and everything is more
obscure.
I also tried the ric
On Tuesday, October 17, 2017 at 9:55:25 AM UTC-5, Simon Brandhorst wrote:
>
> I got that now. But at the time I thought __richcmp__ was just a fancy new
> name for the old __cmp__ in python in order to make it python 3 compatible.
>
> Anyways. It would be nice to say something like that in the
I got that now. But at the time I thought __richcmp__ was just a fancy new
name for the old __cmp__ in python in order to make it python 3 compatible.
Anyways. It would be nice to say something like that in the documentation.
(Maybe I have just missed it and it is there already.)
"
@richcmp_met
On 2017-10-17 12:13, Simon Brandhorst wrote:
Because the documentation did not tell me it was possible:
That *what* is possible? @richcmp_method simply allows to define just
one comparison method __richcmp__ instead of six __eq__, __lt__, ...
However, the functionality of what that compariso
On 2017-10-17 12:13, Simon Brandhorst wrote:
> Because the documentation did not tell me it was possible:
Maybe sage.structure.richcmp.richcmp_by_eq_and_lt is something for you
(see also L1100 in sage/rings/asymptotic/growth_group.py).
Daniel
--
You received this message because you are subscri
Because the documentation did not tell me it was possible:
http://doc.sagemath.org/html/en/reference/structure/sage/structure/richcmp.html
Can you update it?
I have interpreted it as a way to go to python3 without changing the logic
of the code.
On Monday, October 16, 2017 at 6:13:29 PM UTC+2,
Now the question is why are you doing this? You have rich comparison
behavior (i.e., a partial order) by allowing a return value of
NotImplemented. So I do not understand why you would do this because it
comes with a lot of boilerplate code and documentation unless you want to
remove all use of
It works. Thank you :-).
On Monday, October 16, 2017 at 2:28:00 PM UTC+2, Jeroen Demeyer wrote:
>
> Remove the @richcmp_method decorator.
>
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails
Remove the @richcmp_method decorator.
--
You received this message because you are subscribed to the Google Groups
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to sage-devel+unsubscr...@googlegroups.com.
To post to this group, send email to
20 matches
Mail list logo