From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Bug: Babel: asymptote: erroneous conversion of heterogeneous-typed table Date: Mon, 29 Aug 2011 05:05:20 -0400 Message-ID: <26064.1314608720@alphaville.dokosmarshall.org> References: <20110829080003.GA12790@discus> Reply-To: nicholas.dokos@hp.com Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([140.186.70.92]:39215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxxmW-0000bt-95 for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 05:05:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QxxmV-0000P9-BZ for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 05:05:24 -0400 Received: from g4t0017.houston.hp.com ([15.201.24.20]:47630 helo=g1u1820.austin.hp.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QxxmV-0000P5-6Q for emacs-orgmode@gnu.org; Mon, 29 Aug 2011 05:05:23 -0400 In-Reply-To: Message from Major A of "Mon\, 29 Aug 2011 10\:00\:05 +0200." <20110829080003.GA12790@discus> 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: Major A Cc: nicholas.dokos@hp.com, emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Major A 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 --=-=-= Content-Type: image/png Content-Disposition: attachment; filename=asy.png Content-Transfer-Encoding: base64 Content-Description: asy.png iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABmJLR0QA/wD/AP+gvaeTAAAACXBI WXMAAAsSAAALEgHS3X78AAAAHXRFWHRTb2Z0d2FyZQBHUEwgR2hvc3RzY3JpcHQgOC43MQM/aDQA AAIfSURBVHic7dHZTQQxEADRGjIgW0IgBaIkhOEDCVj2msN2t+2qCEp6y7quWHzLsrwC7y/RI/aL AbwJEtxfjHVdPwUJ7D8GgCBB3cIAQUK6hwGCNO8RBgjStGcYIEiztmCAIE3aigGCVG8PBghStb0Y IEi1jmCAIFU6igGCFO8MBghStLMYIEixSmCAIEUqhQGCnK4kBghyqtIYIMjhamCAIIeqhQGC7K4m Bgiyq9oYIMjmWmCAIJtqhQGCPK0lBgjysNYYIMjdIjBAkJtFYYAgV0VigCAXRWOAID9lwABBgDwY IEgqDJgcJBsGTAySEQMmBcmKAROCZMaAyUCyY8BEID1gwCQgvWDABCA9YcDgIL1hwMAgPWLAoCC9 YsCAID1jwGAgvWPAQCAjYMAgIKNgwAAgI2FA5yCjYUDHICNiQKcgo2JAhyAjY0BnIKNjQEcgM2BA JyCzYEAHIDNhQHKQ2TAgMciMGJAUZFYMSAgyMwYkA5kdAxKBiPFdChAxfgsHEeOyUBAxrgsDEeN2 ISBi3K85iBiPawoixvOagYixrSYgYmyvOogY+6oKIsb+qoGIcawqIGIcrziIGOcqCiLG+YqBiFGm IiBilOs0iBhlOwUiRvkOg4hRp0MgYtRrN4gYddsFIkb9NoOI0aZNIGK06ymIGG17CCJG++6CiBHT TRAx4roCESO2CxAx4vsBESNHLyBGphZAjEQtwAdipOkLe4TvfDZ/5Y0AAAAASUVORK5CYII= --=-=-=--