23.03.2012 07:46, smichr пишет:
> Within an interactive session I can override the printing of a matrix
> as follows:
>
> >>> Matrix.__repr__ = mrepr
> >>> randMatrix(2,2)
> [34 16]
> [33 54]
>
> When I try this in a docstring, it doesn't change the output. Does
> anyone know what I should override in the docstring to get this to
> work?
>
If you use SymPy doctest utility, then sympy printer is used and it can
check property "_sympystr":
"""
>>> from sympy.matrices import *
>>> def mrepr(self, printer):
return "777"
>>> Matrix._sympystr = mrepr
>>> randMatrix(2)
"""
Failed example:
randMatrix(2)
Expected nothing
Got:
777
This will work also and in interactive session.
Note also, that there is "_sympyrepr" (may be obsolated, it calls by
"srepr" function)
And "_pprint" for pretty print overloading.
---
Alexey.
--
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.