emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] Fwd: run python from org, draft


From: Evan Misshula
Subject: Re: [O] Fwd: run python from org, draft
Date: Fri, 29 Mar 2013 14:33:37 -0400

Org-mode version 8.0-pre (release_8.0-pre-203-g993e3e @ /home/evan/Documents/org/elisp/org-mode/lisp/)
GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 2.24.10) of 2013-03-21 on evan-Dell-System-Inspiron-N7110 [2 times]

I installed the patched version.  It does hold session definition:

#+name: second-deriv-function
#+begin_src python :session  :results output :exports code
  def diff2(f, x, h=1E-6):
        """Function that takes the second derivative"""
        r=(f(x-h)-2*f(x)+f(x+h))/float(h*h)
        return r

#+end_src
#+RESULTS: second-deriv-function

Now let's write a target function, say $g(t)=t^{-6}$:
#+name: target-funtion
#+begin_src python :session :results output :exports code
  def g(t):
      """well behaved target function"""
      return t**(-6)

#+end_src

#+RESULTS: target-funtion

Now let's define the second derivative and evaluate it at $t=1.2$

#+name: evaluating-the-target
#+begin_src python :session  :results output :exports both
  t=1.2
  d2g = diff2(g,t)
  print "g''(%f)=%f" % (t, d2g)
#+end_src

#+RESULTS: evaluating-the-target
:
: >>> g''(1.200000)=9.767798

But it does not appear to support named session:

Works with a named session.
#+begin_src python :session foo
  x = 9
  x
#+end_src

#+RESULTS:
: None

#+begin_src python :session foo
  x
#+end_src

#+RESULTS:

Thanks,

Evan



On Fri, Mar 29, 2013 at 12:59 PM, Eric Schulte <address@hidden> wrote:
Andreas Röhler <address@hidden> writes:

> Am 29.03.2013 17:20, schrieb Eric Schulte:
>
>> A valid opinion, in fact I think I defended that point of view myself,
>
> Hi Eric,
>
> so, if I'm saying: let's make things considerably easier, working right from the spot,
> why not try that?
>
> What I need still is a specification, what :session and the other header arguments shall do.
> Presently they do quite different things. Also can't read a bulk of mails to figure out some guessing.
>
> Please write a specification and with the help of the other guys let's have some tiny and
> effective ob-python.
>

Sorry, I'm not going to do this work for you.  If you want to take a
shot at re-working ob-python, then you're welcome to.  However, I would
recommend first reading through some of the history which lead to its
current state, and fully understanding what that current state is (which
at a minimum means reading and digesting the relevant documentation).

> Let's see of we need more lines than ob-emacs-lisp.el :)
>

You will. :)

Best of luck,

>
> Cheers

--
Eric Schulte
http://cs.unm.edu/~eschulte




--
Evan Misshula
Doctoral Student (Criminal Justice)
CUNY John Jay
"Let us reform our schools, and we shall find little reform needed in our prisons."
       John Ruskin, Unto This Last, essay 2 (1862)
       English critic, essayist, & reformer (1819 - 1900)

"Instruction does much, but encouragement does everything." Johann Wolfgang Von Goethe
www.snrg-nyc.org

reply via email to

[Prev in Thread] Current Thread [Next in Thread]