emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typ


From: Nick Dokos
Subject: Re: [O] Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table
Date: Mon, 29 Aug 2011 05:05:20 -0400

Major A <address@hidden> wrote:

> 
> Hi,
> 
> I'd like to use asymptote to plot the values in an Org table.  The table
> has cells with numbers but also cells with strings in them.  This table
> gets converted to an array of strings in the resulting asymptote file,
> with the strings escaped with double-quotes but not the numbers.  In
> asymptote, this is an error, so that no plot is produced.
> 
> Here's the code:
> 
>   #+data: values
>   | 0 | 0 | a |
>   | 1 | 1 | b |
>   | 2 | 3 | c |
>  =20
>   #+begin_src asymptote :file asy.png :var v=3Dvalues
>     size(100);
>     draw((0,0)--(1,1));
>   #+end_src
> 
> The temporary asymptote file created during evaluation or export looks
> like this:
> 
>   string[][] v=3D{
>   {0,0,"a"},
>   {1,1,"b"},
>   {2,3,"c"}
>   };
> 
> "asy" complains about this file like this:
> 
>   asymptote-12652XAo: 2.2: cannot cast 'int' to 'string'
>   asymptote-12652XAo: 2.4: cannot cast 'int' to 'string'
>   asymptote-12652XAo: 3.2: cannot cast 'int' to 'string'
>   asymptote-12652XAo: 3.4: cannot cast 'int' to 'string'
>   asymptote-12652XAo: 4.2: cannot cast 'int' to 'string'
>   asymptote-12652XAo: 4.4: cannot cast 'int' to 'string'
> 
> Am I doing something wrong here?
> 

I don't know anything about asymptote and I am not sure whether this
will help: it does produce a temp file with everything quoted and
running asy on the temp file produces an .eps file that contains the
diagonal line, but it produces a png file which seems somewhat peculiar
to me but maybe it'll work for you.

You have to do

(setq org-babel-min-lines-for-block-output 0)

in order to get the example block result.

I just added a python block to produce another table with everything
quoted.  The second table is then give to asymptote:

--8<---------------cut here---------------start------------->8---
#+data: values
| 0 | 0 | a |
| 1 | 1 | b |
| 2 | 3 | c |

#+begin_src python :results output :var table=values
  print "#+data: qvalues"
  for row in table:
      print "|%s|" % ("|".join(map(lambda x: "\"%s\"" % (x), row)))
  
#+end_src

#+results:
#+begin_example
#+data: qvalues
|"0"|"0"|"a"|
|"1"|"1"|"b"|
|"2"|"3"|"c"|
#+end_example

#+begin_src asymptote :file asy.png :var v=qvalues
   size(100);
   draw((0,0)--(1,1));

#+end_src

#+results:
[[file:asy.png]]
--8<---------------cut here---------------end--------------->8---


The temp file looks like this:


--8<---------------cut here---------------start------------->8---
string[][] v={
{"0","0","a"},
{"1","1","b"},
{"2","3","c"}
};
size(100);
draw((0,0)--(1,1));
--8<---------------cut here---------------end--------------->8---

I attach the asy.png file I get.

Nick

Attachment: asy.png
Description: asy.png


reply via email to

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