emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* when does :cache not cache?
@ 2021-10-24 11:49 Emmanuel Charpentier
  2021-10-25 10:58 ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: Emmanuel Charpentier @ 2021-10-24 11:49 UTC (permalink / raw)
  To: e.fraga, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 1654 bytes --]

Workaround : cache the computations,not the plotting itself (which
should be fast,and must be made on every table, anyway...) :

#+options: toc:nil author:nil

* Main text

Use of a static table:

#+call: timeit()
#+call: testplot[:file test0.pdf](data=table0)
#+call: timeit()

Use of a slow function:

#+call: timeit()
#+call: testplot[:file test1.pdf](data=table1)
#+call: timeit()

Use of a /cached/ slow function:

#+call: timeit()
#+call: testplot[:file test2.pdf](data=table2)
#+call: timeit()

* Annexes :noexport:

This is not exported, but computes results.

#+name: timeit
#+begin_src emacs-lisp
  (format-time-string "%Hh %Mm %Ss")
#+end_src

#+name: table0
| Val | Square |
|-----+--------|
|   0 |      0 |
|   1 |      1 |
|   2 |      4 |
|   3 |      9 |
|   4 |     16 |
#+TBLFM: $2=$1^2

#+name: table1
#+begin_src emacs-lisp
  (sleep-for 5)
  (setq s ( list (list "x" "x^2") 'hline))
  (dotimes (i 5 s) (setq s (append s (list (cons i (list (* i i)))))))
  s
#+end_src

#+RESULTS[46320b31c46cef901580bad78aee7032d97ffe64]: table1
| x | x^2 |
|---+-----|
| 0 |   0 |
| 1 |   1 |
| 2 |   4 |
| 3 |   9 |
| 4 |  16 |


#+name: table2
#+begin_src emacs-lisp :cache yes
  (sleep-for 5)
  (setq s ( list (list "x" "x^2") 'hline))
  (dotimes (i 5 s) (setq s (append s (list (cons i (list (* i i)))))))
  s
#+end_src

#+name: tf
| festfile.pdf ]

#+RESULTS[46320b31c46cef901580bad78aee7032d97ffe64]: table2
| x | x^2 |
|---+-----|
| 0 |   0 |
| 1 |   1 |
| 2 |   4 |
| 3 |   9 |
| 4 |  16 |

#+name: testplot
#+begin_src gnuplot :var data=table0 :exports results
  reset
  plot data with linespoints
#+end_src

HTH,

--
Emmanuel Charpentier


[-- Attachment #2: Type: text/html, Size: 2727 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread
* when does :cache not cache?
@ 2021-10-23  9:13 Emmanuel Charpentier
  2021-10-23 10:09 ` Eric S Fraga
  0 siblings, 1 reply; 14+ messages in thread
From: Emmanuel Charpentier @ 2021-10-23  9:13 UTC (permalink / raw)
  To: e.fraga, emacs-orgmode

[-- Attachment #1: Type: text/plain, Size: 91 bytes --]

You may find this John Kitchin's blog post illuminating.

HTH,

--
Emmanuel Charpentier


[-- Attachment #2: Type: text/html, Size: 366 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread
* when does :cache not cache?
@ 2021-10-22  7:55 Eric S Fraga
  2021-12-12  7:45 ` Ihor Radchenko
  0 siblings, 1 reply; 14+ messages in thread
From: Eric S Fraga @ 2021-10-22  7:55 UTC (permalink / raw)
  To: Emacs Org mode mailing list

[-- Attachment #1: Type: text/plain, Size: 976 bytes --]

Hello all (again!),

in the paper I am writing, I have a number of gnuplot src blocks, some
of which process a significant amount of data so take some time to
generate the actual plots.  The data are static so caching the results
make sense.  However, even though I have ":cache yes" on each of these
named src blocks, and I have (for good measure), the property
"header-args:gnuplot" set to ":cache yes" as well, the plots are being
regenerated each time I export to PDF via LaTeX.

In trying to create a minimal example (see attached), it seems that
caching stops working as soon as I add a ":var data=..." header argument
to generate a plot from a table of data.

Why does specifying a variable to a src block violate the caching
directive?  Is this intended behaviour (assuming I've understood what is
happening correctly)?

Thank you,
eric

-- 
: Eric S Fraga via Emacs 28.0.60, Org release_9.5-163-g4eab5b
: Latest paper written in org: https://arxiv.org/abs/2106.05096

[-- Attachment #2: gnuplot.org --]
[-- Type: application/vnd.lotus-organizer, Size: 618 bytes --]

^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2022-07-08 15:48 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-24 11:49 when does :cache not cache? Emmanuel Charpentier
2021-10-25 10:58 ` Eric S Fraga
  -- strict thread matches above, loose matches on Subject: below --
2021-10-23  9:13 Emmanuel Charpentier
2021-10-23 10:09 ` Eric S Fraga
2021-10-23 15:15   ` Eric S Fraga
2021-10-22  7:55 Eric S Fraga
2021-12-12  7:45 ` Ihor Radchenko
2021-12-13  8:13   ` Eric S Fraga
2022-06-09 13:35     ` Ihor Radchenko
2022-06-09 13:41       ` Fraga, Eric
2022-07-04 13:06   ` Ihor Radchenko
2022-07-08 14:59     ` Fraga, Eric
2022-07-08 15:08       ` Ihor Radchenko
2022-07-08 15:19       ` Fraga, Eric

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).