Closed yatsky closed 4 years ago
Thanks for reporting the bug.
Hi @dickmao ,
Thanks for the quick fix, but now I'm only getting "test"
, is this desired behaviour?
Thanks.
#+name: 1 test my solution
#+caption: 1 test my solution
#+begin_src ein-python :session localhost :results output code
def abc():
print("test")
return "abc"
abc()
#+end_src
#+RESULTS: 1 test my solution
#+begin_src none
test
#+end_src
It matches ob-python which also just returns "test". "abc" is a return value; it is not part of stdout.
Thanks.
I tried to implement the following. Here if I set it the results to 'output', I get 'test' printed but I don't see the plot, and if I set results to raw then I see the plot but 'test' is not printed. Is there a way to have both 'test and the plot printed?
#+BEGIN_SRC ein-python :session localhost :results output raw drawer
import numpy, math, matplotlib.pyplot as plt
%matplotlib inline
x = numpy.linspace(0, 2*math.pi)
def abc():
print("test")
return "abc"
abc()
plt.plot(x, numpy.sin(x))
plt.show()
#+END_SRC```
Sorry to yatsky for having dismissed this concern. Yes, the relevant org section says under :session
both output and results should be displayed, but if :session
is not set the old behavior of omitting the result was correct.
Since ob-ein should always have :session set, we should always print everything.
Commit 9b52b02
Problem description
Result from ob-ein source block is not the same as STDOUT when using
:results output
header.Steps to reproduce the problem
In an org file, run the following src block using EIN.
Get the following. A newline and a string of "abc". Expecting
test
and"abc"
.+RESULTS: 1 test my solution
+begin_src none
'abc'
+end_src
But if we run the following python code without using EIN.
We get the following. Only the string "test" is in the output. Expecting
test
and"abc"
.+RESULTS:
+begin_src python
test
+end_src
If we run the
abc()
function in python REPL.According to the documentation, when using
:results output
header, result should be collected from STDOUT during execution of the code, which sounds like it should include bothtest
and'abc'
. And this had been the case before I updated EIN to the current version, but I don't remember which version I was using or if I mixed up something when I did the update.System info: