Skip to content

Did updates to ipython_directive bork support for cython magic snippets? #4791

Closed
@ghost

Description

...I wish to register a complaint.

re #4570, I'd be glad for pandas to get rid of it's copy of ipython_directive
and to that end, I rebased the pandas tweaks on the version in ipython/master (0355d3d).

I cannot however get cython magic code snippets to work with the updated version,
and I've been unable to locate other packages which do this as a sanity check.
Assuming it should work out of the box rather then as a tweak pandas added and
which I failed to carry over.

Here's an example from current pandas docs which now fails to render properly.

.. ipython:: python

   %load_ext cythonmagic


Now, let's simply copy our functions over to cython as is (the suffix
is here to distinguish between function versions):

.. ipython::

   In [2]: %%cython
      ...: def f_plain(x):
      ...:     return x * (x - 1)
      ...: def integrate_f_plain(a, b, N):
      ...:     s = 0
      ...:     dx = (b - a) / N
      ...:     for i in range(N):
      ...:         s += f_plain(a + i * dx)
      ...:     return s * dx
      ...:

.. note::

  If you're having trouble pasting the above into your ipython, you may need
  to be using bleeding edge ipython for paste to play well with cell magics.


.. ipython:: python

   %timeit df.apply(lambda x: integrate_f_plain(x['a'], x['b'], x['N']), axis=1)

Is it my fault or is there an issue with the new version?

cc @takluyver, @jorisvandenbossche

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions