From mboxrd@z Thu Jan 1 00:00:00 1970 From: Evan Misshula Subject: Re: Fwd: run python from org, draft Date: Fri, 29 Mar 2013 14:33:37 -0400 Message-ID: References: <5154BC51.1050001@easy-emacs.de> <5155A97D.2090907@easy-emacs.de> <87sj3e6y5n.fsf@gmail.com> <5155B346.3060708@easy-emacs.de> <87ehey6upd.fsf@gmail.com> <5155C611.5000104@easy-emacs.de> <871uayrvju.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=047d7b5d9c6f69cf7504d91482ff Return-path: Received: from eggs.gnu.org ([208.118.235.92]:52974) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULe7T-0004Px-L1 for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 14:33:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ULe7P-0008HC-5x for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 14:33:43 -0400 Received: from mail-wi0-x22f.google.com ([2a00:1450:400c:c05::22f]:60961) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ULe7O-0008Gr-Rh for emacs-orgmode@gnu.org; Fri, 29 Mar 2013 14:33:39 -0400 Received: by mail-wi0-f175.google.com with SMTP id c10so115741wiw.14 for ; Fri, 29 Mar 2013 11:33:37 -0700 (PDT) In-Reply-To: <871uayrvju.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Eric Schulte Cc: Gary Oberbrunner , emacs-orgmode --047d7b5d9c6f69cf7504d91482ff Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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=3D1E-6): """Function that takes the second derivative""" r=3D(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)=3Dt^{-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=3D1.2$ #+name: evaluating-the-target #+begin_src python :session :results output :exports both t=3D1.2 d2g =3D diff2(g,t) print "g''(%f)=3D%f" % (t, d2g) #+end_src #+RESULTS: evaluating-the-target : : >>> g''(1.200000)=3D9.767798 But it does not appear to support named session: Works with a named session. #+begin_src python :session foo x =3D 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 wrot= e: > Andreas R=F6hler 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 heade= r > 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 > > --=20 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 --047d7b5d9c6f69cf7504d91482ff Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Org-mode version 8.0-pre (release_8.0-pre-203-g9= 93e3e @ /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.=A0 It does hold session definiti= on:

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

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

#+end_src
#+RESULTS: target-funtion

Now let's define the second deri= vative and evaluate it at $t=3D1.2$

#+name: evaluating-the-target
#+begin_src python :session=A0 :result= s output :exports both
=A0 t=3D1.2
=A0 d2g =3D diff2(g,t)
=A0 prin= t "g''(%f)=3D%f" % (t, d2g)
#+end_src

#+RESULTS= : evaluating-the-target
:
: >>> g''(1.200000)=3D9.767798

But it d= oes not appear to support named session:

Works with a named session.=
#+begin_src python :session foo
=A0 x =3D 9
=A0 x
#+end_src
#+RESULTS:
: None

#+begin_src python :session foo
=A0 x
#+e= nd_src

#+RESULTS:

Thanks,

Evan

=





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

"Inst= ruction does much, but encouragement does everything." Johann Wolfgang= Von Goethe
www.snrg-nyc.org
--047d7b5d9c6f69cf7504d91482ff--