Re: [O] Bug: python babel does not support hlines as mentioned in docs
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 pge08...@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
Re: [O] Bug: python babel does not support hlines as mentioned in docs
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
Re: [O] Bug: python babel does not support hlines as mentioned in docs
Lennart Fricke pge08...@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
[O] 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/)]
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/)
Re: [O] Bug: python babel does not support hlines as mentioned in docs
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)))