Create parallel namespaces in Jupyter Notebooks
Project description
Jupyter Spaces
Jupyter Spaces is an IPython extension for creating parallel namespaces availabe within the user namespace. It is designed to be used via IPython magics in Jupyter notebooks.
Installation
pip install jupyter_spaces
jupyter_spaces
supports Python versions 3.4
, 3.5
and 3.6
.
Usage
Load jupyter_spaces
extension
%load_ext jupyter_spaces
Reload jupyter_spaces
extension
%reload_ext jupyter_spaces
Reloading the extension will remove all spaces.
Run a cell within a space
%%space <space-name>
alpha = 0.50
print(alpha)
When you execute a cell within a space, all references are firstly searched in
the space namespace and secondly in the user namespace. All assignments are
made in the space namespace. However, as expected, global
assigments are made
in the user namespace.
Console output
Conversely to the standard usage of the python console, you need to use print to get a output in the console or Jupyter cell output.
- No output to console
%%space <space-name> 100
- Output to console
%%space <space-name> print(100)
Remove a space
%remove_space <space-name>
Access all spaces at once
Without using any magic you can access the spaces' namespaces. This might be useful to jointly post-process or compare the spaces' contents.
from jupyter_spaces import get_spaces
spaces = get_spaces()
space = spaces[<space-name>]
reference = space.namespace[<reference-name>]
Space
objects have two properties:
name
the name of the spacenamespace
a dictionary with the namespace of the space
Modifying the spaces via get_spaces
will actually modify the underlying
spaces.
Acknowledgements
Many thanks to Yeray Diaz Diaz and Karol Duleba!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for jupyter_spaces-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb0f1e7b73f1b3001d60b608d1899ff91bcc27fb1ff72caf6e2d9bc0d3547c33 |
|
MD5 | 61600aa7147a84f07b65c2b4fb8d6c23 |
|
BLAKE2b-256 | 0c1a6364068b3baf6607fc7e049caeb55bc440cb04cfe888808131a77ec55f2b |