From: Petro <x.piter@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Python execution question
Date: Sun, 06 May 2012 13:09:54 +0200 [thread overview]
Message-ID: <877gwpd0ql.fsf@cica.cica> (raw)
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.
reply other threads:[~2012-05-06 11:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=877gwpd0ql.fsf@cica.cica \
--to=x.piter@gmail.com \
--cc=emacs-orgmode@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).