* Unable to reuse the result of a cached function call as argument of a gnuplot call
@ 2015-06-10 18:30 bernardH
2015-07-04 13:09 ` Nicolas Goaziou
0 siblings, 1 reply; 2+ messages in thread
From: bernardH @ 2015-06-10 18:30 UTC (permalink / raw
To: emacs-orgmode
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: Unable to reuse the result of a cached function call as argument of a gnuplot call
2015-06-10 18:30 Unable to reuse the result of a cached function call as argument of a gnuplot call bernardH
@ 2015-07-04 13:09 ` Nicolas Goaziou
0 siblings, 0 replies; 2+ messages in thread
From: Nicolas Goaziou @ 2015-07-04 13:09 UTC (permalink / raw
To: bernardH; +Cc: emacs-orgmode
Hello,
bernardH <org-mode@bernard-hugueney.org> writes:
> 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 |
[...]
> 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
Why can't you simply use the (cached) results of my-call instead of the
call itself, e.g.:
#+name: my-call-cached
#+call: fun[:results table](nb=5) :cache yes
#+name: my-cached-results
#+RESULTS[f2b650eb5296f72a1f7237c2a65b7fb3443acf5f]: my-call-cached
| 1 | 2 |
| 3 | 4 |
| 5 | 6 |
| 7 | 8 |
| 9 | 10 |
#+name: plot-result-cached
#+call: plotting[:file result-call-cached.png](data= my-cached-results) :results file
Regards,
--
Nicolas Goaziou
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-07-04 13:07 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-10 18:30 Unable to reuse the result of a cached function call as argument of a gnuplot call bernardH
2015-07-04 13:09 ` Nicolas Goaziou
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.