New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix "flip" of arguments in relational expressions #30

Merged
merged 3 commits into from Jan 22, 2016

Conversation

1 participant
@skirpichev
Copy link
Collaborator

skirpichev commented Mar 20, 2015

see sympy/sympy#7951 and https://bugs.python.org/issue22052

  • verbose commit messages
  • better docstring for BaseSymbol (i.e. document why we need this)

@skirpichev skirpichev force-pushed the rel-flip branch 4 times, most recently from bf3ef99 to cb62f0a Mar 21, 2015

@skirpichev skirpichev force-pushed the rel-flip branch 4 times, most recently from fb38d61 to 3a07112 Apr 2, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 3a07112 to 05e538a Apr 9, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 05e538a to 2a74e76 May 2, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 2a74e76 to 673b235 Jul 16, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 673b235 to a4ac826 Aug 2, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from a4ac826 to 3e83b77 Aug 2, 2015

@skirpichev skirpichev force-pushed the rel-flip branch 2 times, most recently from 6a926a4 to 878378f Sep 28, 2015

@skirpichev skirpichev modified the milestone: First public release Dec 13, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 1e829d4 to 73dc0f7 Dec 19, 2015

@skirpichev skirpichev force-pushed the rel-flip branch from 73dc0f7 to 93883d4 Dec 26, 2015

@skirpichev skirpichev force-pushed the rel-flip branch 2 times, most recently from 1ba87d5 to 8ced12b Jan 18, 2016

skirpichev added some commits Dec 4, 2014

Introduce BaseSymbol class and improve docs for symbols
This fixes "flip" of arguments in relational expressions,
mentioned in the issue sympy/sympy#7951.

The docs says [1] (see also [2]) about relational ops:
There are no swapped-argument versions of these methods (to be used when
the left argument does not support the operation but the right argument
does); rather, __lt__() and __gt__() are each other’s reflection,
__le__() and __ge__() are each other’s reflection, and __eq__() and
__ne__() are their own reflection.  If the operands are of different
types, and right operand’s type is a direct or indirect subclass of the
left operand’s type, the reflected method of the right operand has
priority, otherwise the left operand’s method has priority.

So, if B is a subclass of A, we can't avoid calling the "reflected"
method.  For example, A() < B() will be silently transformed to
B() > A().  Only know workaround per se - avoid subclassing of "public"
classes.  For example, old class hierarchy for symbols is forbidden:

                    Symbol
                   /      \
                 Dummy    Wild

In this patch, common base class for symbols was implemented.

References
==========

.. [1] https://docs.python.org/3.5/reference/datamodel.html#object.__lt__
.. [2] https://bugs.python.org/issue22052
.. [3] sympy/sympy#7951

skirpichev added a commit that referenced this pull request Jan 22, 2016

Merge pull request #30 from skirpichev/rel-flip
Fix "flip" of arguments in relational expressions

@skirpichev skirpichev merged commit dc859ac into master Jan 22, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.0006%) to 91.867%
Details

@skirpichev skirpichev deleted the rel-flip branch Jan 22, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment