emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug: python babel does not support hlines as mentioned in docs [7.9.2 (release_7.9.2-499-ga29de0 @ /home/lennart/.emacs.d/site-lisp/org/lisp/)]
@ 2012-10-29 17:11 Lennart Fricke
  2012-10-29 17:44 ` Bug: python babel does not support hlines as mentioned in docs Lennart Fricke
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Fricke @ 2012-10-29 17:11 UTC (permalink / raw)
  To: emacs-orgmode

Hello,

The following block exits with error:
orgtbl-format-line: Wrong type argument: sequencep, None

#+TBLNAME: many-cols
| a | b | c |
|---+---+---|
| d | e | f |
|---+---+---|
| g | h | i |
          
#+NAME: echo-table
#+BEGIN_SRC python :var tab=many-cols :hlines yes
 return tab
#+END_SRC

I bisected it down to commit b174975eb7a828d77816a9bf8107fc1a3ae597d7 .
There the special handling of None in a python list was deleted.

Could that be added back? Is it desired? If not, it would be great, if
you change the example in the docs of hlines header argument.

Thank you and best regards
Lennart Fricke

Emacs  : GNU Emacs 24.1.1 (i686-redhat-linux-gnu, GTK+ Version 2.24.11)
 of 2012-08-13 on buildvm-23.phx2.fedoraproject.org
Package: Org-mode version 7.9.2 (release_7.9.2-499-ga29de0 @ /home/lennart/.emacs.d/site-lisp/org/lisp/)

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

* Re: Bug: python babel does not support hlines as mentioned in docs
  2012-10-29 17:11 Bug: python babel does not support hlines as mentioned in docs [7.9.2 (release_7.9.2-499-ga29de0 @ /home/lennart/.emacs.d/site-lisp/org/lisp/)] Lennart Fricke
@ 2012-10-29 17:44 ` Lennart Fricke
  2012-10-30 16:50   ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Fricke @ 2012-10-29 17:44 UTC (permalink / raw)
  To: emacs-orgmode

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

This patch makes None being treated as hline again.

Best regards
Lennart Fricke


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: python-hlines.patch --]
[-- Type: text/x-patch, Size: 629 bytes --]

diff --git a/lisp/ob-python.el b/lisp/ob-python.el
index 71adf73..a1f834f 100644
--- a/lisp/ob-python.el
+++ b/lisp/ob-python.el
@@ -123,7 +123,11 @@ specifying a variable of the same value."
   "Convert RESULTS into an appropriate elisp value.
 If the results look like a list or tuple, then convert them into an
 Emacs-lisp table, otherwise return the results as a string."
-  (org-babel-script-escape results))
+  ((lambda (res)
+     (if (listp res)
+	 (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res)
+       res))
+   (org-babel-script-escape results)))
 
 (defvar org-babel-python-buffers '((:default . nil)))
 

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

* Re: Bug: python babel does not support hlines as mentioned in docs
  2012-10-29 17:44 ` Bug: python babel does not support hlines as mentioned in docs Lennart Fricke
@ 2012-10-30 16:50   ` Eric Schulte
  2012-10-30 18:03     ` Lennart Fricke
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Schulte @ 2012-10-30 16:50 UTC (permalink / raw)
  To: Lennart Fricke; +Cc: emacs-orgmode

Perhaps it would be better to provide two customization variables, e.g.,

    ;; -*- emacs-lisp -*-
    (defcustom org-babel-python-hline-to "None"
      "Replace hlines in incoming tables with this when translating to python.")

    (defcustom org-babel-python-None-to "'hline"
      "Replace 'None' in python tables with this before returning.")

That way users may exercise control over this translation process.  I
know with R tables it is often desirable to replace missing values with
"" or 0.

Cheers,

Lennart Fricke <pge08aqw@studserv.uni-leipzig.de> writes:

> This patch makes None being treated as hline again.
>
> Best regards
> Lennart Fricke
>
> diff --git a/lisp/ob-python.el b/lisp/ob-python.el
> index 71adf73..a1f834f 100644
> --- a/lisp/ob-python.el
> +++ b/lisp/ob-python.el
> @@ -123,7 +123,11 @@ specifying a variable of the same value."
>    "Convert RESULTS into an appropriate elisp value.
>  If the results look like a list or tuple, then convert them into an
>  Emacs-lisp table, otherwise return the results as a string."
> -  (org-babel-script-escape results))
> +  ((lambda (res)
> +     (if (listp res)
> +	 (mapcar (lambda (el) (if (equal el 'None) 'hline el)) res)
> +       res))
> +   (org-babel-script-escape results)))
>  
>  (defvar org-babel-python-buffers '((:default . nil)))
>  

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

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

* Re: Bug: python babel does not support hlines as mentioned in docs
  2012-10-30 16:50   ` Eric Schulte
@ 2012-10-30 18:03     ` Lennart Fricke
  2012-10-31  0:07       ` Eric Schulte
  0 siblings, 1 reply; 5+ messages in thread
From: Lennart Fricke @ 2012-10-30 18:03 UTC (permalink / raw)
  To: Eric Schulte; +Cc: emacs-orgmode

It is not exactly a missing value. The list looks like 
((v,v),None,(v,v)). v for value.
Missing values are rather like ((v,v),(None,None),(v,v)).
At the moment i can not think of a use case of controlling this translation.
But i have to dig deeper in the translation process of the nested list 
to the org-table, to get a clear picture.
For example i don't know what happens to lists with diffrent number of 
elements like ((v,v,v),v,(v,v)).

Semantics for missing values etc. might be better handled in the python 
code and translated there.
But customizing the object hline is mapped from and to is a good idea.

Best regards
Lennart

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

* Re: Bug: python babel does not support hlines as mentioned in docs
  2012-10-30 18:03     ` Lennart Fricke
@ 2012-10-31  0:07       ` Eric Schulte
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Schulte @ 2012-10-31  0:07 UTC (permalink / raw)
  To: Lennart Fricke; +Cc: emacs-orgmode

Lennart Fricke <pge08aqw@studserv.uni-leipzig.de> writes:

> It is not exactly a missing value. The list looks like
> ((v,v),None,(v,v)). v for value.
> Missing values are rather like ((v,v),(None,None),(v,v)).
> At the moment i can not think of a use case of controlling this translation.
> But i have to dig deeper in the translation process of the nested list
> to the org-table, to get a clear picture.
> For example i don't know what happens to lists with diffrent number of
> elements like ((v,v,v),v,(v,v)).
>
> Semantics for missing values etc. might be better handled in the
> python code and translated there.
> But customizing the object hline is mapped from and to is a good idea.
>

Great, I've just pushed up a commit implementing this behavior.

>
> Best regards
> Lennart
>

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

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

end of thread, other threads:[~2012-10-31  0:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-29 17:11 Bug: python babel does not support hlines as mentioned in docs [7.9.2 (release_7.9.2-499-ga29de0 @ /home/lennart/.emacs.d/site-lisp/org/lisp/)] Lennart Fricke
2012-10-29 17:44 ` Bug: python babel does not support hlines as mentioned in docs Lennart Fricke
2012-10-30 16:50   ` Eric Schulte
2012-10-30 18:03     ` Lennart Fricke
2012-10-31  0:07       ` Eric Schulte

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).