From 5d8fa84547c8928ba2b229b40f2358dba733b017 Mon Sep 17 00:00:00 2001 From: dgelessus <dgelessus@users.noreply.github.com> Date: Thu, 5 Jul 2018 12:03:19 +0200 Subject: [PATCH] Fix :show for animation functions with empty cells --- .../tests/AnimationFunctionTestProB2.mch | 11 ++ notebooks/tests/images/small_empty_w.gif | Bin 0 -> 139 bytes notebooks/tests/images/small_wqueen_w.gif | Bin 0 -> 387 bytes notebooks/tests/show.ipynb | 106 ++++++++++++++++++ .../prob2/jupyter/commands/ShowCommand.java | 5 +- 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 notebooks/tests/AnimationFunctionTestProB2.mch create mode 100644 notebooks/tests/images/small_empty_w.gif create mode 100644 notebooks/tests/images/small_wqueen_w.gif diff --git a/notebooks/tests/AnimationFunctionTestProB2.mch b/notebooks/tests/AnimationFunctionTestProB2.mch new file mode 100644 index 0000000..b372774 --- /dev/null +++ b/notebooks/tests/AnimationFunctionTestProB2.mch @@ -0,0 +1,11 @@ +MACHINE AnimationFunctionTestProB2 + DEFINITIONS + ANIMATION_FUNCTION0 == (1..2)*(1..2)*{0}; + ANIMATION_FUNCTION1 == x; + ANIMATION_FUNCTION2 == {(0,0,"Overview")}; + ANIMATION_IMG0 == "images/small_empty_w.gif"; + ANIMATION_IMG1 == "images/small_wqueen_w.gif" + CONSTANTS x + PROPERTIES + x = {1|->2|->1, 2|->1|->1} +END \ No newline at end of file diff --git a/notebooks/tests/images/small_empty_w.gif b/notebooks/tests/images/small_empty_w.gif new file mode 100644 index 0000000000000000000000000000000000000000..0f33c780ae8e000a17f340b75a3b90f5450f6c9c GIT binary patch literal 139 zcmZ?wbhEHb)Mn6T_`qQJ|Nnmm1_m7l1_lO@2m@1AOaIE#GW?6@Z1EDFbx)W1eCr(c zu4hj3R!v&>u6=Kw_WTmvdp{)JSH6FIu<4M{MMfK?_ESqYc3yDgzx47$=32k40eP2K vv&bKHDZ22+`TZ4(va`C)`=4xHvbFv0t@mF-<G-diCpt!WR4fl<V6X-N#cx21 literal 0 HcmV?d00001 diff --git a/notebooks/tests/images/small_wqueen_w.gif b/notebooks/tests/images/small_wqueen_w.gif new file mode 100644 index 0000000000000000000000000000000000000000..4ab932d0db4c10b71eb4d37f444c453412c0bc24 GIT binary patch literal 387 zcmZ?wbhEHb)Mn6T_{?DV|NsBp98Apq!fL8h|M#-gU2d5tx~}fPsg8~g25dkFBnZ;W z!1DjYNzc`LC7RFf{-5x|GbwY{la=cnPVHOBEzePO;FI<hrhjWV4)PTU$aHZy6hxeA zZQ8RqK;x;Zs~_K6u_cmILmu(%+*rFQAuF&V_Wm9x!|E^0z3p+*e`Y+FYA*2)bK&5x z@@{XdvuRZDc60A2Fq;%qESu5NHF?g|*0f&5>?t|@*1=2S(@Pfx*yIE+Uz%gST6J>& zvYnF@W=>qO@!)~1y=xTqA3C|Q>ge`@Q>V^sQ#ujM?<92N;H8DfO_p6)QFHdn)rXJV zpDcRzJbCNorw^XrxqEM!#Oar>UOP&PzBBB(Dg2<H=|C+rx1R+^zr17X^%sdk6>H>= z7)EH+EnqBU(r6L2h;Lo}aigOBB#q!}65;`_DpL)<ZnZhcp5`^pIP+Rhr}1(>JBQ|Z ZC${KioL7@d{1I@fB<c8a0c8dTYXIWzsPF&) literal 0 HcmV?d00001 diff --git a/notebooks/tests/show.ipynb b/notebooks/tests/show.ipynb index 75c21d1..5dacc6b 100644 --- a/notebooks/tests/show.ipynb +++ b/notebooks/tests/show.ipynb @@ -671,6 +671,112 @@ "source": [ ":show" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Empty cells are supported." + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Loaded machine: AnimationFunctionTestProB2" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":load AnimationFunctionTestProB2.mch" + ] + }, + { + "cell_type": "code", + "execution_count": 23, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Machine constants set up using operation 0: $setup_constants()" + ] + }, + "execution_count": 23, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":constants" + ] + }, + { + "cell_type": "code", + "execution_count": 24, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Machine initialised using operation 1: $initialise_machine()" + ] + }, + "execution_count": 24, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":init" + ] + }, + { + "cell_type": "code", + "execution_count": 25, + "metadata": {}, + "outputs": [ + { + "data": { + "text/markdown": [ + "<table style=\"font-family:monospace\"><tbody>\n", + "<tr>\n", + "<td style=\"padding:10px\">Overview</td>\n", + "<td style=\"padding:0px\"></td>\n", + "<td style=\"padding:0px\"></td>\n", + "</tr>\n", + "<tr>\n", + "<td style=\"padding:0px\"></td>\n", + "<td style=\"padding:0px\"></td>\n", + "<td style=\"padding:0px\"></td>\n", + "</tr>\n", + "<tr>\n", + "<td style=\"padding:0px\"></td>\n", + "<td style=\"padding:0px\"></td>\n", + "<td style=\"padding:0px\"></td>\n", + "</tr>\n", + "</tbody></table>" + ], + "text/plain": [ + "<Animation function visualisation>" + ] + }, + "execution_count": 25, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + ":show" + ] } ], "metadata": { diff --git a/src/main/java/de/prob2/jupyter/commands/ShowCommand.java b/src/main/java/de/prob2/jupyter/commands/ShowCommand.java index 7f71ce1..22daba7 100644 --- a/src/main/java/de/prob2/jupyter/commands/ShowCommand.java +++ b/src/main/java/de/prob2/jupyter/commands/ShowCommand.java @@ -99,7 +99,10 @@ public final class ShowCommand implements Command { for (final Object entry : row) { final int padding; final String contents; - if (entry instanceof Integer) { + if (entry == null) { + padding = 0; + contents = ""; + } else if (entry instanceof Integer) { padding = imagePadding; contents = String.format("", entry, images.get(entry)); } else if (entry instanceof String) { -- GitLab