emacs-orgmode
[Top][All Lists]
Advanced

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

[O] Unable to reuse the result of a cached function call as argument of


From: bernardH
Subject: [O] Unable to reuse the result of a cached function call as argument of a gnuplot call
Date: Wed, 10 Jun 2015 18:30:22 +0000 (UTC)
User-agent: Loom/3.14 (http://gmane.org/)

Hi all !
First, I would like to thank the org-mode community for the great fun I'm
having with babel. Unfortunately, I'm currently stumped by what appears to
be a bug (or unhandled corner-case).
Here is a org-mode style write-up to describe the problem :

* Versions
#+BEGIN_SRC elisp
(org-version)
#+END_SRC

#+RESULTS:
: 8.3beta

#+BEGIN_SRC elisp
(emacs-version)
#+END_SRC

#+RESULTS:
: GNU Emacs 24.3.50.1 (x86_64-pc-linux-gnu, GTK+ Version 3.8.6)
:  of 2014-01-01 on prometheus, modified by Debian

* Minimal (!) example

Defining a function, I'll want to use the result of a _cached_ call as
an arg to a a gnuplot function.

#+name: fun
#+BEGIN_SRC sh :var nb="10" :results output
seq $(( ${nb} * 2 )) | paste - -
#+END_SRC

First a regular call, to show that I'll be able to reuse the result of
this call.
#+name: my-call
#+call: fun[:results table](nb=5)

#+RESULTS: my-call
| 1 |  2 |
| 3 |  4 |
| 5 |  6 |
| 7 |  8 |
| 9 | 10 |


Now a cached call.

#+name: my-call-cached
#+call: fun[:results table](nb=5) :cache yes 

#+RESULTS[f2b650eb5296f72a1f7237c2a65b7fb3443acf5f]: my-call-cached
| 1 |  2 |
| 3 |  4 |
| 5 |  6 |
| 7 |  8 |
| 9 | 10 |


Dummy data that I only use as default value for the gnuplot function
definition.
#+name:dummy-data
| 1 |  2 |

#+name: plotting
#+begin_src gnuplot :var data=dummy-data my_title="dummy title" :file dummy.png
  set title my_title
  plot data
#+end_src

#+RESULTS: plotting
[[file:dummy.png]]

I can call the gnuplot function on the result of the uncached call :

#+name: plot-result
#+call: plotting[:file result-call.png](data= my-call) :results file

#+RESULTS: plot-result
[[file:result-call.png]]

#+BEGIN_SRC sh :results output
file result-call.png
#+END_SRC

#+RESULTS:
: result-call.png: PNG image data, 640 x 480, 8-bit colormap, non-interlaced


But if I try to use the cached call :

#+name: plot-result-cached
#+call: plotting[:file result-call-cached.png](data= my-call-cached)
:results file

#+RESULTS: plot-result-cached
[[file:result-call-cached.png]]

#+BEGIN_SRC sh
file result-call-cached.png
#+END_SRC

#+RESULTS:
: result-call-cached.png: empty

* gnuplot console
Working gnuplot invocation had :
#+BEGIN_EXAMPLE
gnuplot>  data = "/tmp/babel-262957O1/gnuplot-26295F9G"
#+END_EXAMPLE


Failed invocation on result of a cached call had :
#+BEGIN_EXAMPLE
gnuplot> data = "((1 2) (3 4) (5 6) (7 8) (9 10))"
gnuplot> set term png
Terminal type set to 'png'
Options are 'nocrop font
"/usr/share/fonts/truetype/liberation/LiberationSans-Regular.ttf,12"
fontscale 1.0 size 640,480 '
gnuplot> set output "result-call-cached.png"
gnuplot> set title my_title
gnuplot> plot data
         warning: Skipping unreadable file "((1 2) (3 4) (5 6) (7 8) (9 10))"
         No data in plot

#+END_EXAMPLE

* References

[[https://lists.gnu.org/archive/html/emacs-orgmode/2010-10/msg01379.html][message
on arg passing to gnuplot]]

[[http://emacs.stackexchange.com/a/12690/8545][stackexchange answer pointing
to the implementation of the results of named function calls as arguments]]


Thank you very much if a fix is possible (I really need to cache the very
expensive function calls of my real use-case, but I should be able to make a
cheap uncached identity function before the gnuplot invocation as a workaround).

Best Regards,

Bernard






reply via email to

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