emacs-orgmode
[Top][All Lists]
Advanced

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

Re: [PATCH] ob-python results handling for dicts, dataframes, arrays, an


From: Jack Kamm
Subject: Re: [PATCH] ob-python results handling for dicts, dataframes, arrays, and plots
Date: Fri, 18 Aug 2023 16:18:23 -0700

Ihor Radchenko <yantar92@posteo.net> writes:

> This is an ORG-NEWS entry for Version 9.4. Is it an intentional change?

Sorry, that was an accident. I've reverted it now:
https://github.com/jackkamm/org-mode/commit/f12a695d67bc5c06013d9fbe0af844c9739e347a

>> @@ -142,7 +144,9 @@ (defun org-babel-python-table-or-string (results)
>>    "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."
>> -  (let ((res (org-babel-script-escape results)))
>> +  (let ((res (if (string-equal "{" (substring results 0 1))
>> +                 results ;don't covert dicts to elisp
>> +               (org-babel-script-escape results))))
>
> You may also need to update the docstring for
> `org-babel-python-table-or-string' after this change.

That change got reverted in subsequent update when I changed dict to
return as table by default instead of string. So there's no need to
update the docstring anymore.

>> -                                        body)))
>> -           (`value (let ((tmp-file (org-babel-temp-file "python-")))
>> +                                            (if graphics-file
>> +                                                (format 
>> org-babel-python--output-graphics-wrapper
>> +                                                        body graphics-file)
>> +                                              body))))
>> +           (`value (let ((results-file (or graphics-file
>> +                                       (org-babel-temp-file "python-"))))
>
> What about :results graphics file ?

Not entirely sure what you mean here.

When ":results graphics file", then graphics-file will be non-nil --
org-babel-execute:python passes graphics-file onto
org-babel-python-evaluate and then
org-babel-python-evaluate-external-process. In case of ":results
graphics file output", org-babel-python--output-graphics-wrapper is used
to save pyplot.gcf(). Or if ":results graphics file value", then
org-babel-python--def-format-value saves the result with
Figure.savefig().



reply via email to

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