Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/davidesarra/jupyter_spaces
Create parallel namespaces in Jupyter Notebooks
https://github.com/davidesarra/jupyter_spaces
extension ipython ipython-magic jupyter jupyter-notebook jupyterlab namespace python
Last synced: 2 months ago
JSON representation
Create parallel namespaces in Jupyter Notebooks
- Host: GitHub
- URL: https://github.com/davidesarra/jupyter_spaces
- Owner: davidesarra
- License: mit
- Created: 2018-04-10T18:07:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-11-08T18:38:04.000Z (about 2 years ago)
- Last Synced: 2024-09-28T23:43:35.979Z (3 months ago)
- Topics: extension, ipython, ipython-magic, jupyter, jupyter-notebook, jupyterlab, namespace, python
- Language: Python
- Homepage:
- Size: 31.3 KB
- Stars: 27
- Watchers: 4
- Forks: 5
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Jupyter Spaces
[![codecov](https://codecov.io/gh/davidesarra/jupyter_spaces/branch/master/graph/badge.svg)](https://codecov.io/gh/davidesarra/jupyter_spaces)
[![Supported Python Versions](https://img.shields.io/pypi/pyversions/jupyter_spaces.svg)](https://pypi.org/project/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
```bash
pip install jupyter_spaces
````jupyter_spaces` supports Python versions `3.6`, `3.7`, `3.8`, `3.9`, `3.10`
and `3.11`.## Usage
### Load `jupyter_spaces` extension
```python
%load_ext jupyter_spaces
```### Reload `jupyter_spaces` extension
```python
%reload_ext jupyter_spaces
```Reloading the extension will remove all spaces.
### Run a cell within a space
```python
%%space
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
```python
%remove_space
```### 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.```python
from jupyter_spaces import get_spacesspaces = get_spaces()
space = spaces[]
reference = space.namespace[]
````Space` objects have two properties:
- `name` the name of the space
- `namespace` a dictionary with the namespace of the spaceModifying the spaces via `get_spaces` will actually modify the underlying
spaces.## Acknowledgements
Many thanks to [Yeray Diaz Diaz](https://github.com/yeraydiazdiaz) and
[Karol Duleba](https://github.com/mrfuxi)!