From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Eric Schulte" Subject: Re: Complex numbers Date: Tue, 12 Apr 2011 21:52:12 -0600 Message-ID: <87tye24xlf.fsf@gmail.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([140.186.70.92]:55268) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9r7t-0004S6-FF for emacs-orgmode@gnu.org; Tue, 12 Apr 2011 23:52:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9r7r-0004gW-SH for emacs-orgmode@gnu.org; Tue, 12 Apr 2011 23:52:21 -0400 Received: from mail-iw0-f169.google.com ([209.85.214.169]:36523) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9r7r-0004gR-Lw for emacs-orgmode@gnu.org; Tue, 12 Apr 2011 23:52:19 -0400 Received: by iwg8 with SMTP id 8so304315iwg.0 for ; Tue, 12 Apr 2011 20:52:19 -0700 (PDT) In-Reply-To: (Renier Marchand's message of "Tue, 12 Apr 2011 17:09:20 +0200") 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: Renier Marchand Cc: emacs-orgmode@gnu.org Hi Renier, The Org-mode table machinery is interpreting the values of your table cells as emacs lisp (given that the table formula is an elisp, rather than a calc formula). Due to the "," the result is a weird nested list which confuses your python code block. Some options here include... 1. wrapping these cells in quotes so that they are passed to the python block as strings... #+source: parameter-variation(data=3D0) #+begin_src python :result values return 'text' #+end_src |---------------------------------------| | "(0.0331901438056,0.000535222885197)" | | "(0.0333434157791,0.000537930174356)" | | "(0.0345727512157,0.000559346040457)" | | "(0.0353146483908,0.000571501584524)" | | "(0.0355522909393,0.000574387067408)" | | "(0.0356575682336,0.000574851263615)" | | "(0.0357806926897,0.000575051685084)" | |---------------------------------------| | text | #+TBLFM: @8$1=3D'(sbe parameter-variation (nums @1$1..@7$1)) 2. referencing the table from an external code block, rather than inside of a table formula. This is probably the easier solution, but it doesn't insert the result into your table, unless you do something tricky like give the code block and the table the same name so that the results of the code block replace the table... #+results: complex-data |-------------------------------------| | (0.0331901438056,0.000535222885197) | | (0.0333434157791,0.000537930174356) | | (0.0345727512157,0.000559346040457) | | (0.0353146483908,0.000571501584524) | | (0.0355522909393,0.000574387067408) | | (0.0356575682336,0.000574851263615) | | (0.0357806926897,0.000575051685084) | #+TBLFM: @8$1=3D'(sbe parameter-variation (nums @1$1..@7$1)) #+begin_src python :var data=3Dcomplex-data return data #+end_src Hope this helps -- Eric Renier Marchand writes: > Hi. > > I have been playing around with complex data that has been returned > from Python. This is obviously not in calc.el format but if I change > them to the correct format I can manipulate them using calc. > > but > > When I want to pass the complex numbers (python format) to python I > get an error. If I pass real number everything works as expected > > For example: > > #+source: parameter-variation(data=3D0) > #+begin_src python :result values > return 'text' > #+end_src > > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0 hmin | = =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |---+-------+-----------------------------= --------| > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0 | =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0 0.05 | (0.0331901438= 056,0.000535222885197) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 0.1 | (0.03334= 34157791,0.000537930174356) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 0.3 | (0.03457= 27512157,0.000559346040457) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 0.6 | (0.03531= 46483908,0.000571501584524) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 0.9 | (0.03555= 22909393,0.000574387067408) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0=C2=A0 1.2 | (0.03565= 75682336,0.000574851263615) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0 10.0 | (0.0357806926= 897,0.000575051685084) | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | $ | x=3D0.1 | y=3D0.1=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 |=C2=A0 text | =C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 | > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 #+TBLFM: @11$2=3D'(sbe "parameter-variatio= n" (data > @3$2..@9$2))::@11$3=3D'(sbe "parameter-variation" (data @3$3..@9$3)) > > i.e. I get the word 'text' returned for column 2 where there are real > numbers but I don't get anything returned where there are complex > numbers. As you can see, there are no actual calculation performed on > the data I am just returning 'text' so I am expecting it to work in > both instances. > > The debug sessions show the following for the real column: > > Substitution history of formula > Orig: '(sbe "parameter-variation" (data @3$2..@9$2)) > $xyz-> '(sbe "parameter-variation" (data @3$2..@9$2)) > @r$c-> '(sbe "parameter-variation" (data #("0.05" 0 4 (fontified t > face org-table)) #("0.1" 0 3 (fontified t face org-table)) #("0.3" 0 3 > (fontified t face org-table)) #("0.6" 0 3 (fontified t face > org-table)) #("0.9" 0 3 (fontified t face org-table)) #("1.2" 0 3 > (fontified t face org-table)) #("10.0" 0 4 (fontified t face > org-table)))) > $1-> '(sbe "parameter-variation" (data #("0.05" 0 4 (fontified t > face org-table)) #("0.1" 0 3 (fontified t face org-table)) #("0.3" 0 3 > (fontified t face org-table)) #("0.6" 0 3 (fontified t face > org-table)) #("0.9" 0 3 (fontified t face org-table)) #("1.2" 0 3 > (fontified t face org-table)) #("10.0" 0 4 (fontified t face > org-table)))) > Result: text > Format: NONE > Final: text > > and for the complex column: > > Substitution history of formula > Orig: '(sbe "parameter-variation" (data @3$3..@9$3)) > $xyz-> '(sbe "parameter-variation" (data @3$3..@9$3)) > @r$c-> '(sbe "parameter-variation" (data > #("(0.0331901438056,0.000535222885197)" 0 35 (fontified t face > org-table)) #("(0.0333434157791,0.000537930174356)" 0 35 (fontified t > face org-table)) #("(0.0345727512157,0.000559346040457)" 0 35 > (fontified t face org-table)) #("(0.0353146483908,0.000571501584524)" > 0 35 (fontified t face org-table)) > #("(0.0355522909393,0.000574387067408)" 0 35 (fontified t face > org-table)) #("(0.0356575682336,0.000574851263615)" 0 35 (fontified t > face org-table)) #("(0.0357806926897,0.000575051685084)" 0 35 > (fontified t face org-table)))) > $1-> '(sbe "parameter-variation" (data > #("(0.0331901438056,0.000535222885197)" 0 35 (fontified t face > org-table)) #("(0.0333434157791,0.000537930174356)" 0 35 (fontified t > face org-table)) #("(0.0345727512157,0.000559346040457)" 0 35 > (fontified t face org-table)) #("(0.0353146483908,0.000571501584524)" > 0 35 (fontified t face org-table)) > #("(0.0355522909393,0.000574387067408)" 0 35 (fontified t face > org-table)) #("(0.0356575682336,0.000574851263615)" 0 35 (fontified t > face org-table)) #("(0.0357806926897,0.000575051685084)" 0 35 > (fontified t face org-table)))) > Result: > Format: NONE > Final: > > > Thank you very much for your help. > > Renier > > --=20 Eric Schulte http://cs.unm.edu/~eschulte/