Change preview to use BytesIO instead of StringIO #2398

Merged
merged 2 commits into from Nov 11, 2013

Projects

None yet

4 participants

@asmeurer
Member

This fixes it to work in Python 3. Since BytesIO is available in Python 2.6,
the use of StringIO has been deprecated. See
https://code.google.com/p/sympy/issues/detail?id=3984.

This fixes, in particular, init_printing(use_latex='png') in Python 3.

@asmeurer asmeurer Change preview to use BytesIO instead of StringIO
This fixes it to work in Python 3. Since BytesIO is available in Python 2.6,
the use of StringIO has been deprecated. See
https://code.google.com/p/sympy/issues/detail?id=3984.

This fixes, in particular, init_printing(use_latex='png') in Python 3.
155b20d
@asmeurer
Member

If I understand http://docs.python.org/2/library/io.html correctly, we should be using the io module everywhere for StringIO, instead of StringIO, meaning we can remove it from compatibility. Should I make this change?

@asmeurer
Member

@flacjacket why did you add StringIO to compatibility?

@flacjacket
Member

I'd put it there for the StringIO.StringIO move to io.StringIO. If we change to using io.StringIO, it can be removed from compatibility.

@asmeurer
Member

But io was introduced in Python 2.6

@asmeurer
Member

I forgot that I opened an issue for this specifically, which should be closed when this is merged. https://code.google.com/p/sympy/issues/detail?id=3983

@asmeurer
Member

I guess I ought to see if I can add a test for this.

@jrioux
Member
jrioux commented Aug 22, 2013

SymPy Bot Summary: Passed after merging asmeurer/preview_bytesio (155b20d) into master (35b7b66).
PyPy 2.0.0-beta-1; 2.7.3-final-42: pass
Python 2.7.2-final-0: pass
Python 3.2.1-final-0: pass
Sphinx 1.1.3: pass
Doc Coverage: unchanged
35.925% of functions have doctests (compared to 35.925% in master)
41.320% of functions are imported into Sphinx (compared to 41.320% in master)

@asmeurer
Member

It seems there aren't any tests for preview.

@asmeurer
Member

@thisch do you know how to test preview() in the regular tests?

@thisch
Contributor
thisch commented Aug 24, 2013

No not automatically. If we want to write regular tests what exactly do we want to test? Do we want to compare the generated files (png, pdf, ..) with checked in reference files ? If you want I can have a look at mpl how it is done there.

@asmeurer
Member

They use some fuzzy image comparison algorithm. We probably don't need to go that far. We should just verify that it works at all. Similar to how the plotting tests work.

@asmeurer
Member

SymPy Bot Summary: ❗️ There were merge conflicts (could not merge asmeurer/preview_bytesio (155b20d) into master (69e8a9a)); could not test the branch.
@asmeurer: Please merge your branch with master. See the report for a list of the merge conflicts.

@asmeurer asmeurer Merge branch 'master' into preview_bytesio
Conflicts:
	sympy/interactive/printing.py
2280187
@asmeurer
Member
asmeurer commented Oct 9, 2013

SymPy Bot Summary: 🔴 Failed after merging asmeurer/preview_bytesio (2280187) into master (69697d8).
@asmeurer: Please fix the test failures.
Python 2.6.8-final-0: pass
Python 2.7.3-final-0: pass
🔴 PyPy 1.8.0-final-0; 2.7.2-final-42: fail
Python 3.2.3-final-0: pass
🔴 Sphinx 1.1.3: fail

@asmeurer
Member

I'm going to merge this. Hopefully it's not too old to cause some test failures in master.

@asmeurer asmeurer merged commit 3c93ffa into sympy:master Nov 11, 2013

1 check failed

default The Travis CI build could not complete due to an error
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment