sphinx-autorun icon indicating copy to clipboard operation
sphinx-autorun copied to clipboard

Remember objects created in previous blocks?

Open endrebak opened this issue 6 years ago • 2 comments

First off, thanks for maintaining this package. Wonderful work!

I have docs that have code example interspersed with text. It might look like this:

Subsetting Ranges
=================

There are many ways to subset a PyRanges object. Each returns a new PyRanges object and does not change the old one.

.. runblock:: pycon
   >>> import pandas as pd
   >>> import pyranges as pr

   >>> gr = pr.load_dataset("chipseq")


Chromosome only
~~~~~~~~~~~~~~~

.. runblock:: pycon
   >>> import pandas as pd # ignore
   >>> import pyranges as pr # ignore

   >>> gr = pr.load_dataset("chipseq") # ignore

   >>> gr["chrX"]

Is there a way to let me reuse the object gr in the second pycon block? I can use the #ignore hack, but it would be nice to be able to avoid it.

endrebak avatar May 16 '18 07:05 endrebak

I'm not entirely sure how to implement this yet, but it sounds like a useful feature. I'd definitely accept a PR for this. :stuck_out_tongue:

I'll try to look into it soon, but I can't commit to anything for now.

WhyNotHugo avatar May 21 '18 16:05 WhyNotHugo

Only just came across this extension but from a stackoverflow question that then points to a now old fork which claims to do this.

inkychris avatar Nov 20 '19 13:11 inkychris