I think all the quantum printing code and test should remain in physics. The reason is that physics is supposed to be an isolated module. The module shouldn't be imported at all with "import sympy" or "from sympy import *". If you put the code in printing, then it will cause the physics module to be imported with the printing module. There are ways around that, but to me, it makes the most sense to put the quantum printing code in the quantum module for this reason. And the tests should go there too for the same reason.
Even so, you should follow exactly the procedure in the test_pretty.py. Perhaps it would be easier to put all the quantum printing tests in a single test_quantum_pretty.py file. Then just copy things as they are in test_pretty.py (including the unicode coding comment at the top of the file). By the way, I don't know to what degree the current code actually follows what I said above. But if physics code is in other modules, it should probably be moved into the physics module. Aaron Meurer 2011/6/20 [email protected] <[email protected]>: > > > 2011/6/20 Mateusz Paprocki <[email protected]> >> >> Hi, >> >> 2011/6/20 [email protected] <[email protected]> >>> >>> Certain tests pass if unicode characters are escaped (like in u"\XXXX") >>> but do not pass if the character is written in unicode (like u"ะค"). For >>> examples see the tests that fail in the branch quantum_printing. >>> >>> Those test pass if they are run in python, fail in ipython (there is a >>> bug in ipython >>> http://stackoverflow.com/questions/5860713/ipython-unicode-in-gnome-terminal-linux) >>> and fail in sympy-bot (I don't know why). They pass if the characters are >>> escaped. >> >> How did you run those tests in IPython? I tried your branch both in Python >> (2.6.6) and IPython and all run fine. I used this: >> In [1]: from sympy.utilities.runtests import test >> In [2]: test("sympy/physics") >> (...) >> to run tests under IPython. >> > > I used ./bin/test - the tests passed. Then I copied the assert statements > (with all the necessary imports and definitions) in both ipython 0.10 and > python 2.7. They worked in python but not in ipython (the unicode strings > were badly parsed). > > When running them by using test("sympy/physics") they both pass. > >>> >>> My questions is not how to write the test that I gave as an example - >>> they will be rewritten with escaped characters. The question is should I use >>> unicode characters (that should be supported by the language) even when some >>> tools seem to have problems with them? To me it seems a bad idea always to >>> escape characters - the tests become unreadable. >> >> Do you experience any problems with tests in sympy.printing.pretty? If not >> then you should follow *exactly* the approach in pretty and you should be on >> the safe side. I see that you implemented printers for physics module >> outside sympy.printing. What it the rationale for this? > > The printers (actually they are not new printers, just overridden methods) > were already implemented when I started working on them. So I can not give a > rationale for them being done outside sympy.printing (Actually I have no > idea how else those can be done. As I said, it's just overridden methods). I > only refactored them so they can be used more easily. > > But there is one tangential question I would like to ask, Mateusz. Should I > move all the printing *tests* to sympy.printing. If so, I was completely > ignorant of this practice and I apologize. > >> >> I would create mixin classes for repr, str, pretty and latex with >> appropriate printing methods and add those classes as basses to appropriate >> printers. This way, you will have to make sure that Unicode is setup >> properly only in one or two files, not n >> 2. >> I would also use U() function from pretty_symbology.py, to make sure that >> Unicode character you use is actually globally available. U() will give you >> None if given character (which you will specify by Unicode name) belongs to >> the standard or not. It often happens that on a certain platform you can get >> more Unicode symbols, but they aren't available elsewhere. >> >>> >>> Regards >>> Stefan >>> >>> P.S. # -*- encoding: utf-8 -*- was present when the tests failed >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "sympy" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/sympy?hl=en. >> >> Mateusz >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sympy" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/sympy?hl=en. > > -- > You received this message because you are subscribed to the Google Groups > "sympy" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/sympy?hl=en. > -- You received this message because you are subscribed to the Google Groups "sympy" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/sympy?hl=en.
