Skip to content

DOC: Building notebooks fails with some ipython version #2813

Closed

Description

@ChadFulton

The nbgenerate script no longer works well, and should in any case probably be at least partly replaced because the newer versions of ipython nbconvert work pretty well; e.g.

ipython nbconvert --to rst --execute *.ipynb

Activity

  1. josef-pkt commented on Feb 13, 2016

    @josef-pkt
    Member

    I didn't know about the --execute option. I was recently trying out runipy another wrapper program on top of it, that also seems to work fine.

    Currently we generate html instead of rst and embed it as html in the rst file.

    Also it doesn't work on python 3. #2312
    Another issue: which format #2530

  2. josef-pkt commented on Feb 14, 2016

    @josef-pkt
    Member

    I need additional --allow-errors to get over cells that raise exceptions

    However, format 4 seems to hardcode the python version.
    I get a keyerror python2 and nbconvert stops with an exception.
    (I'm using python 3.4 and I think I don't have a python 2 on the system path.)
    It looks like we might have to get rid of the python version specific "kernelspec"
    ???

    I didn't figure out yet how to stop raising an exception on timeout, which happened, AFAICS, in one of the notebooks (on cold start)

    Also: I recently looked at sphinx extension for notebook conversion, like http://nbsphinx.readthedocs.org/en/0.2.4/index.html
    but I have no idea how reliable they already are.

  3. TomAugspurger commented on Feb 15, 2016

    @TomAugspurger
    Contributor

    Quick update, I've got all the notebooks converted to version 4, and a new version of nbgenerate that uses nbconvert. It optionally executes the notebooks as well.

    Tonight or maybe tomorrow I'll finish fixing the notebooks so that they're all running. The only real bug I've seen so far (not simple things like py3 compat) is this one in discrete_choice_overview.ipynb

    margeff = logit_res.get_margeff()
    print(margeff.summary())

    which gives

    ---------------------------------------------------------------------------
    TypeError                                 Traceback (most recent call last)
    <ipython-input-7-f2053e93ff07> in <module>()
          1 margeff = logit_res.get_margeff()
    ----> 2 print(margeff.summary())
    
    /Users/tom.augspurger/Envs/dev/lib/python3.4/site-packages/statsmodels/statsmodels/discrete/discrete_margins.py in summary(self, alpha)
        520         _, const_idx = _get_const_index(model.exog)
        521         if const_idx is not None:
    --> 522             exog_names.pop(const_idx)
        523 
        524         J = int(getattr(model, "J", 1))
    
    TypeError: only integer scalar arrays can be converted to a scalar index

    I am using numpy-dev. I can open an issue if this isn't already known.

    EDIT: Oh, nbsphinx worked ok. I couldn't get the Tables of Contents to work correctly (I think a bug on there end, haven't looked), and it needs a better way to pass options to the notebook executor rather than editing the notebook metadata itself. I'd say hold of on using that for now.

  4. TomAugspurger commented on Feb 15, 2016

    @TomAugspurger
    Contributor

    However, format 4 seems to hardcode the python version.

    This is a parameter to the nbconvert.preprocess.PreprocessExectutor, the thing that actually runs the notebook. By default it grabs that from the notebook metadata, but it can be overridden.

    I didn't figure out yet how to stop raising an exception on timeout

    Also a parameter. I had some issues with some plots timing out regardless of the timeout I set. I think the plotting may have blocked the event loop. Including a %matplotlib inline fixed that.

  5. josef-pkt commented on Feb 15, 2016

    @josef-pkt
    Member

    @TomAugspurger Thanks for all this work. Sounds very good.

    You can also put it then in a PR or somewhere so I can also try.
    (Reminder: Don't commit output in notebooks. We don't want to load the repo with temporary print and plots.)

    I'll look at the get_margeff error. It looks like we don't have a unit test for summary (which have smoke tests only so far)

  6. TomAugspurger commented on Feb 15, 2016

    @TomAugspurger
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions