Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-13 Thread Jack Kamm
Ihor Radchenko writes: > We may instead arrange org-lint and possibly ob-core to throw a > warning when an src block uses confusing setting combinations. > Without changing the underlying behaviour. > Basically, discourage using confusing staff. > ... > We should update the docs to avoid such exa

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-12 Thread Ihor Radchenko
Jack Kamm writes: > Ihor Radchenko writes: > >> ":results file" imply that results of the code block are written to a file >> (the file is specified using header args). >> >> ":results file link" imply that results of the code block are interpreted >> as file link. The fact that presence of :fil

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-11 Thread Jack Kamm
Ihor Radchenko writes: > ":results file" imply that results of the code block are written to a file > (the file is specified using header args). > > ":results file link" imply that results of the code block are interpreted > as file link. The fact that presence of :file header arg overrides this

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-09 Thread Ihor Radchenko
Jack Kamm writes: > Ihor Radchenko writes: > >> Your patch appear to only add more confusion, IMHO. >> >> I feel that the description about :results file is confusing from the >> very beginning: > > Well, I guess ":results file" has confusing behavior. So it's > difficult to write accurate, comp

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-08 Thread Jack Kamm
Liu Hui writes: > I think your proposal about ":results graphics" is more flexible and > complies the documentation. Since the patch has no real problem and > the feature is useful indeed, I hope it can be merged instead of mine > after the problem of documentation is resolved. Thanks for your g

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-08 Thread Jack Kamm
Ihor Radchenko writes: > Your patch appear to only add more confusion, IMHO. > > I feel that the description about :results file is confusing from the > very beginning: Well, I guess ":results file" has confusing behavior. So it's difficult to write accurate, comprehensive, non-confusing documen

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-07 Thread Ihor Radchenko
Jack Kamm writes: > ":results graphics file" is used this way in ob-R and ob-julia, and also > in the testing files test-ob-octave.el and ob-maxima-test.org. > > ":results graphics" just means that the result from > org-babel-execute:lang isn't written to the file by > org-babel-execute-src-block

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-07 Thread Ihor Radchenko
Jack Kamm writes: > In fact, :results file also works this way for other Babel languages. > And I used this behavior before for plotting with ob-reticulate blocks. > > I attach a patch to fix the documentation in the manual about this. Your patch appear to only add more confusion, IMHO. I feel

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-06 Thread Liu Hui
Jack Kamm 于2023年7月6日周四 11:49写道: > I would propose the following instead: for ":results output graphics", > ob-python should plot the gcf, and clear it beforehand. But for > ":results value graphics", the ob-python block should return a > matplotlib Figure object to plot, which would allow keeping

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Jack Kamm
Liu Hui writes: > I don't think so. Some users may want to keep the figure between > blocks, and they can always clear the figure themselves when > necessary. I'd rather not have to call pyplot.gcf().clear() every time, it doesn't seem nice. ob-R doesn't require manually clearing the plot, and

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Jack Kamm
Ihor Radchenko writes: > Jack Kamm writes: > >> I think the Worg documentation is accurately describing the behavior of >> ob-python -- it's just that ob-python uses ":results file" in a >> nonstandard way. > > May you please point me to the place in ob-python where :results file is > specially

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Ihor Radchenko
Jack Kamm writes: > I think the Worg documentation is accurately describing the behavior of > ob-python -- it's just that ob-python uses ":results file" in a > nonstandard way. May you please point me to the place in ob-python where :results file is specially treated? -- Ihor Radchenko // yant

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Liu Hui
Jack Kamm 于2023年7月5日周三 13:13写道: > 1. Do you need to add a call to pyplot.gcf().clear(), in case of > multiple blocks in a session? I don't think so. Some users may want to keep the figure between blocks, and they can always clear the figure themselves when necessary. > 2. Would it make sense to

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-05 Thread Liu Hui
Ihor Radchenko 于2023年7月4日周二 19:29写道: > That said, your patch should still work fine even with these > considerations. But we may need to sort out this undocumented behaviour. > Probably, an error like in `org-babel-graphical-output-file' should be > thrown by `org-babel-generate-file-param'. Yes

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-04 Thread Jack Kamm
Ihor Radchenko writes: > WORG documentation is not accurate here. > > If the block has :file parameter _or_ :file-exp parameter and #+name, > the results of evaluation are inserted into a file. Otherwise, results > of evaluation are interpreted as file name--*undocumented*. > > That said, your pa

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-04 Thread Jack Kamm
Liu Hui writes: > Hi, > > This patch adds graphics output support for ob-python via matplotlib. > Specifically, it allows to use header argument `:results file > graphics' as follows: > > #+begin_src python :file "test.png" :results graphics file > import matplotlib.pyplot as plt > plt.plot([1,2,

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-04 Thread Jack Kamm
Ihor Radchenko writes: > Liu Hui writes: > >> This patch adds graphics output support for ob-python via matplotlib. >> Specifically, it allows to use header argument `:results file >> graphics' as follows: >> >> #+begin_src python :file "test.png" :results graphics file >> import matplotlib.pypl

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-04 Thread Ihor Radchenko
[ CCing ob-python maintainer. ] Liu Hui writes: >> May you elaborate? >> >> #+begin_src python :results file >> implies that the result of execution is file _contents_. > > It is consistent with current behavior, e.g. `:results file' is used > to produce graphics file > https://orgmode.org/worg/

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
Ihor Radchenko 于2023年7月3日周一 19:41写道: > This already works, even without the patch. Yes. It means the patch doesn't break current usage. > > In this case, `graphics' can be removed too. > > May you elaborate? > > #+begin_src python :results file > implies that the result of execution is file _co

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Ihor Radchenko
Liu Hui writes: > I have updated the patch and ‘:file’ header argument can be omitted > now, e.g. > > #+begin_src python :results graphics file > import matplotlib.pyplot as plt > plt.plot([1,2,3,4,5]) > plt.savefig('test.png') > return 'test.png' > #+end_src This already works, even without the

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Liu Hui
Ihor Radchenko 于2023年7月3日周一 17:28写道: > This might be a useful feature, but it will break the existing > conventions, if used as in the patch. Currently, the above combination > of :file and :results is treated as the following: > > ‘graphics’ > When used along with ‘file’ type, the result is

Re: [PATCH] ob-python: support header argument `:results file graphics'

2023-07-03 Thread Ihor Radchenko
Liu Hui writes: > This patch adds graphics output support for ob-python via matplotlib. > Specifically, it allows to use header argument `:results file > graphics' as follows: > > #+begin_src python :file "test.png" :results graphics file > import matplotlib.pyplot as plt > plt.plot([1,2,3,4,5])