Create parallel namespaces in Jupyter Notebooks
Project description
Jupyter Spaces
Jupyter Spaces is an IPython extension for creating parallel namespaces available 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.6
, 3.7
, 3.8
, 3.9
and 3.10
.
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
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.
Trying to delete a user namespace reference will raise an error. Trying to
affect a user namespace reference using the keyword global
will produce an
execution equivalent to not using such keyword.
Mutable objects in the user namespace can be altered (e.g. appending an item to a list).
Remove a space
%remove_space <space-name>
Access all spaces at once
You can access all the spaces' namespaces at once without using any magic. 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
File details
Details for the file jupyter_spaces-0.3.0.tar.gz
.
File metadata
- Download URL: jupyter_spaces-0.3.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b18120a0339d565c92ff45127a08937e332706f5766f77cb262c1fe9afdb778e |
|
MD5 | 30adf887676d3b5c22e28d68e63688c8 |
|
BLAKE2b-256 | 0939b5993dbd18d529fed8accc7361b30cfbb0c5407cb78ae8ef1913a7f6f2a2 |
File details
Details for the file jupyter_spaces-0.3.0-py3-none-any.whl
.
File metadata
- Download URL: jupyter_spaces-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0d953da8f29562ee155c259696fae7e59e884df7bb30613e5027f471efcadd89 |
|
MD5 | 0616423a4531b602430b5fc1b1f848f8 |
|
BLAKE2b-256 | 7373df2a457290d56684e00dce4a6c4b9002591e115e32008152ae70b55126ae |