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

Add warning for all possible paths and cyclic path #20131

Merged
merged 4 commits into from Oct 1, 2020
Merged

Add warning for all possible paths and cyclic path #20131

merged 4 commits into from Oct 1, 2020

Conversation

sidhu1012
Copy link
Contributor

@sidhu1012 sidhu1012 commented Sep 22, 2020

References to other Issues or PRs

fix #20129

Brief description of what is fixed or changed

Added User Warnings for all possible paths and userwarnings for cyclic paths.

Other comments

Release Notes

  • physics.vector
    - Added user warnings for all possible paths are found in particle.py.
    - Added user warning for cyclic paths in particle.py.

@sympy-bot
Copy link

sympy-bot commented Sep 22, 2020

Hi, I am the SymPy bot (v160). 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:

  • physics.vector
    • Added user warnings for all possible paths are found in particle.py. (#20131 by @sidhu1012)

    • Added user warning for cyclic paths in particle.py. (#20131 by @sidhu1012)

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

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. --> 
fix #20129 

#### Brief description of what is fixed or changed
Added User Warnings for all possible paths and userwarnings for cyclic paths.

#### 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 -->

- physics.vector
      - Added user warnings for all possible paths are found in particle.py.
      - Added user warning for cyclic paths in particle.py.

<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@sidhu1012 sidhu1012 closed this Sep 22, 2020
@sidhu1012 sidhu1012 reopened this Sep 22, 2020
@codecov
Copy link

codecov bot commented Sep 22, 2020

Codecov Report

Merging #20131 into master will increase coverage by 11.401%.
The diff coverage is 88.854%.

@@              Coverage Diff               @@
##            master    #20131        +/-   ##
==============================================
+ Coverage   64.466%   75.867%   +11.401%     
==============================================
  Files          671       671                
  Lines       173707    173809       +102     
  Branches     41020     41053        +33     
==============================================
+ Hits        111982    131864     +19882     
+ Misses       55307     36203     -19104     
+ Partials      6418      5742       -676     

@sidhu1012 sidhu1012 changed the title Add warning for multiple shortest paths Add warning for all possible paths and cyclic path Sep 23, 2020
@sidhu1012
Copy link
Contributor Author

@moorepants Pls check now

@oscarbenjamin
Copy link
Contributor

Maybe this code should use the topological_sort function from iterables:
https://docs.sympy.org/latest/modules/utilities/iterables.html#sympy.utilities.iterables.topological_sort

Or otherwise maybe a more generic routine could be added to iterables and used here.

@sidhu1012
Copy link
Contributor Author

Or otherwise maybe a more generic routine could be added to iterables and used here.

Can you please elaborate

@asmeurer
Copy link
Member

The release notes don't need to mention test cases. They should only be for end-users.

@asmeurer
Copy link
Member

I would like for @moorepants to confirm this is what he had in mind. My opinion is we generally should be minimal in omitting warnings in SymPy, though there are legitimate use-cases for them.

@moorepants
Copy link
Member

These warnings will only occur if the user sets up their kinematics incorrectly. I think it is a useful feature for the user and it is also pertinent now that this automatic calculation of velocities has been implemented. We should, in general, let the user know if they incorrectly define relationships among points or reference frames.

@sidhu1012 sidhu1012 closed this Sep 24, 2020
@sidhu1012 sidhu1012 reopened this Sep 24, 2020
@sidhu1012 sidhu1012 closed this Sep 24, 2020
@sidhu1012 sidhu1012 reopened this Sep 24, 2020
@sidhu1012
Copy link
Contributor Author

@moorepants Check now please

@asmeurer
Copy link
Member

Should it rather be an error?

Another issue with warnings is that they are only emitted once by default (though that might not be the case if the message is different).

@moorepants
Copy link
Member

No because the selection in the algorithm could be correct and the problem could successfully be defined if the extraneous position connection doesn't effect the result.

@sidhu1012
Copy link
Contributor Author

Should it rather be an error?

These warnings shouldn't be error , as the calculated velocity is correct , but the veloctiy that is calculated would be dependent on how user creates the point tree. So I think the idea is to tell user that calculated veloctiy is dependent on how they define relation between points.

@sidhu1012
Copy link
Contributor Author

@moorepants Does it seems right or require further changes?

@sidhu1012
Copy link
Contributor Author

@moorepants Does it seems right or require further changes?

@moorepants Please review it

@moorepants
Copy link
Member

Please be patient, as we are all doing this as volunteers. I'll review when I have the time. I recommend working on other PRs while you wait for reviews.

with warnings.catch_warnings():
warnings.simplefilter('error')
with ignore_warnings(UserWarning):
assert P4.vel(B) == q1.diff(t) * B.x + u2 * B.y + 2 * q2.diff(t) * B.z
Copy link
Member

Choose a reason for hiding this comment

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

It'd be helpful to have a comment explaining what is happening in each warning catch, as it isn't obvious from a quick read of the code. Does this one now cause a warning? Which one the cyclic or multipath one?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

multiplath warning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comment

Copy link
Member

Choose a reason for hiding this comment

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

So here it is supposed to get that warning? It isn't clear what each warning catch (in each test is doing). You should write a comment just above with in each one that is something like "there are two possible paths in this point tree, thus a warning is raised". Should you also ensure that the correct warning is raised, as there are two possible warnings.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added comments and also ensured that correct warning is being raised

Copy link
Member

Choose a reason for hiding this comment

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

Sorry about requesting that, I missed that the names of the functions explained what was going on too. I thought they were all old tests you added warning catching too. Regardless, it is clearer now. Thanks.

@moorepants
Copy link
Member

This LGTM and can be merged when tests pass.

@sidhu1012
Copy link
Contributor Author

This LGTM and can be merged when tests pass.

Thanks 😄

@moorepants moorepants merged commit adaf9ab into sympy:master Oct 1, 2020
@sidhu1012 sidhu1012 deleted the vel_warning branch October 1, 2020 06:35
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.

Warn the user when trees of points or trees of reference frames are not self consistent.
6 participants