-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Added assumptions in Dynamicsymbols #18061
Conversation
✅ Hi, I am the SymPy bot (v149). 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:
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.
Update The release notes on the wiki have been updated. |
@Smit-create Thanks for this PR. Can you add a unit test? |
You also need to add release notes for this. |
@moorepants Yes I will add both the things. |
On last note: Please add some documentation in the docstring showing how to add assumptions. |
@moorepants Surely, I will add that too. |
Codecov Report
@@ Coverage Diff @@
## master #18061 +/- ##
=============================================
+ Coverage 74.864% 74.894% +0.029%
=============================================
Files 640 641 +1
Lines 166548 166564 +16
Branches 39176 39179 +3
=============================================
+ Hits 124686 124747 +61
+ Misses 36343 36298 -45
Partials 5519 5519 |
>>> q3= dynamicsymbols('q3', positive=True) | ||
q3(t) | ||
>>> q3.is_positive | ||
True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is good. Also add a note in the Parameters section explaining what **asumptions
is. You can reference the symbols()
or Symbol()
documentation.
f3=dynamicsymbols('f3',positive=True) | ||
assert f1.is_real==None | ||
assert f2.is_real | ||
assert f3.is_positive |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add spaces around the equals and after commas, as per PEP8.
f1=dynamicsymbols('f1') | ||
f2=dynamicsymbols('f2',real=True) | ||
f3=dynamicsymbols('f3',positive=True) | ||
assert f1.is_real==None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be is None
.
@moorepants Surely I will do the requires changes. Thanks for reviewing. |
In the release notes, only add one bullet "added assumptions to dynamicsymbols" and the header should be "physics" not "physics.vector" (I think). |
I metioned it physics at first, but it showed be error. So, I changed it to physics.vector |
Ok, I thought the comment should have a green checkmark, so I was confused. it is fine. |
sympy/physics/vector/functions.py
Outdated
@@ -587,20 +587,33 @@ def dynamicsymbols(names, level=0): | |||
level : int | |||
Level of differentiation of the returned function; d/dt once of t, | |||
twice of t, etc. | |||
Assumptions : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lowercase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay
sympy/physics/vector/functions.py
Outdated
@@ -587,20 +587,33 @@ def dynamicsymbols(names, level=0): | |||
level : int | |||
Level of differentiation of the returned function; d/dt once of t, | |||
twice of t, etc. | |||
Assumptions : | |||
real = False | |||
positive = False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should say something like "Key-value pairs of assumptions, see symbols
for more information". You should read this: https://docs.sympy.org/dev/documentation-style-guide.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I have referred it from class Symbol, and it had similar kind to explanation of assumption
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, that sounds like Symbol's docstring is poor then and we should make it better here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"""Uses symbols and Function for functions of time.
Creates a SymPy UndefinedFunction, which is then initialized as a function
of a variable, the default being Symbol('t').
Parameters
==========
names : str
Names of the dynamic symbols you want to create; works the same way as
inputs to symbols
level : int
Level of differentiation of the returned function; d/dt once of t,
twice of t, etc.
assumptions :
real(bool) : This is used to set the dynamicsymbol as real, by default is False
positive(bool) : This is used to set the dynamicsymbol as positive, by default is False
commutative(bool) : This is used to set the commutative property of a dynamicsymbol, by default is True
integer(bool) : This is used to set the dynamicsymbol as integer , by default is False
Examples
========
>>> from sympy.physics.vector import dynamicsymbols
>>> from sympy import diff, Symbol, sqrt
>>> q1 = dynamicsymbols('q1')
>>> q1
q1(t)
>>> q2 = dynamicsymbols('q2', real=True)
>>> q2.is_real
True
>>> q3 = dynamicsymbols('q3', positive=True)
>>> q3.is_positive
True
>>> q4, q5 = dynamicsymbols('q4,q5', commutative=False)
>>> bool(q4*q5 != q5*q4)
True
>>> q6 = dynamicsymbols('q6', integer=True)
>>> q6.is_integer
True
>>> diff(q1, Symbol('t'))
Derivative(q1(t), t)
"""
Is this the correct way to document?
sympy/physics/vector/functions.py
Outdated
|
||
Examples | ||
======== | ||
|
||
>>> from sympy.physics.vector import dynamicsymbols | ||
>>> from sympy import diff, Symbol | ||
>>> from sympy import diff, Symbol, sqrt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the sqrt for?
Remove the |
Yes, it was completely out of my notice |
Thanks for the help provided, as it was my first contribution I made some silly mistakes but will surely not repeat next time. Thanks for your guidance |
sympy/physics/vector/functions.py
Outdated
real(bool) : This is used to set the dynamicsymbol as real, by default is False | ||
positive(bool) : This is used to set the dynamicsymbol as positive, by default is False | ||
commutative(bool) : This is used to set the commutative property of a dynamicsymbol, by default is True | ||
integer(bool) : This is used to set the dynamicsymbol as integer , by default is False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may not render correctly when converted to HTML for the documentation. I think it will all be treated as one line. You may need to use a list like:
- thing 1
- thing 2
Also wrap the lines at 79 characters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* real(bool) : This is used to set the dynamicsymbol as real, by default is False
* positive(bool) : This is used to set the dynamicsymbol as positive, by default is False
* commutative(bool) : This is used to set the commutative property of a dynamicsymbol,
by default is True
* integer(bool) : This is used to set the dynamicsymbol as integer , by default is False
You mean this way should I write?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but I think you should check that it renders correctly by building the docs locally.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I have made the required changes and wrapped the lines to 79 characters
One more likely issue. You can build the docs locally to check if it renders correctly. |
@moorepants I am making the required changes in physics.vector.functions.py but it is showing error in sympy.utilities.lambdify.lambdify though I haven't made any changes there. |
|
There are unrelated test failures. |
Then what I did is correct? |
Yes, I think it is good. |
So will it get merged? |
Once the tests are fixed it will. |
But they are failing unrelated test. So do I need to do anything for fixing them? |
Wait on #18080 to get merged and then you'll need to merge in the master branch here. |
Is it good to go now? |
Yes! Thank you for the contribution. |
Added assumptions to dynamicsymbols
References to other Issues or PRs
Fixes #17739
Brief description of what is fixed or changed
Added assumptions in dynamicsymbols so it can be positive, real, etc.
Other comments
Release Notes