<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Introduction
This is a "kitchen sink" test fixture for the Jupyter Notebook (ipynb) format. It's principal use is in testing Stencila's conversion to / from Jupyter Notebooks but also serves to document that conversion. It contains a variety of document node types and Jupyter cell types.
Meta data
Stencila parses the metadata property of a notebook by coercing it to an Article. This allows article properties such as title, authors, funders and references to be encoded into the ipynb format and then extracted, for conversion to other formats e.g. HTML.
Markdown cells
This Markdown cell illustrates that Stencila supports the same Markdown syntax (including extensions) in Jupyter Notebooks, as in plain Markdown files.
Including inline node types like emphasis, strong emphasis, ~~delete~~, super^script^, and sub~script~.
Also lists
like this
And block quotes like this
Markdown cells get decoded into arrays of BlockContent and merged together, so the the fact that this cell is separate from the preceding and following cells will not be apparent.
Code expressions
Stencila supports inline executable code expressions and variable interpolation using either
Step1:  The following code cells illustrate how different types of cell outputs are decoded.
Step2:  Primitive outputs
Stencila will attempt to parse the text/plain outputs of cells (including stream outputs) into node types such as Boolean, Number, Array, Object etc, falling back to String.
Step3:  Image outputs
Stencila supports several image formats, including dynamic formats such as Plotly and Altair (Vega/Vega-Lite).
Step4:  HTML outputs
Stencila will attempt to convert text/html outputs into rich node types e.g. Table
Step5:  Preformatted text outputs
If a string output of the cell includes newlines, tabs or more than two consecutive spaces (other than leading or trailing whitespace) it is treated as preformatted text and converted to a Stencila CodeBlock.
Step6:  Errors
Stencila converts any cell outputs that are errors into a CodeError with message, type and stack trace. In addition, any output to the stderr stream is converted to a CodeError with errorType
<ASSISTANT_TASK:>
Python Code:
# Python
// JavaScript
Explanation: Introduction
This is a "kitchen sink" test fixture for the Jupyter Notebook (ipynb) format. It's principal use is in testing Stencila's conversion to / from Jupyter Notebooks but also serves to document that conversion. It contains a variety of document node types and Jupyter cell types.
Meta data
Stencila parses the metadata property of a notebook by coercing it to an Article. This allows article properties such as title, authors, funders and references to be encoded into the ipynb format and then extracted, for conversion to other formats e.g. HTML.
Markdown cells
This Markdown cell illustrates that Stencila supports the same Markdown syntax (including extensions) in Jupyter Notebooks, as in plain Markdown files.
Including inline node types like emphasis, strong emphasis, ~~delete~~, super^script^, and sub~script~.
Also lists
like this
And block quotes like this
Markdown cells get decoded into arrays of BlockContent and merged together, so the the fact that this cell is separate from the preceding and following cells will not be apparent.
Code expressions
Stencila supports inline executable code expressions and variable interpolation using either:
the exec keyword on backticked inline code e.g. 1+1{exec}, optionally with a language e.g. 2*2{r exec}.
double curly braces {{3+3}}, optionally with a language {{4+4}}{r}.
Using backticks with exec is recommend as most Markdown parsers will properly escape symbols like * within backticks. If code expressions do not specify a language, then Stencila falls back to the language of the notebook e.g. 4*4{exec} and {{5+5}}.
Code chunks
Jupyter code cells are converted into Stencila CodeChunks.
Cell languages
All cells in a notebook normally all use the same language. However, if a cell has a language_info.name specified in their metadata property then Stencila will use that, rather than the language from the top-level metadata of the notebook.
End of explanation
# No output
Explanation: The following code cells illustrate how different types of cell outputs are decoded.
End of explanation
# Plain text output
"Hello world"
True
False
42
import math
math.pi
dict(a=1,b=2)
list(range(10))
dict(a='string', b=1, c=3.14, d=[1, 2, 3], e=dict(f=1))
# Stream output
print("Just a string")
Explanation: Primitive outputs
Stencila will attempt to parse the text/plain outputs of cells (including stream outputs) into node types such as Boolean, Number, Array, Object etc, falling back to String.
End of explanation
# Matplotlib
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(0, 10, 100)
plt.plot(x, np.sin(x))
plt.show()
# Plotly
import plotly.express as px
fig = px.scatter(px.data.iris(), x="sepal_width", y="sepal_length")
fig.show()
# Altair
import altair as alt
import pandas as pd
alt.renderers.enable('mimetype')
source = pd.DataFrame({
    'a': ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I'],
    'b': [28, 55, 43, 91, 81, 53, 19, 87, 52]
})
alt.Chart(source).mark_bar().encode(
    x='a',
    y='b'
)
Explanation: Image outputs
Stencila supports several image formats, including dynamic formats such as Plotly and Altair (Vega/Vega-Lite).
End of explanation
import pandas as pd
import numpy as np
df = pd.DataFrame(np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]), columns=['a', 'b', 'c'])
# By default a `text/html` representation of the data frame is generated
df
Explanation: HTML outputs
Stencila will attempt to convert text/html outputs into rich node types e.g. Table
End of explanation
# Print the data.frame so that is output as `text/plain`
print(df)
Explanation: Preformatted text outputs
If a string output of the cell includes newlines, tabs or more than two consecutive spaces (other than leading or trailing whitespace) it is treated as preformatted text and converted to a Stencila CodeBlock.
End of explanation
A syntax error
foo()
import sys
print("Whooaah!", file=sys.stderr)
Explanation: Errors
Stencila converts any cell outputs that are errors into a CodeError with message, type and stack trace. In addition, any output to the stderr stream is converted to a CodeError with errorType: "stderr".
End of explanation
<END_TASK>