Search code examples
pythonmatlaboctavesymbolic-math

Avoid unwanted text from Octave's symbolic package


When you call vpa (from Octave's symbolic package) for the first time, Octave produces some text on screen before outputting the actual result. For example:

>> x = pretty(vpa('sqrt(-1)'))
OctSymPy v2.2.4: this is free software without warranty, see source.
Initializing communication with SymPy using a popen2() pipe.
Detected Windows: using "winwrapy.bat" to workaround Octave bug #43036
Some output from the Python subprocess (pid 6680) might appear next.

OctSymPy: Communication established.  SymPy v0.7.6.1.
Python 2.7.11 (v2.7.11:6d1b6a68f775, Dec  5 2015, 20:32:19) [MSC v.1500 32 bit (Intel)]
x =   1.0*I

Note that the actual output (variable x) is the string '1.0*I', as expected. The rest is not part of the function output, but rather text produced directly on screen.

That text doesn't appear in subsequent calls to vpa, only the first time after starting Octave. It doesn't seem to be specifically related to vpa, but to the way Octave communicates with Python to handle symbolic computations.

Is there a way to avoid that text being displayed? Or failing that, is there a way to temporarily capture stdout to intercept that text? For example, Matlab's evalc (evaluate an expression with capture) would be a solution, but Octave doesn't have that function.


Solution

  • An option sympref quiet on has recently been committed which at least suppresses some of the messages. Check doc sympref to see if the changes are already present in your version.