emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [O] [babel] Problems assigning tables as variables using #+CALL and


From: Eric Schulte
Subject: Re: [O] [babel] Problems assigning tables as variables using #+CALL and using properties in code blocks and sbe calls
Date: Thu, 18 Jul 2013 19:06:24 -0600
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux)

Torsten Wagner <address@hidden> writes:

> Hi,
> I have a tables like this:
>
> #+TBLNAME: tablename
> | a | b |c | d |
> | 1 | 2 |3  |4 |
> | z | x | y |w|
>
> #+TBLNAME: othertablename
> | a | b |c | d |
> | 1 | 2 |3  |4 |
> | z | x | y |w|
>
> I have the following code block
>
> #+name: test
> #+begin_src python :var table=tablename :exports results
> import numpy as np
> tab = np.array(table)
> return np.array([tab[:,1], tab[:,-1]]).T
> #+end_src
>
> If I call that function the result is correct
>
> However using
>
> #+CALL: aushang[:var table=othertablename]() :exports results
> or
> #+CALL: aushang(table=othertablename) :exports results
>
> does not work. It seem the babel block does not get the table but something
> else in case its called by #+CALL:.
> In general, how-to refer to a table in #+CALL blocks?
>

Your tables are identical, and you're not calling the test function in
your call blocks.  A more reasonable (to me) version of your example
works as expected.

#+TBLNAME: tablename
| a | b | c | d |
| 1 | 2 | 3 | 4 |
| z | x | y | w |

#+TBLNAME: othertablename
| a | b | c | d |
| 4 | 3 | 2 | 1 |
| z | x | y | w |

I have the following code block

#+name: test
#+begin_src python :var table=tablename :exports results
  import numpy as np
  tab = np.array(table)
  return np.array([tab[:,1], tab[:,-1]]).T
#+end_src

#+RESULTS: test
| b | d |
| 2 | 4 |
| x | w |

If I call that function the result is correct

However using

#+CALL: test[:var table=othertablename]() :exports results

#+RESULTS:
| b | d |
| 3 | 1 |
| x | w |

#+CALL: test(table=othertablename) :exports results

#+RESULTS:
| b | d |
| 3 | 1 |
| x | w |

>
> On a similar line: I used $PROP_name to use property values within the
> sbe function.  However, how to use the same property as input to a
> code-block?
>
> +begin_src python :var x=$PROP_name :exports results
> and
> +begin_src python :var x=name :exports results
>
> did not work
>
> Any ideas?
>

I don't understand the later part of this email, perhaps an example
would clarify.  Also, it might be worth looking in the following to see
if something matching your use case appears.

  http://eschulte.github.io/org-scraps/

Cheers,

>
> Thanks
>
> Torsten

-- 
Eric Schulte
http://cs.unm.edu/~eschulte

reply via email to

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