Open IndianBoy42 opened 2 years ago
same issue
A rough workaround is evoke function of vim-ipython-cell:
function! PrevExecNextCell()
call IPythonCellPrevCell()
call jupyter_ascending#execute()
call IPythonCellNextCell()
endfunction
nmap <leader><CR> :call PrevExecNextCell()<CR>
hope someone have a more elegant solution
hope someone have a more elegant solution
@fecet @IndianBoy42
After taking a look at the code, it appears to be an issue with the assumptions for how the file starts: https://github.com/untitled-ai/jupyter_ascending/blob/main/jupyter_ascending/requests/execute.py#L20
I don't know enough about jupytext
as this is my first time trying to use it, but I assume you need the header at the top for it to work correctly, so you just need to remove the very first # %%
in order to trigger the second specified case.
This worked for me, hopefully it does for you as well.
Cheers
@jvivian this solutions works! Thanks for the this workaround :)
So if i'm understanding right, not having the first cell marker on the first line should make it work?
But my notebook files are generally created by jupytext which does add a leading cell marker, so could it be fixed in jupyter_ascending?
So if i'm understanding right, not having the first cell marker on the first line should make it work?
I used the jupyter_ascending.scripts.make_pairs
function to generate the .py/ipynb pairs, which puts a jupytext
header at the top. If you remove the first # %%
below the header (---
), it should work. Example below
(base) jvivian@DESKTOP-8U6S9I6:~/Dropbox/Learning/Statistics/Bayesian-modeling-and-computation$ head Notebooks/03_Linear_models.sync.py -n 20
# ---
# jupyter:
# jupytext:
# text_representation:
# extension: .py
# format_name: percent
# format_version: '1.3'
# jupytext_version: 1.3.4
# kernelspec:
# display_name: Python 3
# language: python
# name: python3
# ---
import pandas as pd
# %%
print('hello world')
This was maybe hopefully fixed in the most recent update of the jupyter_ascending
plugin - there was a numbering bug. If anyone happens to be able to confirm or deny, lmk!
Putting my cursor on
import
and hitting<localleader>j
will cause the second cell to execute. What could be the problem?