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

raise error if seq change is detected in uniq #18835

Merged
merged 2 commits into from
Mar 13, 2020
Merged

Conversation

smichr
Copy link
Member

@smichr smichr commented Mar 11, 2020

References to other Issues or PRs

fixes #18832

Brief description of what is fixed or changed

When easily detectable, Python raises an error when an item being iterated over is changed and would thus cause the iteration to fail.

When iterating over the unique elements of an iterable as detected by uniq, changing the iterable during iteration will cause a failure in uniq to detect the unique elements. It is not clear that uniq will do this so an error is now raised in the cases when this is easy to detect and a note is added to the docstring.

Other comments

Release Notes

  • utilities
    • iterables - uniq will now raise a RuntimeError if a size change of the sequence is detected

@sympy-bot
Copy link

sympy-bot commented Mar 11, 2020

Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes.

Your release notes are in good order.

Here is what the release notes will look like:

  • utilities
    • iterables - uniq will now raise a RuntimeError if a size change of the sequence is detected (#18835 by @smichr)

This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.6.

Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it.

Click here to see the pull request description that was parsed.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234" (see
https://tinyurl.com/auto-closing for more information). Also, please
write a comment on that issue linking back to this pull request once it is
open. -->

fixes #18832 

#### Brief description of what is fixed or changed

When easily detectable, [Python raises an error](https://stackoverflow.com/a/50167042/1089161) when an item being iterated over is changed and would thus cause the iteration to fail.

When iterating over the unique elements of an iterable as detected by `uniq`, changing the iterable during iteration will cause a failure in `uniq` to detect the unique elements. It is not clear that `uniq` will do this so an error is now raised in the cases when this is easy to detect and a note is added to the docstring.

#### Other comments


#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* utilities
    * iterables - `uniq` will now raise a RuntimeError if a size change of the sequence is detected
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@codecov
Copy link

codecov bot commented Mar 12, 2020

Codecov Report

Merging #18835 into master will increase coverage by 0.004%.
The diff coverage is 100.000%.

@@              Coverage Diff              @@
##            master    #18835       +/-   ##
=============================================
+ Coverage   75.653%   75.657%   +0.004%     
=============================================
  Files          647       647               
  Lines       168516    168526       +10     
  Branches     39706     39708        +2     
=============================================
+ Hits        127488    127503       +15     
+ Misses       35474     35467        -7     
- Partials      5554      5556        +2     

@smichr
Copy link
Member Author

smichr commented Mar 13, 2020

@oscarbenjamin , are you ok with this addition?

@oscarbenjamin
Copy link
Contributor

It seems unnecessary to me but I don't object to it. I think this is fine to merge

@smichr smichr merged commit cb088e7 into sympy:master Mar 13, 2020
@smichr smichr deleted the uniq branch March 19, 2020 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

uniq modifies list argument
4 participants