ipynb icon indicating copy to clipboard operation
ipynb copied to clipboard

IndentationError: unexpected indent

Open xgdgsc opened this issue 8 years ago • 7 comments

When using import ipynb.fs.defs.myipynb, I get an error:

 File "<unknown>", line 81
    alpha_dict[key] = alpha_dict[key].ewm(span=20,adjust=True,min_periods=0,ignore_na=False).mean()
    ^
IndentationError: unexpected indent

The cell is:

for key in alpha_dict:
    alpha_dict[key] = alpha_dict[key].ewm(span=20,adjust=True,min_periods=0,ignore_na=False).mean()

I don' t know why would it try to import a for loop like this.

xgdgsc avatar Mar 15 '17 07:03 xgdgsc

I ran into a similar problem. In my case the cell above was markdown and the the last line in the cell was part of an indented list. The first line of the code cell started with 'def'

Adding an extra new line on the bottom of the markdown fixed the problem.

hard to believe its a parsing error given the implementation of ipynb uses the abstract syntax tree.

AEDWIP avatar Apr 14 '17 22:04 AEDWIP

I had a markdown cell with no trailing newline and the first line of the following cell wasn't being executed - looks like the same issue.

I was able to reproduce here: https://gist.github.com/alexlouden/4d8cae9643b9118e4c3c23d0b44e12d7

You can see that only Line2 is printed by notebook2

alexlouden avatar Oct 23 '17 06:10 alexlouden

I'm considering getting rid of the 'defs' feature completely, since I am unsure if we can ever implement it in a way that's consistent and safe in all cases...

Would you all be able to use the 'full' import without problems?

yuvipanda avatar Oct 23 '17 06:10 yuvipanda

I was actually using full - see my gist above (using the latest PyPi release - ipynb==0.4)

alexlouden avatar Oct 23 '17 06:10 alexlouden

Just tried version 0.5 from Github and looks like it's fixed - thanks!

Releasing it to PyPi would be great, if you can?

alexlouden avatar Oct 23 '17 06:10 alexlouden

I just released to pypi! Can you test?

On Sun, Oct 22, 2017 at 11:16 PM, Alex Louden [email protected] wrote:

Just tried version 0.5 from Github and looks like it's fixed - thanks!

Releasing it to PyPi https://github.com/ipython/ipynb/issues/26 would be great, if you can?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ipython/ipynb/issues/29#issuecomment-338557831, or mute the thread https://github.com/notifications/unsubscribe-auth/AAB23hSdXfnRyooMCPObQ3zLtJ_3i7QXks5svC8ygaJpZM4MdlsS .

-- Yuvi Panda T http://yuvi.in/blog

yuvipanda avatar Oct 23 '17 06:10 yuvipanda

It's working, thanks!

❯ pip install ipynb
Collecting ipynb
  Downloading ipynb-0.5.1-py3-none-any.whl
Installing collected packages: ipynb
Successfully installed ipynb-0.5.1

alexlouden avatar Oct 23 '17 06:10 alexlouden