emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Eric Schulte <schulte.eric@gmail.com>
To: Torsten Wagner <torsten.wagner@gmail.com>
Cc: Org Mode Mailing List <emacs-orgmode@gnu.org>
Subject: Re: [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	[thread overview]
Message-ID: <871u6ve4tr.fsf@gmail.com> (raw)
In-Reply-To: <CAPaq-gNyv=JtKvkwi-YCB0w+-2AAyE0Mr6qZo-P2ZEZa8ORj5Q@mail.gmail.com> (Torsten Wagner's message of "Fri, 19 Jul 2013 02:34:20 +0200")

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

Torsten Wagner <torsten.wagner@gmail.com> 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.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: table-call.org --]
[-- Type: text/x-org, Size: 665 bytes --]

#+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 |


[-- Attachment #3: Type: text/plain, Size: 611 bytes --]


>
> 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	other threads:[~2013-07-19  1:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-19  0:34 [babel] Problems assigning tables as variables using #+CALL and using properties in code blocks and sbe calls Torsten Wagner
2013-07-19  1:06 ` Eric Schulte [this message]
2013-07-19 11:06   ` Torsten Wagner
2013-07-19 15:57     ` Torsten Wagner
2013-07-19 17:56       ` Rick Frankel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871u6ve4tr.fsf@gmail.com \
    --to=schulte.eric@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=torsten.wagner@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).