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

Allowed assumptions poorly documented and missing validation of assumptions #21416

Open
HDembinski opened this issue May 2, 2021 · 4 comments · May be fixed by #21417
Open

Allowed assumptions poorly documented and missing validation of assumptions #21416

HDembinski opened this issue May 2, 2021 · 4 comments · May be fixed by #21417

Comments

@HDembinski
Copy link

HDembinski commented May 2, 2021

The Symbol class allows one to specify assumptions. Assumptions are frequently needed in engineering and physics to express that certain variables are real and positive (e.g. mass of a particle). Which assumptions are understood by Sympy is not well documented and mistyping the assumptions does not cause an error, which is bad.

Documentation issues

  1. Docstring of function symbols

The docstring mentions assumptions and shows integer and real in examples, but does not list all possible assumptions nor does it point to the place where such a list can be found (the latter would be better, the assumptions should be documented in the Symbol class, I suppose).

  1. Docstring of class Symbol

The docstring mentions assumptions in the class docstring but does not list all possible assumptions. The docstring of assumptions0 (why the 0 at the end?) also does not list all possible assumptions, they only appear by chance in the example code.

  1. Searching for "assumption" in Sympy docs yields results, but not on first hit

When you search in the Sympy online docs for the string "assumption" you find these hits (in that order):

Validation issues

The class Symbol does not validate the assumptions. One can pass arbitrary arguments. The user is not informed about typos, this is bad.

>>> from sympy import Symbol

>>> Symbol("x", real=True).assumptions0 # OK, real is a valid assumption
{'real': True, 'complex': True, 'imaginary': False, 'hermitian': True, 'infinite': False, 'finite': True, 'commutative': True, 'extended_real': True}
>>> Symbol("x", is_real=True).assumptions0 # BAD, is_real is not a valid assumption, this should raise an error
{'is_real': True, 'commutative': True}
@oscarbenjamin
Copy link
Contributor

I did write a lengthy page for the docs about assumptions here: #20090

I think it needs to be reorganised though.

@HDembinski HDembinski changed the title Possible assumptions poorly documented and missing validation of assumptions Allowed assumptions poorly documented and missing validation of assumptions May 2, 2021
@HDembinski
Copy link
Author

@oscarbenjamin Glad to see your contribution, I quickly read over the new docs and this is very much what I feel is missing in the user guide. Complementary to that I think the docstrings need to be improved as well to point the user to the right info.

@oscarbenjamin
Copy link
Contributor

I've merged #20090.

It should appear in the dev docs once they are updated.

Which docstrings should be changed to point to that information?

@oscarbenjamin
Copy link
Contributor

The link to those added docs are here:
https://docs.sympy.org/dev/guides/assumptions.html

There is still improvement that can be done on those but I think it's just good to have something up.

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

Successfully merging a pull request may close this issue.

2 participants