From 1e136a8b50083c3c35b4d82166bdbd1fb93f4053 2014-11-01 23:41:03 From: MinRK Date: 2014-11-01 23:41:03 Subject: [PATCH] s/prompt_number/execution_count in nbformat 4 --- diff --git a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py index 904bc98..4fb2705 100644 --- a/IPython/html/nbconvert/tests/test_nbconvert_handlers.py +++ b/IPython/html/nbconvert/tests/test_nbconvert_handlers.py @@ -60,7 +60,7 @@ class APITest(NotebookTestBase): cc1.outputs.append(new_output(output_type="stream", data=u'12')) cc1.outputs.append(new_output(output_type="execute_result", mime_bundle={'image/png' : png_green_pixel}, - prompt_number=1, + execution_count=1, )) nb.cells.append(cc1) diff --git a/IPython/html/static/notebook/js/codecell.js b/IPython/html/static/notebook/js/codecell.js index ca5b6f3..8ae55b5 100644 --- a/IPython/html/static/notebook/js/codecell.js +++ b/IPython/html/static/notebook/js/codecell.js @@ -471,7 +471,7 @@ define([ this.code_mirror.clearHistory(); this.auto_highlight(); } - this.set_input_prompt(data.prompt_number); + this.set_input_prompt(data.execution_count); this.output_area.trusted = data.metadata.trusted || false; this.output_area.fromJSON(data.outputs); if (data.metadata.collapsed !== undefined) { @@ -490,9 +490,9 @@ define([ data.source = this.get_text(); // is finite protect against undefined and '*' value if (isFinite(this.input_prompt_number)) { - data.prompt_number = this.input_prompt_number; + data.execution_count = this.input_prompt_number; } else { - data.prompt_number = null; + data.execution_count = null; } var outputs = this.output_area.toJSON(); data.outputs = outputs; diff --git a/IPython/html/static/notebook/js/outputarea.js b/IPython/html/static/notebook/js/outputarea.js index 3732563..81c49ed 100644 --- a/IPython/html/static/notebook/js/outputarea.js +++ b/IPython/html/static/notebook/js/outputarea.js @@ -220,7 +220,7 @@ define([ json = content.data; json.output_type = msg_type; json.metadata = content.metadata; - json.prompt_number = content.execution_count; + json.execution_count = content.execution_count; } else if (msg_type === "error") { json.ename = content.ename; json.evalue = content.evalue; @@ -414,7 +414,7 @@ define([ OutputArea.prototype.append_execute_result = function (json) { - var n = json.prompt_number || ' '; + var n = json.execution_count || ' '; var toinsert = this.create_output_area(); if (this.prompt_area) { toinsert.find('div.prompt').addClass('output_prompt').text('Out[' + n + ']:'); diff --git a/IPython/html/tests/notebook/inject_js.js b/IPython/html/tests/notebook/inject_js.js index 4f72a36..03757aa 100644 --- a/IPython/html/tests/notebook/inject_js.js +++ b/IPython/html/tests/notebook/inject_js.js @@ -13,7 +13,7 @@ casper.notebook_test(function () { this.evaluate(function () { var cell = IPython.notebook.get_cell(0); var json = cell.toJSON(); - json.prompt_number = ""; + json.execution_count = ""; cell.fromJSON(json); }); diff --git a/IPython/nbconvert/exporters/tests/files/notebook2.ipynb b/IPython/nbconvert/exporters/tests/files/notebook2.ipynb index 6381d97..8a6b5ea 100644 --- a/IPython/nbconvert/exporters/tests/files/notebook2.ipynb +++ b/IPython/nbconvert/exporters/tests/files/notebook2.ipynb @@ -17,6 +17,7 @@ }, { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, @@ -28,18 +29,17 @@ "text": "\nWelcome to pylab, a matplotlib-based Python environment [backend: module://IPython.kernel.zmq.pylab.backend_inline].\nFor more information, type 'help(pylab)'.\n" } ], - "prompt_number": 1, "source": [ "%pylab inline" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 2, "source": [ "import numpy as np" ] @@ -53,62 +53,62 @@ }, { "cell_type": "code", + "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 6, "source": [ "a = np.random.uniform(size=(100,100))" ] }, { "cell_type": "code", + "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 7, "metadata": {}, "output_type": "execute_result", - "prompt_number": 7, "text/plain": [ "(100, 100)" ] } ], - "prompt_number": 7, "source": [ "a.shape" ] }, { "cell_type": "code", + "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 8, "source": [ "evs = np.linalg.eigvals(a)" ] }, { "cell_type": "code", + "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 10, "metadata": {}, "output_type": "execute_result", - "prompt_number": 10, "text/plain": [ "(100,)" ] } ], - "prompt_number": 10, "source": [ "evs.shape" ] @@ -122,14 +122,15 @@ }, { "cell_type": "code", + "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 14, "metadata": {}, "output_type": "execute_result", - "prompt_number": 14, "text/plain": [ "(array([95, 4, 0, 0, 0, 0, 0, 0, 0, 1]),\n", " array([ -2.93566063, 2.35937011, 7.65440086, 12.9494316 ,\n", @@ -147,18 +148,17 @@ ] } ], - "prompt_number": 14, "source": [ "hist(evs.real)" ] }, { "cell_type": "code", + "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": null, "source": [] } ], diff --git a/IPython/nbconvert/preprocessors/clearoutput.py b/IPython/nbconvert/preprocessors/clearoutput.py index 61c4b7f..f28f189 100644 --- a/IPython/nbconvert/preprocessors/clearoutput.py +++ b/IPython/nbconvert/preprocessors/clearoutput.py @@ -3,16 +3,8 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. -#----------------------------------------------------------------------------- -# Imports -#----------------------------------------------------------------------------- - from .base import Preprocessor - -#----------------------------------------------------------------------------- -# Classes -#----------------------------------------------------------------------------- class ClearOutputPreprocessor(Preprocessor): """ Removes the output from all code cells in a notebook. @@ -24,5 +16,5 @@ class ClearOutputPreprocessor(Preprocessor): """ if cell.cell_type == 'code': cell.outputs = [] - cell.prompt_number = None + cell.execution_count = None return cell, resources diff --git a/IPython/nbconvert/preprocessors/execute.py b/IPython/nbconvert/preprocessors/execute.py index 03975c2..12077c5 100644 --- a/IPython/nbconvert/preprocessors/execute.py +++ b/IPython/nbconvert/preprocessors/execute.py @@ -88,8 +88,7 @@ class ExecutePreprocessor(Preprocessor): # set the prompt number for the input and the output if 'execution_count' in content: - cell['prompt_number'] = content['execution_count'] - out.prompt_number = content['execution_count'] + cell['execution_count'] = content['execution_count'] if msg_type == 'status': if content['execution_state'] == 'idle': @@ -101,8 +100,6 @@ class ExecutePreprocessor(Preprocessor): elif msg_type == 'clear_output': outs = [] continue - elif msg_type == 'execute_result': - cell['prompt_number'] = content['execution_count'] try: out = output_from_msg(msg) diff --git a/IPython/nbconvert/preprocessors/tests/base.py b/IPython/nbconvert/preprocessors/tests/base.py index 7115560..ae02c05 100644 --- a/IPython/nbconvert/preprocessors/tests/base.py +++ b/IPython/nbconvert/preprocessors/tests/base.py @@ -27,7 +27,7 @@ class PreprocessorTestsBase(TestsBase): out['application/pdf'] = 'aA==' outputs.append(out) - cells=[nbformat.new_code_cell(source="$ e $", prompt_number=1, outputs=outputs), + cells=[nbformat.new_code_cell(source="$ e $", execution_count=1, outputs=outputs), nbformat.new_markdown_cell(source="$ e $")] return nbformat.new_notebook(cells=cells) diff --git a/IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb b/IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb index 5470ee6..58f1bf5 100644 --- a/IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/Clear Output.ipynb @@ -2,17 +2,18 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 1, "source": [ "from IPython.display import clear_output" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, @@ -24,7 +25,6 @@ "text": "9\n" } ], - "prompt_number": 2, "source": [ "for i in range(10):\n", " clear_output()\n", diff --git a/IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb b/IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb index e2f29cf..b632010 100644 --- a/IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/Factorials.ipynb @@ -2,17 +2,18 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 1, "source": [ "i, j = 1, 1" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, @@ -24,7 +25,6 @@ "text": "2\n3\n5\n8\n13\n21\n34\n55\n89\n144\n" } ], - "prompt_number": 2, "source": [ "for m in range(10):\n", " i, j = j, i + j\n", diff --git a/IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb b/IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb index 665a654..dce137a 100644 --- a/IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/HelloWorld.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, @@ -13,7 +14,6 @@ "text": "Hello World\n" } ], - "prompt_number": 1, "source": [ "print(\"Hello World\")" ] diff --git a/IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb b/IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb index 48deb38..48423aa 100644 --- a/IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/Inline Image.ipynb @@ -2,22 +2,22 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 1, "source": [ "from IPython.display import Image" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 2, "source": [ "Image('../input/python.png');" ] diff --git a/IPython/nbconvert/preprocessors/tests/files/SVG.ipynb b/IPython/nbconvert/preprocessors/tests/files/SVG.ipynb index cd4684b..9c03ab7 100644 --- a/IPython/nbconvert/preprocessors/tests/files/SVG.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/SVG.ipynb @@ -2,22 +2,24 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 1, "source": [ "from IPython.display import SVG" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 2, "image/svg+xml": [ "\n", " \n", @@ -25,13 +27,11 @@ ], "metadata": {}, "output_type": "execute_result", - "prompt_number": 2, "text/plain": [ "" ] } ], - "prompt_number": 2, "source": [ "SVG(data='''\n", "\n", diff --git a/IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb b/IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb index d308d1f..2271fb6 100644 --- a/IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/Skip Exceptions.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, @@ -19,13 +20,13 @@ ] } ], - "prompt_number": 1, "source": [ "raise Exception(\"message\")" ] }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, @@ -37,7 +38,6 @@ "text": "ok\n" } ], - "prompt_number": 2, "source": [ "print('ok')" ] diff --git a/IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb b/IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb index 2d658fa..9d3ec1d 100644 --- a/IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb +++ b/IPython/nbconvert/preprocessors/tests/files/Unicode.ipynb @@ -2,6 +2,7 @@ "cells": [ { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, @@ -13,7 +14,6 @@ "text": "\u2603\n" } ], - "prompt_number": 1, "source": [ "print('\u2603')" ] diff --git a/IPython/nbconvert/preprocessors/tests/test_clearoutput.py b/IPython/nbconvert/preprocessors/tests/test_clearoutput.py index e10b0f4..21f4c2e 100644 --- a/IPython/nbconvert/preprocessors/tests/test_clearoutput.py +++ b/IPython/nbconvert/preprocessors/tests/test_clearoutput.py @@ -32,4 +32,4 @@ class TestClearOutput(PreprocessorTestsBase): preprocessor = self.build_preprocessor() nb, res = preprocessor(nb, res) assert nb.cells[0].outputs == [] - assert nb.cells[0].prompt_number is None + assert nb.cells[0].execution_count is None diff --git a/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py b/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py index 57a7088..f65a7ff 100644 --- a/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py +++ b/IPython/nbconvert/preprocessors/tests/test_coalescestreams.py @@ -33,7 +33,7 @@ class TestCoalesceStreams(PreprocessorTestsBase): nbformat.new_output(output_type="stream", name="stdout", text="5"), nbformat.new_output(output_type="stream", name="stdout", text="6"), nbformat.new_output(output_type="stream", name="stdout", text="7")] - cells=[nbformat.new_code_cell(source="# None", prompt_number=1,outputs=outputs)] + cells=[nbformat.new_code_cell(source="# None", execution_count=1,outputs=outputs)] nb = nbformat.new_notebook(cells=cells) res = self.build_resources() @@ -49,7 +49,7 @@ class TestCoalesceStreams(PreprocessorTestsBase): nbformat.new_output(output_type="stream", name="stdout", text="\nz"), nbformat.new_output(output_type="stream", name="stdout", text="\rc\n"), nbformat.new_output(output_type="stream", name="stdout", text="z\rz\rd")] - cells=[nbformat.new_code_cell(source="# None", prompt_number=1,outputs=outputs)] + cells=[nbformat.new_code_cell(source="# None", execution_count=1,outputs=outputs)] nb = nbformat.new_notebook(cells=cells) res = self.build_resources() diff --git a/IPython/nbconvert/preprocessors/tests/test_execute.py b/IPython/nbconvert/preprocessors/tests/test_execute.py index b07a1e9..699eaf4 100644 --- a/IPython/nbconvert/preprocessors/tests/test_execute.py +++ b/IPython/nbconvert/preprocessors/tests/test_execute.py @@ -53,9 +53,9 @@ class TestExecute(PreprocessorTestsBase): normalized_actual_outputs = list(map(self.normalize_output, actual_outputs)) assert normalized_expected_outputs == normalized_actual_outputs - expected_prompt_number = expected_cell.get('prompt_number', None) - actual_prompt_number = actual_cell.get('prompt_number', None) - assert expected_prompt_number == actual_prompt_number + expected_execution_count = expected_cell.get('execution_count', None) + actual_execution_count = actual_cell.get('execution_count', None) + assert expected_execution_count == actual_execution_count def build_preprocessor(self): @@ -81,8 +81,8 @@ class TestExecute(PreprocessorTestsBase): preprocessor = self.build_preprocessor() cleaned_input_nb = copy.deepcopy(input_nb) for cell in cleaned_input_nb.cells: - if 'prompt_number' in cell: - del cell['prompt_number'] + if 'execution_count' in cell: + del cell['execution_count'] cell['outputs'] = [] output_nb, _ = preprocessor(cleaned_input_nb, res) self.assert_notebooks_equal(output_nb, input_nb) diff --git a/IPython/nbconvert/preprocessors/tests/test_revealhelp.py b/IPython/nbconvert/preprocessors/tests/test_revealhelp.py index 7e50618..49c8894 100644 --- a/IPython/nbconvert/preprocessors/tests/test_revealhelp.py +++ b/IPython/nbconvert/preprocessors/tests/test_revealhelp.py @@ -21,9 +21,9 @@ class Testrevealhelp(PreprocessorTestsBase): slide_metadata = {'slideshow' : {'slide_type': 'slide'}} subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} - cells=[nbformat.new_code_cell(source="", prompt_number=1, outputs=outputs), + cells=[nbformat.new_code_cell(source="", execution_count=1, outputs=outputs), nbformat.new_markdown_cell(source="", metadata=slide_metadata), - nbformat.new_code_cell(source="", prompt_number=2, outputs=outputs), + nbformat.new_code_cell(source="", execution_count=2, outputs=outputs), nbformat.new_markdown_cell(source="", metadata=slide_metadata), nbformat.new_markdown_cell(source="", metadata=subslide_metadata)] diff --git a/IPython/nbconvert/preprocessors/tests/test_svg2pdf.py b/IPython/nbconvert/preprocessors/tests/test_svg2pdf.py index f744606..9d82388 100644 --- a/IPython/nbconvert/preprocessors/tests/test_svg2pdf.py +++ b/IPython/nbconvert/preprocessors/tests/test_svg2pdf.py @@ -47,7 +47,7 @@ class Testsvg2pdf(PreprocessorTestsBase): slide_metadata = {'slideshow' : {'slide_type': 'slide'}} subslide_metadata = {'slideshow' : {'slide_type': 'subslide'}} - cells=[nbformat.new_code_cell(source="", prompt_number=1, outputs=outputs)] + cells=[nbformat.new_code_cell(source="", execution_count=1, outputs=outputs)] return nbformat.new_notebook(cells=cells) diff --git a/IPython/nbconvert/templates/html/basic.tpl b/IPython/nbconvert/templates/html/basic.tpl index 22f0382..b79b253 100644 --- a/IPython/nbconvert/templates/html/basic.tpl +++ b/IPython/nbconvert/templates/html/basic.tpl @@ -23,8 +23,8 @@ {% block in_prompt -%}
-{%- if cell.prompt_number is defined -%} -In [{{ cell.prompt_number|replace(None, " ") }}]: +{%- if cell.execution_count is defined -%} +In [{{ cell.execution_count|replace(None, " ") }}]: {%- else -%} In [ ]: {%- endif -%} @@ -55,8 +55,8 @@ In [ ]:
{%- if output.output_type == 'execute_result' -%}
-{%- if cell.prompt_number is defined -%} - Out[{{ cell.prompt_number|replace(None, " ") }}]: +{%- if cell.execution_count is defined -%} + Out[{{ cell.execution_count|replace(None, " ") }}]: {%- else -%} Out[ ]: {%- endif -%} diff --git a/IPython/nbconvert/templates/latex/style_bw_ipython.tplx b/IPython/nbconvert/templates/latex/style_bw_ipython.tplx index 4e0ca7c..d856f5d 100644 --- a/IPython/nbconvert/templates/latex/style_bw_ipython.tplx +++ b/IPython/nbconvert/templates/latex/style_bw_ipython.tplx @@ -20,7 +20,7 @@ ((*- if type in ['text']*)) ((( add_prompt(output.text, cell, 'Out') ))) ((*- else -*)) -\verb+Out[((( cell.prompt_number )))]:+((( super() ))) +\verb+Out[((( cell.execution_count )))]:+((( super() ))) ((*- endif -*)) ((*- endfor -*)) ((* endblock execute_result *)) @@ -33,13 +33,13 @@ % Name: draw_prompt % Purpose: Renders an output/input prompt ((* macro add_prompt(text, cell, prompt) -*)) - ((*- if cell.prompt_number is defined -*)) - ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*)) + ((*- if cell.execution_count is defined -*)) + ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) ((*- else -*)) - ((*- set prompt_number = " " -*)) + ((*- set execution_count = " " -*)) ((*- endif -*)) - ((*- set indentation = " " * (prompt_number | length + 7) -*)) + ((*- set indentation = " " * (execution_count | length + 7) -*)) \begin{verbatim} -(((- text | add_prompts(first=prompt ~ '[' ~ prompt_number ~ ']: ', cont=indentation) -))) +(((- text | add_prompts(first=prompt ~ '[' ~ execution_count ~ ']: ', cont=indentation) -))) \end{verbatim} ((*- endmacro *)) diff --git a/IPython/nbconvert/templates/latex/style_ipython.tplx b/IPython/nbconvert/templates/latex/style_ipython.tplx index f067fa7..4c77319 100644 --- a/IPython/nbconvert/templates/latex/style_ipython.tplx +++ b/IPython/nbconvert/templates/latex/style_ipython.tplx @@ -33,7 +33,7 @@ ((*- if type in ['text']*)) ((( add_prompt(output.text | escape_latex, cell, 'Out', 'outcolor') ))) ((* else -*)) -\texttt{\color{outcolor}Out[{\color{outcolor}((( cell.prompt_number )))}]:}((( super() ))) +\texttt{\color{outcolor}Out[{\color{outcolor}((( cell.execution_count )))}]:}((( super() ))) ((*- endif -*)) ((*- endfor -*)) ((* endblock execute_result *)) @@ -46,13 +46,13 @@ % Name: draw_prompt % Purpose: Renders an output/input prompt ((* macro add_prompt(text, cell, prompt, prompt_color) -*)) - ((*- if cell.prompt_number is defined -*)) - ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*)) + ((*- if cell.execution_count is defined -*)) + ((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*)) ((*- else -*)) - ((*- set prompt_number = " " -*)) + ((*- set execution_count = " " -*)) ((*- endif -*)) - ((*- set indention = " " * (prompt_number | length + 7) -*)) + ((*- set indention = " " * (execution_count | length + 7) -*)) \begin{Verbatim}[commandchars=\\\{\}] -((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ prompt_number ~ '}]:} ', cont=indention) ))) +((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) ))) \end{Verbatim} ((*- endmacro *)) diff --git a/IPython/nbconvert/templates/python.tpl b/IPython/nbconvert/templates/python.tpl index 11449ba..706ba6e 100644 --- a/IPython/nbconvert/templates/python.tpl +++ b/IPython/nbconvert/templates/python.tpl @@ -5,7 +5,7 @@ {% endblock header %} {% block in_prompt %} -# In[{{ cell.prompt_number if cell.prompt_number else ' ' }}]: +# In[{{ cell.execution_count if cell.execution_count else ' ' }}]: {% endblock in_prompt %} {% block input %} diff --git a/IPython/nbconvert/tests/files/notebook1.ipynb b/IPython/nbconvert/tests/files/notebook1.ipynb index 41693a1..f74d0a6 100644 --- a/IPython/nbconvert/tests/files/notebook1.ipynb +++ b/IPython/nbconvert/tests/files/notebook1.ipynb @@ -17,11 +17,11 @@ }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 2, "source": [ "from sympy import init_printing\n", "from sympy import *\n", @@ -37,11 +37,11 @@ }, { "cell_type": "code", + "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 4, "source": [ "x,y,z = symbols('x y z')" ] @@ -55,15 +55,16 @@ }, { "cell_type": "code", + "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 6, "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKMAAAAZBAMAAACvE4OgAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEHarIkSJZt3NVLsy\nme8Q6PJIAAACz0lEQVRIDa1UTWjUQBT+ZpvdzW7TGlrxItjYSg/C6vbiDwjmoCgUpHioPYhdqig9\nFJYiPYmW4klB14NgFGnw4EHpj7UgUtTFXhSEBgVBxIOFggWVrrUqiMY3mZkkLNIK7oN575vvvfky\n8yYJIGzgkSlRrULKrivVSkvq6LbxtcaSjV3aSo0lgWyl5pK69V+SRlEsPxNTGYhhDrV3M2Ue2etc\nEDmuMmM+IjolrCuHXNoLoQDNSAXdzbjsfFVKTY1vCgFXFIxenG4cFSSzRewAPnN0FugXjPDr45MQ\nJwoKtitgXL9zT+CsJeIHYG+Z4H1gwhRU4G/FcAQbbYU3KdDo+0sCK8lRU0guA72uKqMYk9RehHxP\niDIu0NS2v90KGShJYi7T7tgvkrQ2vIT2XtRISWNra6lzGc8/PW3ji4PL7Vmge095YIX0iB71NCaZ\n5N3XyM0VCuNIyFNIyY3AMG/KDUvjn90DGmwq9wpIl5AyU5WsTYy0aJf6JFGB5An3Der5jExKHjNR\n4JKPge/EXqDBoOXpkxkmkJHFfAFRVhDIveWA0S57N2Me6yw+DSX1n1uCq3sIfCF2IcjNkjeWyKli\nginHubboOB4vSNAjyaiXE26ygrkyTfod55Lj3CTE+n2P73ImJpnk6wJJKjYJSwt3OQbNJu4icM5s\nKGGbzMuD70N6JSbJD44x7pLDyJrbkfiLpOEhYVMJSVEj83x5YFLyNrAzJsmvJ+uhLrieXvcJDshy\nHtQuD54c2IWWEnSXfUTDZJJfAjcpOW5imp9aHvw4ZZ4NDV4FGjw0tzadKgbFwinJUd//AT0P1tdW\nBtuRU39oKdk9ONQ163fM+nvu/s4D/FX30otdQIZGlSnJKpq6KUxKVqV1WxGHFIhishjhEO1Gi3r4\nkZCMg+hH1henV8EjmFoly1PTMs/Uadaox+FceY2STpmvt9co/Pe0Jvt1GvgDK/Osw/4jQ4wAAAAA\nSUVORK5CYII=\n", "metadata": {}, "output_type": "execute_result", - "prompt_number": 6, "text/latex": [ "$$x^{2} + 2.0 y + \\sin{\\left (z \\right )}$$" ], @@ -73,22 +74,22 @@ ] } ], - "prompt_number": 6, "source": [ "e = x**2 + 2.0*y + sin(z); e" ] }, { "cell_type": "code", + "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 7, "image/png": "iVBORw0KGgoAAAANSUhEUgAAABQAAAAOBAMAAADd6iHDAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAIpm7MhCriUTv3c12\nVGZoascqAAAAgElEQVQIHWNgVDJ2YICAMAb2H1BmKgPDTChzFgNDvgOEvT8AzgQKrA9gPZPYUwNk\ncXxnCGd4dWA1kMllwFDKUB9wEchUZmAIYNgMZDDwJIDIPyDiEgOjAAPLFwZWBhYFBh6BqzwfGI4y\nSJUXZXH8Zf7A+IBh////v1hzjh5/xwAAW80hUDE8HYkAAAAASUVORK5CYII=\n", "metadata": {}, "output_type": "execute_result", - "prompt_number": 7, "text/latex": [ "$$2 x$$" ], @@ -97,22 +98,22 @@ ] } ], - "prompt_number": 7, "source": [ "diff(e, x)" ] }, { "cell_type": "code", + "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 8, "image/png": "iVBORw0KGgoAAAANSUhEUgAAALsAAAAZBAMAAACbakK8AAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAEHarIkSJZt3NVLsy\nme8Q6PJIAAADAklEQVRIDbVVS2gTURQ90/wmk0k6tCJCsR1SKShIsxE3CgNWBKUxq9qFmqFqShfF\nUKQrkaDiF0pcCKYgBBcuBLV+wIWKARe6kQ4UhNKKWdiF4KIptmA/xPvmzZuMxdYUzIPcd+655568\nvLlJAL6G32oOasQWNHz5Rvg6nrKh/mygfSzlX2ygPaBUGmov6//NXs1yq4sex2EPrsHemTd2snNg\ntkb+Cx1zBL6SqwxZLvQAKYHzKZaPY4fh4TeHd0S5Nox9OClItm/jiU9DrEwwVEawpiVis9VkimqX\nAOr4o2cCs/0BT2I5+FYJRhJbePQxgzcD7QLEqtV5gdnu2Icr3L45gcCyt74Z7neL4SLQ0nm4S+dM\nYCz1gSPHnhKZDWyHhcCCNKwjqaF/TkwGl0L6nClie/wc1D1xdoNsSLhT0IJkhi7Lzr22xb8keE/N\nPm0Sc9yEuhRUyuiG9HzvFNeImCyq39SriOhtQI7IV/TiTqE8glqwohjE0NJwiANxOZTdZoxtfzSa\nx2tI8DtHcKQoQFmV6f1XT2swibxFL+6k5EgenhBCqKLTPX3ULnaYdDlaTMcCSd8zuXTvBq2bJUJr\nlE4WgSV5ZRdBzLFgO6nzhJp1ltvrlB2HCoWxQuG+jTvt2GxBWUZaU2mMApZNuSHA3vJpCliRhqqs\nZtvbTrb9ZIk+i70Ut1OcnpgeKskTCFUwjaYy8Jhr3eiefq0HIfa7yC6HOwVyULRuNDn21JngbcL+\nE8A+MNnSxb+w59+Cj2tELJBbjEZr8SGwn0j2aLkTPdp08R2OcKV6fXB3ikPH3n8tM5WTfrETtZcw\ng3QWH0dH7nKNiMkszqo/EDafaHhJ5Bm6ee4UtdAabxnMcmUUl0SnYx+uVqs5XAGN9QGgdeCrASv0\n3TmCsJcOdhnozexD38goK9HXynEKr1OKDs9guhQD039kGySyIQpJAdbvJ9YTlPvyUl3/aLUf34G/\nuGxIyXpE37DoLbAHwJaU53t9MRCfrU8o/k4iRn36Lar8Wd5wAfgN4R6xelyy/ssAAAAASUVORK5C\nYII=\n", "metadata": {}, "output_type": "execute_result", - "prompt_number": 8, "text/latex": [ "$$x^{2} z + 2.0 y z - \\cos{\\left (z \\right )}$$" ], @@ -122,18 +123,17 @@ ] } ], - "prompt_number": 8, "source": [ "integrate(e, z)" ] }, { "cell_type": "code", + "execution_count": null, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": null, "source": [] } ], diff --git a/IPython/nbconvert/tests/files/notebook2.ipynb b/IPython/nbconvert/tests/files/notebook2.ipynb index 9e3098e..4fdba87 100644 --- a/IPython/nbconvert/tests/files/notebook2.ipynb +++ b/IPython/nbconvert/tests/files/notebook2.ipynb @@ -17,6 +17,7 @@ }, { "cell_type": "code", + "execution_count": 1, "metadata": { "collapsed": false }, @@ -28,7 +29,6 @@ "text": "module://IPython.kernel.zmq.pylab.backend_inline\n" } ], - "prompt_number": 1, "source": [ "%matplotlib inline\n", "import matplotlib\n", @@ -38,11 +38,11 @@ }, { "cell_type": "code", + "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 2, "source": [ "from IPython.display import set_matplotlib_formats\n", "set_matplotlib_formats('png', 'pdf')\n", @@ -51,31 +51,31 @@ }, { "cell_type": "code", + "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 3, "metadata": {}, "output_type": "execute_result", - "prompt_number": 3, "text/plain": [ "{matplotlib.figure.Figure: >}" ] } ], - "prompt_number": 3, "source": [ "ip.display_formatter.formatters['application/pdf'].type_printers" ] }, { "cell_type": "code", + "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 4, "source": [ "import numpy as np" ] @@ -89,62 +89,62 @@ }, { "cell_type": "code", + "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 5, "source": [ "a = np.random.uniform(size=(100,100))" ] }, { "cell_type": "code", + "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 6, "metadata": {}, "output_type": "execute_result", - "prompt_number": 6, "text/plain": [ "(100, 100)" ] } ], - "prompt_number": 6, "source": [ "a.shape" ] }, { "cell_type": "code", + "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [], - "prompt_number": 7, "source": [ "evs = np.linalg.eigvals(a)" ] }, { "cell_type": "code", + "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 8, "metadata": {}, "output_type": "execute_result", - "prompt_number": 8, "text/plain": [ "(100,)" ] } ], - "prompt_number": 8, "source": [ "evs.shape" ] @@ -166,14 +166,15 @@ }, { "cell_type": "code", + "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { + "execution_count": 9, "metadata": {}, "output_type": "execute_result", - "prompt_number": 9, "text/plain": [ "(array([97, 2, 0, 0, 0, 0, 0, 0, 0, 1]),\n", " array([ -2.59479443, 2.67371141, 7.94221725, 13.21072308,\n", @@ -192,7 +193,6 @@ ] } ], - "prompt_number": 9, "source": [ "plt.hist(evs.real)" ] diff --git a/IPython/nbformat/sign.py b/IPython/nbformat/sign.py index a8d7390..0cf61f2 100644 --- a/IPython/nbformat/sign.py +++ b/IPython/nbformat/sign.py @@ -211,7 +211,7 @@ class NotebookNotary(LoggingConfigurable): output_type = output['output_type'] if output_type in {'execute_result', 'display_data'}: # if there are any data keys not in the safe whitelist - output_keys = set(output).difference({"output_type", "prompt_number", "metadata"}) + output_keys = set(output).difference({"output_type", "execution_count", "metadata"}) if output_keys.difference(safe): return False diff --git a/IPython/nbformat/tests/test4.ipynb b/IPython/nbformat/tests/test4.ipynb index 1862a76..27f1cd8 100644 --- a/IPython/nbformat/tests/test4.ipynb +++ b/IPython/nbformat/tests/test4.ipynb @@ -52,7 +52,7 @@ ] } ], - "prompt_number": 1 + "execution_count": 1 }, { "cell_type": "heading", @@ -88,13 +88,13 @@ ], "metadata": {}, "output_type": "execute_result", - "prompt_number": 3, + "execution_count": 3, "text/plain": [ "" ] } ], - "prompt_number": 3 + "execution_count": 3 }, { "cell_type": "code", @@ -118,7 +118,7 @@ ] } ], - "prompt_number": 7 + "execution_count": 7 }, { "cell_type": "heading", @@ -143,13 +143,13 @@ "metadata": {}, "output_type": "execute_result", "image/png": "iVBORw0KGgoAAAANSUhEUgAAAggAAABDCAYAAAD5/P3lAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAAH3AAAB9wBYvxo6AAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAACAASURB\nVHic7Z15uBxF1bjfugkJhCWBsCSAJGACNg4QCI3RT1lEAVE+UEBNOmwCDcjHT1wQgU+WD3dFxA1o\nCAikAZFFVlnCjizpsCUjHQjBIAkQlpCFJGS79fvjdGf69vTsc2fuza33eeaZmeqq6jM9vZw6dc4p\nBUwC+tE+fqW1fqmRDpRSHjCggS40sBxYDCxKvL8KzNBaL21EPoPB0DPIWVY/4NlE0ffzYfhgu+Qx\nGHoy/YFjaK+CcB3QkIIAHAWs3wRZsuhUSs0CXgQeBm7UWi/spn0Z+jA5yxpEfYruqnwYllRic5a1\nMaWv8U5gaT4M19Sx396IAnZLfB/SLkEMhp5O/3YL0Av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Q0GAwGw7qC7fqjEUvKqsBzmhWd\nt05gu/5pyNoifw48J9N5PForxQeeNFMMBoPBYDD0DWL/llvK1In9jt4zCoLBYDAYDH2DePo5MwrJ\ndv0hFPwTnjBRDAaDwWAw9A3+hPgOHRPl25iK+FhsiuR4OARx0Lwf+J1REAwGg8Fg6AMEnvNklL78\nHMRRca/E5hVINNIVwI2B56z6/3ExLRI31pXNAAAAAElFTkSuQmCC\n", - "prompt_number": 6, + "execution_count": 6, "text/plain": [ "" ] } ], - "prompt_number": 6 + "execution_count": 6 } ] } diff --git a/IPython/nbformat/v4/convert.py b/IPython/nbformat/v4/convert.py index cbd1e3b..ddaac6e 100644 --- a/IPython/nbformat/v4/convert.py +++ b/IPython/nbformat/v4/convert.py @@ -75,6 +75,7 @@ def upgrade_cell(cell): code cell: - remove language metadata - cell.input -> cell.source + - cell.prompt_number -> cell.execution_count - update outputs """ cell.setdefault('metadata', NotebookNode()) @@ -82,7 +83,7 @@ def upgrade_cell(cell): cell.pop('language', '') cell.metadata.collapsed = cell.pop('collapsed') cell.source = cell.pop('input') - cell.setdefault('prompt_number', None) + cell.execution_count = cell.pop('prompt_number', None) cell.outputs = upgrade_outputs(cell.outputs) elif cell.cell_type == 'html': # Technically, this exists. It will never happen in practice. @@ -90,9 +91,18 @@ def upgrade_cell(cell): return cell def downgrade_cell(cell): + """downgrade a cell from v4 to v3 + + code cell: + - set cell.language + - cell.input <- cell.source + - cell.prompt_number <- cell.execution_count + - update outputs + """ if cell.cell_type == 'code': cell.language = 'python' cell.input = cell.pop('source', '') + cell.prompt_number = cell.pop('execution_count', None) cell.collapsed = cell.metadata.pop('collapsed', False) cell.outputs = downgrade_outputs(cell.outputs) return cell @@ -134,6 +144,7 @@ def upgrade_output(output): if output['output_type'] in {'pyout', 'display_data'}: if output['output_type'] == 'pyout': output['output_type'] = 'execute_result' + output['execution_count'] = output.pop('prompt_number', None) to_mime_key(output) to_mime_key(output.metadata) if 'application/json' in output: @@ -158,6 +169,7 @@ def downgrade_output(output): """ if output['output_type'] == 'execute_result': output['output_type'] = 'pyout' + output['prompt_number'] = output.pop('execution_count', None) if 'application/json' in output: output['application/json'] = json.dumps(output['application/json']) from_mime_key(output) diff --git a/IPython/nbformat/v4/nbbase.py b/IPython/nbformat/v4/nbbase.py index a905446..9184a36 100644 --- a/IPython/nbformat/v4/nbbase.py +++ b/IPython/nbformat/v4/nbbase.py @@ -74,7 +74,7 @@ def output_from_msg(msg): return new_output(output_type=msg_type, metadata=content['metadata'], mime_bundle=content['data'], - prompt_number=content['execution_count'], + execution_count=content['execution_count'], ) elif msg_type == 'stream': @@ -103,7 +103,7 @@ def new_code_cell(source='', **kwargs): cell.update(from_dict(kwargs)) cell.setdefault('metadata', NotebookNode()) cell.setdefault('source', '') - cell.setdefault('prompt_number', None) + cell.setdefault('execution_count', None) cell.setdefault('outputs', []) validate(cell, 'code_cell') diff --git a/IPython/nbformat/v4/nbformat.v4.schema.json b/IPython/nbformat/v4/nbformat.v4.schema.json index ace80c0..127b313 100644 --- a/IPython/nbformat/v4/nbformat.v4.schema.json +++ b/IPython/nbformat/v4/nbformat.v4.schema.json @@ -150,7 +150,7 @@ "description": "Notebook code cell.", "type": "object", "additionalProperties": false, - "required": ["cell_type", "metadata", "source", "outputs", "prompt_number"], + "required": ["cell_type", "metadata", "source", "outputs", "execution_count"], "properties": { "cell_type": { "description": "String identifying the type of cell.", @@ -179,7 +179,7 @@ "type": "array", "items": {"$ref": "#/definitions/output"} }, - "prompt_number": { + "execution_count": { "description": "The code cell's prompt number. Will be null if the cell has not been run.", "type": ["integer", "null"], "minimum": 0 @@ -199,15 +199,15 @@ "description": "Result of executing a code cell.", "type": "object", "additionalProperties": false, - "required": ["output_type", "metadata", "prompt_number"], + "required": ["output_type", "metadata", "execution_count"], "properties": { "output_type": { "description": "Type of cell output.", "enum": ["execute_result"] }, - "prompt_number": { + "execution_count": { "description": "A result's prompt number.", - "type": ["integer"], + "type": ["integer", "null"], "minimum": 0 }, "application/json": { @@ -314,7 +314,7 @@ "description": "Contents of the cell, represented as an array of lines.", "$ref": "#/definitions/misc/multiline_string" }, - "prompt_number": { + "execution_count": { "description": "The code cell's prompt number. Will be null if the cell has not been run.", "type": ["integer", "null"], "minimum": 0 diff --git a/IPython/nbformat/v4/tests/nbexamples.py b/IPython/nbformat/v4/tests/nbexamples.py index 26f833a..d03bce2 100644 --- a/IPython/nbformat/v4/tests/nbexamples.py +++ b/IPython/nbformat/v4/tests/nbexamples.py @@ -20,7 +20,7 @@ cells.append(new_markdown_cell( cells.append(new_code_cell( source='import numpy', - prompt_number=1, + execution_count=1, )) cells.append(new_markdown_cell( @@ -38,20 +38,20 @@ cells.append(new_heading_cell( cells.append(new_code_cell( source='a = numpy.random.rand(100)', - prompt_number=2, + execution_count=2, )) cells.append(new_code_cell( source='a = 10\nb = 5\n', - prompt_number=3, + execution_count=3, )) cells.append(new_code_cell( source='a = 10\nb = 5', - prompt_number=4, + execution_count=4, )) cells.append(new_code_cell( source=u'print "ünîcødé"', - prompt_number=3, + execution_count=3, outputs=[new_output( output_type=u'execute_result', mime_bundle={ @@ -66,7 +66,7 @@ cells.append(new_code_cell( }, 'application/javascript': u'var i=0;' }, - prompt_number=3 + execution_count=3 ),new_output( output_type=u'display_data', mime_bundle={ diff --git a/IPython/nbformat/v4/tests/test_nbbase.py b/IPython/nbformat/v4/tests/test_nbbase.py index 1e23241..1e6334c 100644 --- a/IPython/nbformat/v4/tests/test_nbbase.py +++ b/IPython/nbformat/v4/tests/test_nbbase.py @@ -61,7 +61,7 @@ def test_empty_stream(): nt.assert_equal(output.text, '') def test_empty_execute_result(): - output = new_output('execute_result', prompt_number=1) + output = new_output('execute_result', execution_count=1) nt.assert_equal(output.output_type, 'execute_result') mimebundle = { @@ -80,8 +80,8 @@ def test_display_data(): nt.assert_equal(output[key], expected) def test_execute_result(): - output = new_output('execute_result', mimebundle, prompt_number=10) - nt.assert_equal(output.prompt_number, 10) + output = new_output('execute_result', mimebundle, execution_count=10) + nt.assert_equal(output.execution_count, 10) for key, expected in mimebundle.items(): nt.assert_equal(output[key], expected) @@ -95,15 +95,15 @@ def test_error(): nt.assert_equal(o.traceback, [u'frame 0', u'frame 1', u'frame 2']) def test_code_cell_with_outputs(): - cell = new_code_cell(prompt_number=10, outputs=[ + cell = new_code_cell(execution_count=10, outputs=[ new_output('display_data', mimebundle), new_output('stream', text='hello'), - new_output('execute_result', mimebundle, prompt_number=10), + new_output('execute_result', mimebundle, execution_count=10), ]) - nt.assert_equal(cell.prompt_number, 10) + nt.assert_equal(cell.execution_count, 10) nt.assert_equal(len(cell.outputs), 3) er = cell.outputs[-1] - nt.assert_equal(er.prompt_number, 10) + nt.assert_equal(er.execution_count, 10) nt.assert_equal(er['output_type'], 'execute_result') def test_stream():