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

Better docs for Subs. #2649

Merged
merged 1 commit into from
Dec 17, 2013
Merged

Better docs for Subs. #2649

merged 1 commit into from
Dec 17, 2013

Conversation

hargup
Copy link
Contributor

@hargup hargup commented Dec 3, 2013

  • Added examples to resolve confusion regarding the result of subs and the limiting value of the expression at that point
  • Added examples to clearly show the difference between substitution and numerical evaluation.
  • Added evalf in the See Also of Subs documentation section.

The substitution is literal replacement of old arguments with new one
and it may not reflect the limiting behaviour of the expression.

>>> (x**3 - 3*x).subs({x:oo})
Copy link
Contributor

Choose a reason for hiding this comment

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

space after colon. or just subs(x, oo)?

Also, may be you can include limit result as well? See, for example, a demo for simultaneous=True.

@skirpichev
Copy link
Contributor

anyway, +1

@asmeurer
Copy link
Member

asmeurer commented Dec 3, 2013

Move the example down. You've injected it in the middle of a discussion about the difference between subs and xreplace.

See Also
========
replace: replacement capable of doing wildcard-like matching,
parsing of match, and conditional replacements
xreplace: exact node replacement in expr tree; also capable of
using matching rules
evalf: evaluate the given formula to a given accuracy of digits
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this?

Copy link
Member

Choose a reason for hiding this comment

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

..and note that evalf calculates to a desired level of precision.

On Thu, Dec 5, 2013 at 8:19 AM, Sergey B Kirpichev <notifications@github.com

wrote:

In sympy/core/basic.py:

     See Also
     ========
     replace: replacement capable of doing wildcard-like matching,
              parsing of match, and conditional replacements
     xreplace: exact node replacement in expr tree; also capable of
               using matching rules
  •    evalf: evaluate the given formula to a given accuracy of digits
    

Why this?


Reply to this email directly or view it on GitHubhttps://github.com//pull/2649/files#r8129547
.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@skirpichev I did this because I thought people might try to substitute the variable with a constant to evaluate the expression. My unnecessary pull request [1] was also in some ways a result of confusion between evalf and subs. So I think adding evalf in the See Also section might serve as a good pointer.

@skirpichev
Copy link
Contributor

ok, if there is no objection against, I'll merge this in 24h.

@hargup, I think it's good to give a bit more verbose and descriptive commit message.

- Added examples to resolve confusion regarding the result of subs and the limiting value of the expression at that point
- Added examples to clearly show the difference between substitution and numerical evaluation.
- Added `evalf` in the `See Also` of `Subs` documentation section.
@hargup
Copy link
Contributor Author

hargup commented Dec 16, 2013

@skirpichev Thanks, I have updated the commit message and the pull request description.

skirpichev added a commit that referenced this pull request Dec 17, 2013
@skirpichev skirpichev merged commit dac52ae into sympy:master Dec 17, 2013
@hargup hargup deleted the fix_subs_doc branch December 18, 2013 08:02
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.

4 participants