emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Python execution question
@ 2012-05-06 11:09 Petro
  0 siblings, 0 replies; only message in thread
From: Petro @ 2012-05-06 11:09 UTC (permalink / raw)
  To: emacs-orgmode


Hi list.
I try to process my data in python.  I store outputs from different
scripts in separate txt files and load data using numpy.loadtxt. I want
to change it store outputs in results tables. 


So I have this example table

#+TBLNAME: test-table
| 1e212 | 2e1  | 23e3  |

and use it as variable for python source code block below

#+BEGIN_SRC python :var rates=test-table 
  import numpy as np
  for i in range(len(rates)):
      rates[i]=map(float,rates[i])
  rates2=np.array(rates)
  return np.log10(rates2)
#+END_SRC

#+RESULTS:
| 212 | 1.30103 | 4.36172784 |

works OK so far. 
And here comes a problem. I want to be able to debug my code in python
session. I use session header argument  for it and access session via
org-babel-switch-to-session. 

#+BEGIN_SRC python :var rates=test-table :session
  import numpy as np
  for i in range(len(rates)):
      rates[i]=map(float,rates[i])
  rates2=np.array(rates)
  
#+END_SRC

#+RESULTS:


Then it does not work. And inside of session i have the following
output:
__________________________________________

>>> rates=[["1e212", "2e1", "23e3"]]
>>> import numpy as np
for i in range(len(rates)):
    rates[i]=map(float,rates[i])
rates2=np.array(rates)


open('/tmp/babel-54890hk/python-54897vP', 'w').write(str(_))


'org_babel_python_eoe'
>>> ... ...   File "<stdin>", line 3
    rates2=np.array(rates)
         ^
SyntaxError: invalid syntax
>>> >>> >>> Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name '_' is not defined
>>> >>> >>> 'org_babel_python_eoe'
>>> 
_________________________________________________________
Thank for help in advance.
Petro.
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2012-05-06 11:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-06 11:09 Python execution question Petro

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).