-
Notifications
You must be signed in to change notification settings - Fork 394
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ignore cell language when exporting to hydrogen format #179
Hydrogen allows cell magics just like in the Jupyter Notebook. There's no need to comment out these cells.
- Loading branch information
Showing
16 changed files
with
377 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# %% | ||
1 + 1 | ||
|
||
# %% | ||
import pandas as pd | ||
pd.Series({'A':5, 'B':2}).plot() | ||
|
||
# %% | ||
%matplotlib inline | ||
pd.Series({'A':5, 'B':2}).plot(figsize=(3,2)) | ||
|
||
# %% | ||
%%html | ||
<p><a href="https://github.com/mwouts/jupytext", style="color: rgb(0,0,255)">Jupytext</a> on GitHub</p> | ||
|
||
# %% | ||
%load_ext rpy2.ipython | ||
|
||
# %% | ||
%%R -w 400 -h 200 | ||
library(ggplot2) | ||
ggplot(data=data.frame(x=c('A', 'B'), y=c(5, 2)), aes(x,weight=y)) + geom_bar() | ||
|
||
# %% | ||
%%latex | ||
$\frac{\pi}{2}$ |
29 changes: 29 additions & 0 deletions
29
tests/notebooks/mirror/ipynb_to_hydrogen/Notebook with function and cell metadata 164.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
1 + 1 | ||
|
||
|
||
# %% [markdown] | ||
# A markdown cell | ||
# And below, the cell for function f has non trivial cell metadata. And the next cell as well. | ||
|
||
# %% {"attributes": {"classes": [], "id": "", "n": "10"}} | ||
def f(x): | ||
return x | ||
|
||
|
||
# %% {"attributes": {"classes": [], "id": "", "n": "10"}} | ||
f(5) | ||
|
||
# %% [markdown] | ||
# More text | ||
|
||
# %% | ||
2 + 2 |
29 changes: 29 additions & 0 deletions
29
tests/notebooks/mirror/ipynb_to_hydrogen/Notebook with many hash signs.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# ################################################################## | ||
# This is a notebook that contains many hash signs. | ||
# Hopefully its python representation is not recognized as a Sphinx Gallery script... | ||
# ################################################################## | ||
|
||
# %% | ||
some = 1 | ||
code = 2 | ||
some+code | ||
|
||
################################################################## | ||
# A comment | ||
################################################################## | ||
# Another comment | ||
|
||
# %% [markdown] | ||
# ################################################################## | ||
# This is a notebook that contains many hash signs. | ||
# Hopefully its python representation is not recognized as a Sphinx Gallery script... | ||
# ################################################################## |
30 changes: 30 additions & 0 deletions
30
tests/notebooks/mirror/ipynb_to_hydrogen/Notebook_with_R_magic.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 2 | ||
# language: python | ||
# name: python2 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # A notebook with R cells | ||
# | ||
# This notebook shows the use of R cells to generate plots | ||
|
||
# %% | ||
%load_ext rpy2.ipython | ||
|
||
# %% | ||
%%R | ||
suppressMessages(require(tidyverse)) | ||
|
||
# %% | ||
%%R | ||
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species)) + geom_point() | ||
|
||
# %% [markdown] | ||
# The default plot dimensions are not good for us, so we use the -w and -h parameters in %%R magic to set the plot size | ||
|
||
# %% | ||
%%R -w 400 -h 240 | ||
ggplot(iris, aes(x = Sepal.Length, y = Petal.Length, color=Species)) + geom_point() |
17 changes: 17 additions & 0 deletions
17
tests/notebooks/mirror/ipynb_to_hydrogen/convert_to_py_then_test_with_update83.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
%%time | ||
|
||
print('asdf') | ||
|
||
# %% [markdown] | ||
# Thanks for jupytext! | ||
|
||
# %% |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
# This is an unfrozen cell. Works as usual. | ||
print("I'm a regular cell so I run and print!") | ||
|
||
# %% {"deletable": false, "editable": false, "run_control": {"frozen": true}} | ||
# # This is an frozen cell | ||
# print("I'm frozen so Im not executed :(") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] | ||
# # Jupyter notebook | ||
# | ||
# This notebook is a simple jupyter notebook. It only has markdown and code cells. And it does not contain consecutive markdown cells. We start with an addition: | ||
|
||
# %% | ||
a = 1 | ||
b = 2 | ||
a + b | ||
|
||
# %% [markdown] | ||
# Now we return a few tuples | ||
|
||
# %% | ||
a, b | ||
|
||
# %% | ||
a, b, a+b | ||
|
||
# %% [markdown] | ||
# And this is already the end of the notebook |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
c = ''' | ||
title: "Quick test" | ||
output: | ||
ioslides_presentation: | ||
widescreen: true | ||
smaller: true | ||
editor_options: | ||
chunk_output_type console | ||
''' | ||
|
||
# %% | ||
import yaml | ||
print(yaml.dump(yaml.load(c))) | ||
|
||
# %% | ||
?next |
16 changes: 16 additions & 0 deletions
16
tests/notebooks/mirror/ipynb_to_hydrogen/jupyter_with_raw_cell_in_body.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
1+2+3 | ||
|
||
# %% [raw] | ||
# This is a raw cell | ||
|
||
# %% [markdown] | ||
# This is a markdown cell |
19 changes: 19 additions & 0 deletions
19
tests/notebooks/mirror/ipynb_to_hydrogen/jupyter_with_raw_cell_on_top.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# --- | ||
# title: "Quick test" | ||
# output: | ||
# ioslides_presentation: | ||
# widescreen: true | ||
# smaller: true | ||
# editor_options: | ||
# chunk_output_type console | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% | ||
1+2+3 | ||
|
||
# %% |
9 changes: 9 additions & 0 deletions
9
tests/notebooks/mirror/ipynb_to_hydrogen/notebook_with_complex_metadata.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% |
24 changes: 24 additions & 0 deletions
24
tests/notebooks/mirror/ipynb_to_hydrogen/nteract_with_parameter.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# --- | ||
# jupyter: | ||
# kernel_info: | ||
# name: python3 | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% {"outputHidden": false, "inputHidden": false, "tags": ["parameters"]} | ||
param = 4 | ||
|
||
# %% {"outputHidden": false, "inputHidden": false} | ||
import pandas as pd | ||
|
||
# %% {"outputHidden": false, "inputHidden": false} | ||
df = pd.DataFrame({'A': [1, 2], 'B': [3 + param, 4]}, | ||
index=pd.Index(['x0', 'x1'], name='x')) | ||
df | ||
|
||
# %% {"outputHidden": false, "inputHidden": false} | ||
%matplotlib inline | ||
df.plot(kind='bar') |
16 changes: 16 additions & 0 deletions
16
tests/notebooks/mirror/ipynb_to_hydrogen/sample_rise_notebook_66.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# --- | ||
# jupyter: | ||
# kernelspec: | ||
# display_name: Python 3 | ||
# language: python | ||
# name: python3 | ||
# --- | ||
|
||
# %% [markdown] {"slideshow": {"slide_type": "slide"}} | ||
# A markdown cell | ||
|
||
# %% {"slideshow": {"slide_type": ""}} | ||
1+1 | ||
|
||
# %% [markdown] {"cell_style": "center", "slideshow": {"slide_type": "fragment"}} | ||
# Markdown cell two |
82 changes: 82 additions & 0 deletions
82
tests/notebooks/mirror/script_to_ipynb/hydrogen_latex_html_R_magics.ipynb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"1 + 1" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import pandas as pd\n", | ||
"pd.Series({'A':5, 'B':2}).plot()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%matplotlib inline\n", | ||
"pd.Series({'A':5, 'B':2}).plot(figsize=(3,2))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%html\n", | ||
"<p><a href=\"https://github.com/mwouts/jupytext\", style=\"color: rgb(0,0,255)\">Jupytext</a> on GitHub</p>" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%load_ext rpy2.ipython" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%R -w 400 -h 200\n", | ||
"library(ggplot2)\n", | ||
"ggplot(data=data.frame(x=c('A', 'B'), y=c(5, 2)), aes(x,weight=y)) + geom_bar()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"%%latex\n", | ||
"$\\frac{\\pi}{2}$" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"jupytext": { | ||
"cell_metadata_filter": "-all", | ||
"main_language": "python", | ||
"notebook_metadata_filter": "-all" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.