Skip to content
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

Set.sort_key, default_sort_key edits #1458

Merged
merged 7 commits into from
Aug 4, 2012
Merged

Set.sort_key, default_sort_key edits #1458

merged 7 commits into from
Aug 4, 2012

Conversation

smichr
Copy link
Member

@smichr smichr commented Aug 2, 2012

This is a replacement for @scolobb's branch #1446 (he doesn't show up in the branch list in github so I can't send it directly to him).

scolobb and others added 6 commits August 2, 2012 20:14
Some time ago I have made this method sort the elements by
default_sort_key.  This is redundant however, because _complement only
works for FiniteSet's containing numbers, which can be sorted directly,
without invoking default_sort_key.
In the derived classes which don't fix a certain ordering for their
.args, _sorted_args should returns the list of arguments sorted with
default_sort_key.  By default, _sorted_args returns the same thing as
args.
This argument was not used before.  It's meaning is to assure
order-dependent sort keys.  The example by Christopher Smith says:

>>> (1+x).sort_key()==(1+x).sort_key('rev-lex')
False
This is done in order to assure that the sort keys of these two classes
are hash-independent.
The docstring of this function was not properly updated when the code
has been changed.  This commit fixes that.
@smichr
Copy link
Member Author

smichr commented Aug 3, 2012

This is ready to go but someone else has to give the final ok of the
changes I made. The 2.5 error is "error: Cannot allocate memory".

@asmeurer
Copy link
Member

asmeurer commented Aug 3, 2012

Yeah, that's a problem with Stefan's bot. Let me run a more comprehensive (and hopefully bug-free) bot test.

@asmeurer
Copy link
Member

asmeurer commented Aug 3, 2012

As to it being OK to merge, perhaps @scolobb should sign-off since it's based off his PR and he's hopefully pretty adept in these kinds of changes by now.


This key is supplied by the sort_key routine of Basic objects when
``item`` is a Basic object or a string that sympifies to a Basic
object. Otherwise, this function supplies a values:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"this function supplies a tuple containing the following values" ?

@scolobb
Copy link
Contributor

scolobb commented Aug 3, 2012

@smichr , thank you for taking this up! I'm perfectly OK with the commits you have added, modulo the nitpicks in the comments.

Sorry it took me so long to come around to this pull request.

@asmeurer
Copy link
Member

asmeurer commented Aug 3, 2012

The Python 3 failures in my bot run are my fault.

@smichr
Copy link
Member Author

smichr commented Aug 3, 2012

@asmeurer, there are some gremlins printing in http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYrrYiDA see the ask.py and ipython lines.

Also, how do we keep track of the failures that are occuring? Perhaps I should open an issue? There is a matrixlib-related error

___________ sympy/physics/quantum/tests/test_density.py:test_entropy ___________
  File "/private/var/folders/wc/dppcpmxs1tlb36nqcw853wkm0000gq/t/sympy-bot-tmplooirr/sympy/sympy/physics/quantum/tests/test_density.py", line 172, in test_entropy
    assert isinstance(np_mat, np.matrixlib.defmatrix.matrix) and \
AttributeError: 'module' object has no attribute 'matrixlib'

and a plot error showing in http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sYgvAhDA

@smichr
Copy link
Member Author

smichr commented Aug 3, 2012

btw, @Krastanov (or others) I used tilde underlining so as not to mess up the docs (docscrape?) I'm hoping it will let them pass and not parse that as a header.

I'll make the changes suggested and then commit this (after hearring about whether the tildes are a problem).

@asmeurer
Copy link
Member

asmeurer commented Aug 3, 2012

Yeah open issues for those, except for the cython (autowrap) one, which already has an issue.

@ness01
Copy link
Contributor

ness01 commented Aug 3, 2012

For what it's worth, this looks good to me, too.

@smichr
Copy link
Member Author

smichr commented Aug 4, 2012

I'm slowly getting the hang of Sphinx's errors. I think this will be the final edit of the docstring and then (if it passes) I will commit it.

Any idea why scolobb doesn't show up in the github list of branches?

@travisbot
Copy link

This pull request passes (merged 356c5755 into 9625918).

@asmeurer
Copy link
Member

asmeurer commented Aug 4, 2012

This is a long standing github bug. It's because they only show the top 100 people. The work around is to enter the URL manually (the format is easy enough to figure out from the default).

@Krastanov
Copy link
Member

SymPy Bot Summary: 🔴 There were test failures.

@smichr: Please fix the test failures.

Test command: setup.py test
master hash: 9625918
branch hash: 356c57558289e9674338164528b607a3d9d6cc6b

Interpreter 1: ✳️ All tests have passed.

Interpreter: /usr/local/bin/python2.5 (2.5.6-final-0)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY5ZsjDA

Interpreter 2: ✳️ All tests have passed.

Interpreter: /usr/bin/python2.7 (2.7.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY5P8hDA

Interpreter 3: ✳️ All tests have passed.

Interpreter: /usr/bin/python3.2 (3.2.3-candidate-2)
Architecture: Linux (64-bit)
Cache: yes

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY6fQiDA

Build HTML Docs: 🔴 There were test failures.

Docs build command: make html-errors
Sphinx version: 1.1.3

Test results html report: http://reviews.sympy.org/report/agZzeW1weTNyDAsSBFRhc2sY_5MjDA

Automatic review by SymPy Bot.

The docstring explains why using the order hint may not
give the results one expects if using the default_sort_key
for sorting rather than canonical ordering.

The way around this would be
to create a new sort function that collects a set Expr items,
then assigns an order to each one as might be given if those
items were in an Add or Mul. The only catch is that 0 cannot appear in
an Add and 1 cannot appear in a Mul:

>>> Add(1/x, x ,1, 2, evaluate=0).as_ordered_terms('rev-lex')
[1/x, 2, 1, x]
>>> Add(1/x, x ,1, 2, evaluate=0).as_ordered_terms()
[x, 1, 2, 1/x]

>>> Mul(0, 1/x, x + 1, x**2, evaluate=0).as_ordered_factors()
[0, 1/x, x**2, x + 1]
@smichr
Copy link
Member Author

smichr commented Aug 4, 2012

If that doctest still fails I'll work on it, but let's get the corrections to other errors in....

Thanks to @scolobb for the bulk of this, and to @ness01 and @asmeurer for review. This is in. @scolobb, are there issues to close?

smichr added a commit that referenced this pull request Aug 4, 2012
Set.sort_key, default_sort_key edits
@smichr smichr merged commit aefc67a into sympy:master Aug 4, 2012
@travisbot
Copy link

This pull request passes (merged b36f33b6 into 9625918).

@travisbot
Copy link

This pull request passes (merged b2690e8 into 9625918).

@scolobb
Copy link
Contributor

scolobb commented Aug 4, 2012

@smichr , thanks for the corrections and for getting this in!

I don't remember seeing any issues related to the problem this pull request fixes; so I guess, nothing to close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants