Commit 61216e59 authored by Rok Roškar's avatar Rok Roškar
Browse files

Auto-saving for roskarr@ethz.ch on branch master from commit 8e7ed036

parent 8e7ed036
Pipeline #388539 passed with stage
in 4 minutes and 22 seconds
jupytext/tests/notebooks/ipynb_py/World filter=lfs diff=lfs merge=lfs -text
jupytext/demo/World filter=lfs diff=lfs merge=lfs -text
.git/objects/pack/pack-bedcc3f800a01729725f0e92d0a8f400ad53a0ce.pack filter=lfs diff=lfs merge=lfs -text
.git/modules/jupytext/objects/pack/pack-b270bd361734445c38c57c2bc3a8d5efa5dc2335.pack filter=lfs diff=lfs merge=lfs -text
demo/World filter=lfs diff=lfs merge=lfs -text
population.ipynb filter=lfs diff=lfs merge=lfs -text
%% Cell type:markdown id:ef929eed tags:
# Getting started with Jupytext
This small notebook shows you how to activate Jupytext in the JupyterLab
environment. We'll show you a few things that you can do with Jupytext and
a bit of what happens under the hood.
**Note: to run this notebook locally, you need to first follow the Jupytext
installation instructions and activate the JupyterLab plugin. If you're on
Binder, it should already work.**
## Enabling Jupytext in a new notebook
This notebook is brand new - it hasn't had any special extra metadata added
to it.
If we want Jupytext to save files in multiple formats automatically,
we can use the JupyterLab **command palette** to do so.
* In the _View_ menu, click on _Activate Command Palette_
* Then type **`Jupytext`**. You should see a number of commands come up. Each
one tells Jupytext to save the notebook in a different
file format automatically.
* Select **Pair notebook with Markdown**
That's it! If you have Jupytext installed, it will now save your notebook in
markdown format automatically when you save this `.ipynb` file
**in addition to** saving the `.ipynb` file itself.
After you've done this, save the notebook. You should now see a new file called
**`get_started.md`** in the same directory as this notebook.
## How does Jupytext know to do this?
Jupytext uses notebook-level metadata to keep track of what formats are paired
with a notebook. Below we'll print the metadata of this notebook so you can see
what the Jupytext metadata looks like.
%% Cell type:code id:350a250f tags:
``` python
import nbformat as nbf
from IPython.display import JSON
notebook = nbf.read('./get_started.ipynb', nbf.NO_CONVERT)
JSON(notebook['metadata'])
```
%% Cell type:markdown id:b9615e72 tags:
As you select different formats from the command palette (following the instructions
above) and save the notebook, you'll see this metadata change.
%% Cell type:markdown id:cff7b741 tags:
## That's it!
Play around with different kinds of code and outputs to see how each is
converted into its corresponding text format. Here's a little Python code
to get you started:
%% Cell type:code id:1868ebe8 tags:
``` python
import numpy as np
import matplotlib.pyplot as plt
plt.scatter(*np.random.randn(2, 100), c=np.random.randn(100), s=np.random.rand(100)*100)
```
%% Cell type:markdown id:edb7fd45 tags:
# Experiment with the demo notebook!
In the "demo" folder for `jupytext` there is a notebook called **`World population.ipynb`**.
By default, saving the demo notebook will also create *many* possible Jupytext
outputs so you can see what each looks like and which you prefer.
---
jupyter:
jupytext:
formats: ipynb,md
text_representation:
extension: .md
format_name: markdown
format_version: '1.1'
jupytext_version: 1.1.6
kernelspec:
display_name: Python 3
language: python
name: python3
---
# Getting started with Jupytext
This small notebook shows you how to activate Jupytext in the JupyterLab
environment. We'll show you a few things that you can do with Jupytext and
a bit of what happens under the hood.
**Note: to run this notebook locally, you need to first follow the Jupytext
installation instructions and activate the JupyterLab plugin. If you're on
Binder, it should already work.**
## Enabling Jupytext in a new notebook
This notebook is brand new - it hasn't had any special extra metadata added
to it.
If we want Jupytext to save files in multiple formats automatically,
we can use the JupyterLab **command palette** to do so.
* In the _View_ menu, click on _Activate Command Palette_
* Then type **`Jupytext`**. You should see a number of commands come up. Each
one tells Jupytext to save the notebook in a different
file format automatically.
* Select **Pair notebook with Markdown**
That's it! If you have Jupytext installed, it will now save your notebook in
markdown format automatically when you save this `.ipynb` file
**in addition to** saving the `.ipynb` file itself.
After you've done this, save the notebook. You should now see a new file called
**`get_started.md`** in the same directory as this notebook.
## How does Jupytext know to do this?
Jupytext uses notebook-level metadata to keep track of what formats are paired
with a notebook. Below we'll print the metadata of this notebook so you can see
what the Jupytext metadata looks like.
```python
import nbformat as nbf
from IPython.display import JSON
notebook = nbf.read('./get_started.ipynb', nbf.NO_CONVERT)
JSON(notebook['metadata'])
```
As you select different formats from the command palette (following the instructions
above) and save the notebook, you'll see this metadata change.
## That's it!
Play around with different kinds of code and outputs to see how each is
converted into its corresponding text format. Here's a little Python code
to get you started:
```python
import numpy as np
import matplotlib.pyplot as plt
plt.scatter(*np.random.randn(2, 100), c=np.random.randn(100), s=np.random.rand(100)*100)
```
# Experiment with the demo notebook!
In the "demo" folder for `jupytext` there is a notebook called **`World population.ipynb`**.
By default, saving the demo notebook will also create *many* possible Jupytext
outputs so you can see what each looks like and which you prefer.
Subproject commit 1ca33a2fbddc1e706b1f0c830b9f6ab5fd503a9a
Subproject commit 5d287b11a338788c462ccefae526e9b3b3551c31
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment