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

Use srepr instead of sstr for __repr__ printing #39

Merged
merged 9 commits into from Jan 17, 2016

Conversation

1 participant
@skirpichev
Copy link
Collaborator

skirpichev commented Mar 26, 2015

see #32

  • fix tests
  • document repr behavior in docs
  • fix polys repr methods (e.g. SubModule.repr returns things like '')
  • rebase

most test failures because container’s str uses contained objects’ repr. I.e. see this.

See also:
https://www.python.org/dev/peps/pep-3140/
https://groups.google.com/forum/#!topic/python-ideas/ChVbmWhlqJA

@skirpichev skirpichev force-pushed the repr-printing branch from b6f4769 to 36361ae Apr 3, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 36361ae to 21ae447 Apr 11, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 21ae447 to 559ee43 May 16, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 559ee43 to 25010d8 Jun 1, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 25010d8 to 4ae5882 Jul 19, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 4ae5882 to 07a85e5 Aug 27, 2015

@skirpichev skirpichev force-pushed the repr-printing branch from 07a85e5 to 644f140 Oct 3, 2015

@skirpichev skirpichev added this to the First public release milestone Oct 18, 2015

@skirpichev skirpichev force-pushed the repr-printing branch 4 times, most recently from c55dc2d to 95af900 Jan 7, 2016

@skirpichev skirpichev force-pushed the repr-printing branch 3 times, most recently from 8d20d88 to 5410d98 Jan 15, 2016

skirpichev added some commits Mar 26, 2015

Use srepr instead of sstr for __repr__ printing
As it stated by the Python docs [1] about returned value of
__repr__(), "If at all possible, this should look like a valid
Python expression that could be used to recreate an object
with the same value (given an appropriate environment)."

It seems, that our printing system violates this maxima.  "More
accurate rule - is that repr() output for SymPy's objects is something
that can be "a suitable input for sympify()" [2].   An example is
Rational's printing:

In [3]: repr(Rational(1, 2))
Out[3]: '1/2'

I believe, we should prefer Python's conventions.

This closes #32.

References
==========

.. [1] https://docs.python.org/3/reference/datamodel.html#object.__repr__
.. [2] sympy/sympy#6880 (comment)
Override sys.__displayhook__ for doctests
Unfortunately, we can't just override sys.displayhook,
see https://bugs.python.org/issue26092.

@skirpichev skirpichev force-pushed the repr-printing branch from 5410d98 to 16fed1b Jan 17, 2016

@skirpichev skirpichev force-pushed the repr-printing branch from 16fed1b to 9e8ba2b Jan 17, 2016

skirpichev added a commit that referenced this pull request Jan 17, 2016

Merge pull request #39 from skirpichev/repr-printing
Use srepr instead of sstr for __repr__ printing

@skirpichev skirpichev merged commit 0cc5ed2 into master Jan 17, 2016

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
coverage/coveralls Coverage increased (+0.04%) to 91.92%
Details

@skirpichev skirpichev deleted the repr-printing branch Jan 17, 2016

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