repo2docker/tests/stencila-py/pyjp/py-jupyter/py-jupyter.ipynb.jats.xml

212 wiersze
10 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.1d3 20150301//EN" "JATS-archivearticle1.dtd">
<article xmlns:mml="http://www.w3.org/1998/Math/MathML" xmlns:xlink="http://www.w3.org/1999/xlink">
<front>
<article-meta>
<title-group>
<article-title>Jupyter and Stencila</article-title>
</title-group>
<contrib-group content-type="author">
<contrib contrib-type="person">
<name>
<surname>Pawlik</surname>
<given-names>Aleksandra</given-names>
</name>
</contrib>
</contrib-group>
<abstract>
<p>An example of a Jupyter notebook converted into a JATS document for editing in Stencila.</p>
</abstract>
</article-meta>
</front>
<body>
<sec id="introduction-1">
<title>Introduction</title>
<p>Jupyter notebooks (<xref ref-type="bibr" rid="ref-1">1</xref>&#x2013;<xref ref-type="bibr" rid="ref-3">3</xref>) are one of the most popular platforms for doing reproducible research. Stencila supports importing of Jupyter Notebook <monospace>.ipynb</monospace> files. This allows you to work with collegues to refine a document for final publication while still retaining the code cells, and thus reprodubility of your the work. In the future we also plan to support exporting to <monospace>.ipynb</monospace> files.</p>
</sec>
<sec id="markdown-cells-1">
<title>Markdown cells</title>
<p>Most standard Markdown should be supported by the importer including inline <monospace>code</monospace>, headings etc (although the Stencila user interface do not currently support rendering of some elements e.g.&#xA0;math and lists).</p>
</sec>
<sec id="code-cells-1">
<title>Code cells</title>
<p>Code cells in notebooks are imported without loss. Stencila&#x2019;s user interface currently differs from Jupyter in that code cells are executed on update while you are typing. This produces a very reactive user experience but is inappropriate for more compute intensive, longer running code cells. We are currently working on improving this to allowing users to decide to execute cells explicitly (e.g.&#xA0;using <monospace>Ctrl+Enter</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="pyjp" executable="yes">import sys
import time
&apos;Hello this is Python %s.%s and it is %s&apos; % (sys.version_info[0], sys.version_info[1], time.strftime(&apos;%c&apos;))</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>Stencila also support Jupyter code cells that produce plots. The cell below produces a simple plot based on the example from <ext-link ext-link-type="uri" xlink:href="https://matplotlib.org/examples/shapes_and_collections/scatter_demo.html">the Matplotlib website</ext-link>. Try changing the code below (for example, the variable <monospace>N</monospace>).</p>
<code specific-use="cell"><named-content><alternatives>
<code specific-use="source" language="pyjp" executable="yes">import numpy as np
import matplotlib.pyplot as plt
N = 50
N = min(N, 1000) # Prevent generation of too many numbers :)
x = np.random.rand(N)
y = np.random.rand(N)
colors = np.random.rand(N)
area = np.pi * (15 * np.random.rand(N))**2 # 0 to 15 point radii
plt.scatter(x, y, s=area, c=colors, alpha=0.5)
plt.show()</code>
<code specific-use="output" language="json">{}</code>
</alternatives>
</named-content>
</code>
<p>We are currently working on supporting <ext-link ext-link-type="uri" xlink:href="http://ipython.readthedocs.io/en/stable/interactive/magics.html">Jupyter&#x2019;s magic commands</ext-link> in Stencila via a bridge to Jupyter kernels.</p>
</sec>
<sec id="metadata-1">
<title>Metadata</title>
<p>To add some metadata about the document (such as authors, title, abstract and so on), In Jupyter, select <monospace>Edit -&gt; Edit Notebook metadata</monospace> from the top menu. Add the title and abstract as JSON strings and authors and organisations metadata as <ext-link ext-link-type="uri" xlink:href="https://www.w3schools.com/js/js_json_arrays.asp">JSON arrays</ext-link>. Author <monospace>affiliation</monospace> identifiers (like <monospace>university-of-earth</monospace> below) must be unique and preferably use only lowercase characters and no spaces.</p>
<p>For example,</p>
<preformat> &quot;authors&quot;: [
{
&quot;given-names&quot;: &quot;Your first name goes here&quot;,
&quot;surname&quot;: &quot;Your last name goes here&quot;,
&quot;email&quot;: &quot;your.email@your-organisation&quot;,
&quot;corresponding&quot;: &quot;yes / no&quot;,
&quot;affiliation&quot;: &quot;university-of-earth&quot;
}
],
&quot;organisations&quot;: [
{
&quot;university-of-earth&quot;: {
&quot;institution&quot;: &quot;Your organisation name&quot;,
&quot;city&quot;: &quot;Your city&quot;,
&quot;country&quot;: &quot;Your country&quot;
}
],
&quot;title&quot;: &quot;Your title goes here&quot;,
&quot;abstract&quot;: &quot;This is a paper about lots of different interesting things&quot;,
</preformat>
</sec>
<sec id="citations-and-references-1">
<title>Citations and references</title>
<p>Stencila supports Pandoc style citations and reference lists within Jupyter notebook Markdown cells. Add a <monospace>bibliography</monospace> entry to the notebook&#x2019;s metadata which points to a file containing your list of references e.g.</p>
<code language="json">&quot;bibliography&quot;: &quot;my-bibliography.bibtex&quot;</code>
<p>Then, within Markdown cells, you can insert citations inside square brackets and separated by semicolons. Each citation is represented using the <monospace>@</monospace> symbol followed by the citation identifier from the bibliography database e.g.</p>
<code language="json">[@perez2015project; @kluyver2016jupyter]</code>
<p>The <ext-link ext-link-type="uri" xlink:href="https://github.com/takluyver/cite2c">cite2c</ext-link> Jupyter extension allows for easier, &#x201C;cite-while-you-write&#x201D; insertion of citations from a Zotero library. We&#x2019;re hoping to support conversion of cite2cstyle citations/references in the <ext-link ext-link-type="uri" xlink:href="https://github.com/stencila/convert/issues/14">future</ext-link>.</p>
</sec>
</body>
<back>
<ref-list>
<ref id="ref-1">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Perez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
</person-group>
<article-title>Project jupyter: Computational narratives as the engine of collaborative data science</article-title>
<source>Retrieved September</source>
<year>2015</year>
<volume>11</volume>
<fpage>207</fpage>
</element-citation>
</ref>
<ref id="ref-2">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Kluyver</surname>
<given-names>Thomas</given-names>
</name>
<name>
<surname>Ragan-Kelley</surname>
<given-names>Benjamin</given-names>
</name>
<name>
<surname>P&#xE9;rez</surname>
<given-names>Fernando</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>Brian E</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>Matthias</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>Jonathan</given-names>
</name>
<name>
<surname>Kelley</surname>
<given-names>Kyle</given-names>
</name>
<name>
<surname>Hamrick</surname>
<given-names>Jessica B</given-names>
</name>
<name>
<surname>Grout</surname>
<given-names>Jason</given-names>
</name>
<name>
<surname>Corlay</surname>
<given-names>Sylvain</given-names>
</name>
<name>
<surname>Others</surname>
</name>
</person-group>
<article-title>Jupyter notebooks-a publishing format for reproducible computational workflows.</article-title>
<source>ELPUB</source>
<year>2016</year>
<fpage>87</fpage>
</element-citation>
</ref>
<ref id="ref-3">
<element-citation publication-type="journal">
<person-group person-group-type="author">
<name>
<surname>Ragan-Kelley</surname>
<given-names>M</given-names>
</name>
<name>
<surname>Perez</surname>
<given-names>F</given-names>
</name>
<name>
<surname>Granger</surname>
<given-names>B</given-names>
</name>
<name>
<surname>Kluyver</surname>
<given-names>T</given-names>
</name>
<name>
<surname>Ivanov</surname>
<given-names>P</given-names>
</name>
<name>
<surname>Frederic</surname>
<given-names>J</given-names>
</name>
<name>
<surname>Bussonnier</surname>
<given-names>M</given-names>
</name>
</person-group>
<article-title>The jupyter/ipython architecture: A unified view of computational research, from interactive exploration to communication and publication.</article-title>
<source>AGU Fall Meeting Abstracts</source>
<year>2014</year>
</element-citation>
</ref>
</ref-list>
</back>
</article>