diff --git a/docs/source/index.ipynb b/docs/source/index.ipynb index 65a59db..cd6ee99 100644 --- a/docs/source/index.ipynb +++ b/docs/source/index.ipynb @@ -51,7 +51,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "9240a454a1c0450eb5b5bbb8260cb74f", + "model_id": "aefbc5694c834e6c9d5d86696b28c512", "version_major": 2, "version_minor": 0 }, @@ -84,7 +84,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "dc5faebcb39a46b4bab9fe1d6ac59dd1", + "model_id": "31566bf1ca5a4481ac29df8e2af5c069", "version_major": 2, "version_minor": 0 }, @@ -134,12 +134,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "15f35d4e95474f348b8f364b5b7bdf01", + "model_id": "c55becb64db14d5fb42adf386a40d0ef", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "VBox(children=(Sheet(cells=(Cell(column_end=1, column_start=1, row_end=0, row_start=0, type='numeric', value=1…" + "VBox(children=(Sheet(cells=(Cell(column_end=1, column_start=1, row_end=0, row_start=0, type='float', value=1),…" ] }, "metadata": {}, @@ -149,9 +149,9 @@ "source": [ "import ipywidgets as widgets\n", "sheet = ipysheet.sheet(rows=3, columns=2, column_headers=False, row_headers=False)\n", - "cell_a = ipysheet.cell(0, 1, 1, label_left='a')\n", - "cell_b = ipysheet.cell(1, 1, 2, label_left='b')\n", - "cell_sum = ipysheet.cell(2, 1, 3, label_left='sum', read_only=True)\n", + "cell_a = ipysheet.cell(0, 1, 1, label_left='a', type='float')\n", + "cell_b = ipysheet.cell(1, 1, 2, label_left='b', type='float')\n", + "cell_sum = ipysheet.cell(2, 1, 3, label_left='sum', type='float', read_only=True)\n", "\n", "# create a slider linked to cell a\n", "slider = widgets.FloatSlider(min=-10, max=10, description='a')\n", @@ -184,7 +184,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "331eb1d230d04a2b9cf22ff0e7d34221", + "model_id": "b37b8eca5c8848be89723324f2d00cc9", "version_major": 2, "version_minor": 0 }, @@ -221,12 +221,12 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "ee569f56091c4b069b0ee13367c33a60", + "model_id": "6ee23e4789234a5ea9649db94c533a38", "version_major": 2, "version_minor": 0 }, "text/plain": [ - "VBox(children=(Sheet(cells=(Cell(column_end=1, column_start=1, row_end=0, row_start=0, type='numeric', value=1…" + "VBox(children=(Sheet(cells=(Cell(column_end=1, column_start=1, row_end=0, row_start=0, type='int', value=1), C…" ] }, "metadata": {}, @@ -241,7 +241,7 @@ "cell_sum = ipysheet.cell(2, 1, 3, label_left='sum', read_only=True)\n", "\n", "# create a slider linked to cell a\n", - "slider = widgets.FloatSlider(min=-10, max=10, description='a')\n", + "slider = widgets.IntSlider(min=-10, max=10, description='a')\n", "widgets.jslink((cell_a, 'value'), (slider, 'value'))\n", "\n", "@ipysheet.calculation(inputs=[cell_a, cell_b], output=cell_sum)\n", @@ -282,7 +282,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "120d773208664b28a62edb6279d39e52", + "model_id": "5329d60e41b14391a3a20b8eb324d8f7", "version_major": 2, "version_minor": 0 }, @@ -306,7 +306,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "If [flexx](http://flexx.readthedocs.io/en/stable/pyscript/index.html) is installed, Python code can be transpiled to JavaScript at runtime." + "Custom renderers can be JavaScript functions as well as Python functions that returns the cell style" ] }, { @@ -330,7 +330,7 @@ { "data": { "application/vnd.jupyter.widget-view+json": { - "model_id": "96f01acbd7054929b95d9b6a93e80ec1", + "model_id": "2c8599283f5d4347895b95d24b887d47", "version_major": 2, "version_minor": 0 }, @@ -382,76 +382,87 @@ "widgets": { "application/vnd.jupyter.widget-state+json": { "state": { - "078a93ab3a954e6e9fd0cb309683ad9a": { + "02cee59ebef44b7cabddc13e7250526c": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.4.0", + "model_name": "IntSliderModel", + "state": { + "description": "a", + "layout": "IPY_MODEL_b1c054ac2a1340fb9200c5f16af5323e", + "max": 10, + "min": -10, + "style": "IPY_MODEL_d11ccb31354249589dd350497d7c0779", + "value": 1 + } + }, + "136070030dee469a91c0b5f86f8a744b": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", + "state": {} + }, + "1690d5f265784d0094c7492f9c9436d3": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "column_end": 3, - "column_start": 0, - "renderer": "negative_transpiled", + "type": "float", + "value": 2 + } + }, + "1f20ca8577d64f409dda17d6c6f0c303": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "CellRangeModel", + "state": { + "_view_module": null, + "_view_module_version": "", + "column_end": 2, + "column_start": 2, "row_end": 2, - "row_start": 0, - "squeeze_column": false, - "squeeze_row": false, - "type": "numeric", - "value": [ - [ - -4, - -3, - -1, - 9 - ], - [ - -1, - 9, - -6, - 9 - ], - [ - -9, - 9, - -1, - -9 - ] - ] + "row_start": 2, + "type": "float", + "value": 42 } }, - "120d773208664b28a62edb6279d39e52": { + "2911b30eab6941e7beb2ed6060e96c99": { "model_module": "ipysheet", "model_module_version": "~0.4.1", - "model_name": "SheetModel", + "model_name": "CellRangeModel", "state": { - "cells": [ - "IPY_MODEL_1e98bbb1a81b414691f47a167cf7d12f" - ], - "layout": "IPY_MODEL_c1dbe91c4db244ceb857f8ce9401cc6a" + "_view_module": null, + "_view_module_version": "", + "type": "int", + "value": 2 } }, - "155748346e0a4bfbaa4a6cdd209755f5": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", + "2c8599283f5d4347895b95d24b887d47": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "SheetModel", "state": { - "height": "auto", - "width": "auto" + "cells": [ + "IPY_MODEL_4855a741aca94869be3e526e3cdc5a25" + ], + "layout": "IPY_MODEL_5e79886cd1b844c28b880b373887d745" } }, - "15f35d4e95474f348b8f364b5b7bdf01": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "1.4.0", - "model_name": "VBoxModel", + "31566bf1ca5a4481ac29df8e2af5c069": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "SheetModel", "state": { - "children": [ - "IPY_MODEL_9ed9cb9f61294fb0b9a97848d193c1db", - "IPY_MODEL_3a02c16fe28c4f269b15eea3914114b6" + "cells": [ + "IPY_MODEL_ba619725ce96426ead50b7d9321b08f6", + "IPY_MODEL_96446474f82e4e6897772b1550e865d2", + "IPY_MODEL_1f20ca8577d64f409dda17d6c6f0c303" ], - "layout": "IPY_MODEL_418d6f810c4c49e18b5310d205dba504" + "layout": "IPY_MODEL_3bee1706c9d6466191ddc6b9eeaaec12" } }, - "1e98bbb1a81b414691f47a167cf7d12f": { + "360ed33dd47241bebf26dd5366c808e5": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -465,50 +476,63 @@ "row_start": 0, "squeeze_column": false, "squeeze_row": false, - "type": "numeric", + "type": "int", "value": [ [ - 10, - 3, - 1, - 9 + 8, + 0, + -3, + 0 ], [ - -5, - 7, + -1, + -7, -3, 7 ], [ - 1, - 10, - -3, - 1 + -7, + -6, + 8, + -1 ] ] } }, - "1f92a18646e94c68b9424fdbc6bff1f4": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", + "3633f20c839f443d9b0ebfb984473975": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.4.0", + "model_name": "LinkModel", "state": { - "height": "auto", - "width": "auto" + "source": [ + "IPY_MODEL_60fbd1008b794878947bf8d72afa9935", + "value" + ], + "target": [ + "IPY_MODEL_e8882d237be147c190d87e8fb3564121", + "value" + ] } }, - "260d446590784781b0ea1079242ee098": { + "3b08b671e1014d3f99544a4b180cbce4": { "model_module": "ipysheet", "model_module_version": "~0.4.1", - "model_name": "RendererModel", + "model_name": "CellRangeModel", "state": { - "_view_module": "ipysheet", - "_view_module_version": "~0.4.1", - "code": "\nfunction() {\n var the_renderer;\n the_renderer = function flx_the_renderer (value) {\n return ({backgroundColor: ((value < 0))? (\"orange\") : (\"\")});\n };\n\n return the_renderer\n\n}()\n", - "name": "negative_transpiled" + "_view_module": null, + "_view_module_version": "", + "column_end": 0, + "column_start": 0, + "row_end": 2, + "row_start": 2, + "style": { + "fontWeight": "bold" + }, + "type": "text", + "value": "sum" } }, - "2733376ab7f14d4dbe107138963c2214": { + "3bee1706c9d6466191ddc6b9eeaaec12": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.1.0", "model_name": "LayoutModel", @@ -517,63 +541,92 @@ "width": "auto" } }, - "2ae00660ce774f22ab24da60c086fc0e": { + "4855a741aca94869be3e526e3cdc5a25": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "read_only": true, + "column_end": 3, + "column_start": 0, + "renderer": "negative_transpiled", "row_end": 2, - "row_start": 2, - "type": "numeric", - "value": 3 + "row_start": 0, + "squeeze_column": false, + "squeeze_row": false, + "type": "int", + "value": [ + [ + 1, + 2, + -4, + 10 + ], + [ + -3, + 5, + 4, + 10 + ], + [ + 4, + 8, + -4, + 7 + ] + ] } }, - "2c4fa222b61a4d518c6a40c92b040f11": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "1.4.0", - "model_name": "FloatSliderModel", + "51ebae69061f4846816261b35ae62b32": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "SheetModel", "state": { - "description": "a", - "layout": "IPY_MODEL_d91e09a8701e4888a34550824908ab8c", - "max": 10, - "min": -10, - "step": 0.1, - "style": "IPY_MODEL_714d355de86d4881b34fb804fe770008", - "value": 1 + "cells": [ + "IPY_MODEL_60fbd1008b794878947bf8d72afa9935", + "IPY_MODEL_f1ae488f0a9245938c107a68dcf959bd", + "IPY_MODEL_1690d5f265784d0094c7492f9c9436d3", + "IPY_MODEL_67a73ba0f1fd4a37a880c53e112881f2", + "IPY_MODEL_6123f60effa2498a86dd1c84adee9427", + "IPY_MODEL_3b08b671e1014d3f99544a4b180cbce4" + ], + "column_headers": false, + "columns": 2, + "layout": "IPY_MODEL_a85ee3116fdc4c698343192143b2b421", + "row_headers": false } }, - "331eb1d230d04a2b9cf22ff0e7d34221": { + "5329d60e41b14391a3a20b8eb324d8f7": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "SheetModel", "state": { "cells": [ - "IPY_MODEL_69590c5315e34d6e884458c4ed1271ec", - "IPY_MODEL_e93dd6c4fb4240478c3cbb535bf3d478", - "IPY_MODEL_a8546559d0c544af840ac5212b3fe9fd" + "IPY_MODEL_360ed33dd47241bebf26dd5366c808e5" ], - "layout": "IPY_MODEL_41c13784e4714966adcb8ae3d44178db", - "rows": 5 + "layout": "IPY_MODEL_b3cdf33d93784df695183e0fe55efe3e" } }, - "3a02c16fe28c4f269b15eea3914114b6": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "1.4.0", - "model_name": "FloatSliderModel", + "54da9a994bfb4769aa3d680fa70d34ac": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "CellRangeModel", "state": { - "description": "a", - "layout": "IPY_MODEL_7a9609f5eb3d444485201b9424cc45eb", - "max": 10, - "min": -10, - "step": 0.1, - "style": "IPY_MODEL_3f8af119d77d4a508b090398dff5a8fd", - "value": 1 + "_view_module": null, + "_view_module_version": "", + "column_end": 0, + "column_start": 0, + "row_end": 2, + "row_start": 2, + "style": { + "fontWeight": "bold" + }, + "type": "text", + "value": "sum" } }, - "3f8af119d77d4a508b090398dff5a8fd": { + "567b271aa9b54533a75d50c63da111f5": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.4.0", "model_name": "SliderStyleModel", @@ -581,33 +634,28 @@ "description_width": "" } }, - "402e691da01e4dd2af5ef3f97e91d0a5": { + "5902bfe2b33b44dda27c63383745a6b8": { "model_module": "ipysheet", "model_module_version": "~0.4.1", - "model_name": "RendererModel", - "state": { - "_view_module": "ipysheet", - "_view_module_version": "~0.4.1", - "code": "function (value) {\n return {\n backgroundColor: value < 0 ? 'red' : 'green'\n };\n}\n", - "name": "negative" - } - }, - "418d6f810c4c49e18b5310d205dba504": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", - "state": {} - }, - "41c13784e4714966adcb8ae3d44178db": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", + "model_name": "CellRangeModel", "state": { - "height": "auto", - "width": "auto" + "_view_module": null, + "_view_module_version": "", + "row_end": 4, + "squeeze_row": false, + "style": { + "backgroundColor": "green" + }, + "type": "text", + "value": [ + "a", + "b", + "c", + "d" + ] } }, - "43172e8bacd645bca0c4289ea6de15f4": { + "5e79886cd1b844c28b880b373887d745": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.1.0", "model_name": "LayoutModel", @@ -616,37 +664,20 @@ "width": "auto" } }, - "535bb3899bcf426389df0a9ed97c4e3d": { + "60fbd1008b794878947bf8d72afa9935": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "type": "numeric", - "value": 2 - } - }, - "593c55e36b1e449fba9193764c1b00ce": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "SheetModel", - "state": { - "cells": [ - "IPY_MODEL_b1fde7c30c954ad8b0198bc66b28a121", - "IPY_MODEL_aa085b146c2241c0929ced4f8d0b8cc3", - "IPY_MODEL_8a9a9bdb7f104943b53b06d9943c3a45", - "IPY_MODEL_ba0c6a1a21624d82aa23f75afdc7666c", - "IPY_MODEL_2ae00660ce774f22ab24da60c086fc0e", - "IPY_MODEL_90541fb1218742e4bcacfe67b9ee4180" - ], - "column_headers": false, - "columns": 2, - "layout": "IPY_MODEL_43172e8bacd645bca0c4289ea6de15f4", - "row_headers": false + "row_end": 0, + "row_start": 0, + "type": "float", + "value": 1 } }, - "6476661bcf82408dbc65f220605068dc": { + "6123f60effa2498a86dd1c84adee9427": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -656,105 +687,70 @@ "read_only": true, "row_end": 2, "row_start": 2, - "type": "numeric", + "type": "float", "value": 3 } }, - "69590c5315e34d6e884458c4ed1271ec": { + "67a73ba0f1fd4a37a880c53e112881f2": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "column_end": 3, + "column_end": 0, "column_start": 0, - "row_end": 0, - "row_start": 0, - "squeeze_column": false, "style": { - "backgroundColor": "red" + "fontWeight": "bold" }, - "type": "numeric", - "value": [ - 0, - 1, - 2, - 3 - ] - } - }, - "7096b52219184bbb99b0e8c2a834fcbb": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "CellRangeModel", - "state": { - "_view_module": null, - "_view_module_version": "", - "column_end": 0, - "column_start": 0, - "row_end": 0, - "row_start": 0, "type": "text", - "value": "Hello" + "value": "b" } }, - "714d355de86d4881b34fb804fe770008": { + "6ee23e4789234a5ea9649db94c533a38": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.4.0", - "model_name": "SliderStyleModel", + "model_name": "VBoxModel", "state": { - "description_width": "" + "children": [ + "IPY_MODEL_983bf4f9d45c4e3281bb704cbf3c1491", + "IPY_MODEL_02cee59ebef44b7cabddc13e7250526c" + ], + "layout": "IPY_MODEL_77f6caae156442808f7121e594c518af" } }, - "7a9609f5eb3d444485201b9424cc45eb": { + "77f6caae156442808f7121e594c518af": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.1.0", "model_name": "LayoutModel", "state": {} }, - "7e19d6589d564fcca765396f70c0b799": { + "81a7727c6d0b456894342fa8b619a56a": { "model_module": "ipysheet", "model_module_version": "~0.4.1", - "model_name": "CellRangeModel", - "state": { - "_view_module": null, - "_view_module_version": "", - "column_end": 0, - "column_start": 0, - "row_end": 2, - "row_start": 2, - "type": "text", - "value": "World" - } - }, - "85e2ce2478f04c629dda0e83829aab0d": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "1.4.0", - "model_name": "LinkModel", + "model_name": "RendererModel", "state": { - "source": [ - "IPY_MODEL_f0faccde3e71426a96bf6a454802b5dd", - "value" - ], - "target": [ - "IPY_MODEL_3a02c16fe28c4f269b15eea3914114b6", - "value" - ] + "_view_module": "ipysheet", + "_view_module_version": "~0.4.1", + "code": "function (value) {\n return {\n backgroundColor: value < 0 ? 'red' : 'green'\n };\n}\n", + "name": "negative" } }, - "8a9a9bdb7f104943b53b06d9943c3a45": { + "86e297200d5c4ab6a6576545c6bafea5": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "type": "numeric", - "value": 2 + "read_only": true, + "row_end": 2, + "row_start": 2, + "type": "int", + "value": 3 } }, - "90541fb1218742e4bcacfe67b9ee4180": { + "96446474f82e4e6897772b1550e865d2": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -765,72 +761,98 @@ "column_start": 0, "row_end": 2, "row_start": 2, - "style": { - "fontWeight": "bold" - }, "type": "text", - "value": "sum" + "value": "World" } }, - "9240a454a1c0450eb5b5bbb8260cb74f": { + "983bf4f9d45c4e3281bb704cbf3c1491": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "SheetModel", "state": { - "columns": 5, - "layout": "IPY_MODEL_2733376ab7f14d4dbe107138963c2214", - "rows": 5 + "cells": [ + "IPY_MODEL_d46df184a60c4a67a4e6147de0d75f54", + "IPY_MODEL_e665dc60260d43029ff6c9f009bc71ca", + "IPY_MODEL_2911b30eab6941e7beb2ed6060e96c99", + "IPY_MODEL_bcbafc1b29b749ba809ce88c98e382e7", + "IPY_MODEL_86e297200d5c4ab6a6576545c6bafea5", + "IPY_MODEL_54da9a994bfb4769aa3d680fa70d34ac" + ], + "column_headers": false, + "columns": 2, + "layout": "IPY_MODEL_e755bf96293344d6b58f964663157da8", + "row_headers": false } }, - "96f01acbd7054929b95d9b6a93e80ec1": { + "a85ee3116fdc4c698343192143b2b421": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", + "state": { + "height": "auto", + "width": "auto" + } + }, + "ad9f1c5a27414203996ec7d5d9ae696b": { + "model_module": "ipysheet", + "model_module_version": "~0.4.1", + "model_name": "RendererModel", + "state": { + "_view_module": "ipysheet", + "_view_module_version": "~0.4.1", + "code": "\nfunction() {\n var the_renderer;\n the_renderer = function flx_the_renderer (value) {\n return ({backgroundColor: ((value < 0))? (\"orange\") : (\"\")});\n };\n\n return the_renderer\n\n}()\n", + "name": "negative_transpiled" + } + }, + "aefbc5694c834e6c9d5d86696b28c512": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "SheetModel", "state": { - "cells": [ - "IPY_MODEL_078a93ab3a954e6e9fd0cb309683ad9a" - ], - "layout": "IPY_MODEL_bfa652564a4041be993c7b9861a94fa2" + "columns": 5, + "layout": "IPY_MODEL_d377c608b55842f4b97ee5ed2ac0815c", + "rows": 5 } }, - "9ed9cb9f61294fb0b9a97848d193c1db": { + "b1c054ac2a1340fb9200c5f16af5323e": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", + "state": {} + }, + "b33250fe84c84ed4adc564398824e817": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", + "state": { + "height": "auto", + "width": "auto" + } + }, + "b37b8eca5c8848be89723324f2d00cc9": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "SheetModel", "state": { "cells": [ - "IPY_MODEL_f0faccde3e71426a96bf6a454802b5dd", - "IPY_MODEL_bf3490b9d1f948c3ab227bc5d8bb5d23", - "IPY_MODEL_535bb3899bcf426389df0a9ed97c4e3d", - "IPY_MODEL_d860be8268d9499ba20855a4d1eaac84", - "IPY_MODEL_6476661bcf82408dbc65f220605068dc", - "IPY_MODEL_a6ee3cb412cf4bd3b88fcc68accb532e" + "IPY_MODEL_cf3f654a13ac44a480f482b9c7255d5b", + "IPY_MODEL_5902bfe2b33b44dda27c63383745a6b8", + "IPY_MODEL_b5f0019090854f9eb8b09fc43c10f91a" ], - "column_headers": false, - "columns": 2, - "layout": "IPY_MODEL_1f92a18646e94c68b9424fdbc6bff1f4", - "row_headers": false + "layout": "IPY_MODEL_b33250fe84c84ed4adc564398824e817", + "rows": 5 } }, - "a6ee3cb412cf4bd3b88fcc68accb532e": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "CellRangeModel", + "b3cdf33d93784df695183e0fe55efe3e": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", "state": { - "_view_module": null, - "_view_module_version": "", - "column_end": 0, - "column_start": 0, - "row_end": 2, - "row_start": 2, - "style": { - "fontWeight": "bold" - }, - "type": "text", - "value": "sum" + "height": "auto", + "width": "auto" } }, - "a8546559d0c544af840ac5212b3fe9fd": { + "b5f0019090854f9eb8b09fc43c10f91a": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -862,7 +884,7 @@ ] } }, - "aa085b146c2241c0929ced4f8d0b8cc3": { + "ba619725ce96426ead50b7d9321b08f6": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -873,42 +895,11 @@ "column_start": 0, "row_end": 0, "row_start": 0, - "style": { - "fontWeight": "bold" - }, "type": "text", - "value": "a" - } - }, - "ae4747feb81646a8bf093db1b62ed0a8": { - "model_module": "@jupyter-widgets/controls", - "model_module_version": "1.4.0", - "model_name": "LinkModel", - "state": { - "source": [ - "IPY_MODEL_b1fde7c30c954ad8b0198bc66b28a121", - "value" - ], - "target": [ - "IPY_MODEL_2c4fa222b61a4d518c6a40c92b040f11", - "value" - ] - } - }, - "b1fde7c30c954ad8b0198bc66b28a121": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "CellRangeModel", - "state": { - "_view_module": null, - "_view_module_version": "", - "row_end": 0, - "row_start": 0, - "type": "numeric", - "value": 1 + "value": "Hello" } }, - "ba0c6a1a21624d82aa23f75afdc7666c": { + "bcbafc1b29b749ba809ce88c98e382e7": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -924,34 +915,57 @@ "value": "b" } }, - "bf3490b9d1f948c3ab227bc5d8bb5d23": { + "bf2fa263e1044e1eb082865be4d25eca": { + "model_module": "@jupyter-widgets/base", + "model_module_version": "1.1.0", + "model_name": "LayoutModel", + "state": {} + }, + "c55becb64db14d5fb42adf386a40d0ef": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.4.0", + "model_name": "VBoxModel", + "state": { + "children": [ + "IPY_MODEL_51ebae69061f4846816261b35ae62b32", + "IPY_MODEL_e8882d237be147c190d87e8fb3564121" + ], + "layout": "IPY_MODEL_bf2fa263e1044e1eb082865be4d25eca" + } + }, + "cf3f654a13ac44a480f482b9c7255d5b": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "column_end": 0, + "column_end": 3, "column_start": 0, "row_end": 0, "row_start": 0, + "squeeze_column": false, "style": { - "fontWeight": "bold" + "backgroundColor": "red" }, - "type": "text", - "value": "a" + "type": "int", + "value": [ + 0, + 1, + 2, + 3 + ] } }, - "bfa652564a4041be993c7b9861a94fa2": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", + "d11ccb31354249589dd350497d7c0779": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.4.0", + "model_name": "SliderStyleModel", "state": { - "height": "auto", - "width": "auto" + "description_width": "" } }, - "c1dbe91c4db244ceb857f8ce9401cc6a": { + "d377c608b55842f4b97ee5ed2ac0815c": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.1.0", "model_name": "LayoutModel", @@ -960,22 +974,20 @@ "width": "auto" } }, - "c5cb3daa341842a8a77d33bdaed0d179": { + "d46df184a60c4a67a4e6147de0d75f54": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", - "column_end": 2, - "column_start": 2, - "row_end": 2, - "row_start": 2, - "type": "numeric", - "value": 42 + "row_end": 0, + "row_start": 0, + "type": "int", + "value": 1 } }, - "d860be8268d9499ba20855a4d1eaac84": { + "e665dc60260d43029ff6c9f009bc71ca": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", @@ -984,82 +996,69 @@ "_view_module_version": "", "column_end": 0, "column_start": 0, + "row_end": 0, + "row_start": 0, "style": { "fontWeight": "bold" }, "type": "text", - "value": "b" + "value": "a" } }, - "d91e09a8701e4888a34550824908ab8c": { + "e755bf96293344d6b58f964663157da8": { "model_module": "@jupyter-widgets/base", "model_module_version": "1.1.0", "model_name": "LayoutModel", - "state": {} - }, - "dc5faebcb39a46b4bab9fe1d6ac59dd1": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "SheetModel", "state": { - "cells": [ - "IPY_MODEL_7096b52219184bbb99b0e8c2a834fcbb", - "IPY_MODEL_7e19d6589d564fcca765396f70c0b799", - "IPY_MODEL_c5cb3daa341842a8a77d33bdaed0d179" - ], - "layout": "IPY_MODEL_155748346e0a4bfbaa4a6cdd209755f5" + "height": "auto", + "width": "auto" } }, - "e93dd6c4fb4240478c3cbb535bf3d478": { - "model_module": "ipysheet", - "model_module_version": "~0.4.1", - "model_name": "CellRangeModel", + "e8882d237be147c190d87e8fb3564121": { + "model_module": "@jupyter-widgets/controls", + "model_module_version": "1.4.0", + "model_name": "FloatSliderModel", "state": { - "_view_module": null, - "_view_module_version": "", - "row_end": 4, - "squeeze_row": false, - "style": { - "backgroundColor": "green" - }, - "type": "text", - "value": [ - "a", - "b", - "c", - "d" - ] + "description": "a", + "layout": "IPY_MODEL_136070030dee469a91c0b5f86f8a744b", + "max": 10, + "min": -10, + "step": 0.1, + "style": "IPY_MODEL_567b271aa9b54533a75d50c63da111f5", + "value": 1 } }, - "ee569f56091c4b069b0ee13367c33a60": { + "eeed7f4571194d48a2af3c241722653a": { "model_module": "@jupyter-widgets/controls", "model_module_version": "1.4.0", - "model_name": "VBoxModel", + "model_name": "LinkModel", "state": { - "children": [ - "IPY_MODEL_593c55e36b1e449fba9193764c1b00ce", - "IPY_MODEL_2c4fa222b61a4d518c6a40c92b040f11" + "source": [ + "IPY_MODEL_d46df184a60c4a67a4e6147de0d75f54", + "value" ], - "layout": "IPY_MODEL_f099a6b43c1c4a009f8b06dbb068c287" + "target": [ + "IPY_MODEL_02cee59ebef44b7cabddc13e7250526c", + "value" + ] } }, - "f099a6b43c1c4a009f8b06dbb068c287": { - "model_module": "@jupyter-widgets/base", - "model_module_version": "1.1.0", - "model_name": "LayoutModel", - "state": {} - }, - "f0faccde3e71426a96bf6a454802b5dd": { + "f1ae488f0a9245938c107a68dcf959bd": { "model_module": "ipysheet", "model_module_version": "~0.4.1", "model_name": "CellRangeModel", "state": { "_view_module": null, "_view_module_version": "", + "column_end": 0, + "column_start": 0, "row_end": 0, "row_start": 0, - "type": "numeric", - "value": 1 + "style": { + "fontWeight": "bold" + }, + "type": "text", + "value": "a" } } }, diff --git a/examples/format.ipynb b/examples/format.ipynb index 5bf56d0..3820ef5 100644 --- a/examples/format.ipynb +++ b/examples/format.ipynb @@ -16,14 +16,21 @@ "outputs": [], "source": [ "sheet = ipysheet.sheet()\n", - "cell0 = ipysheet.cell(0, 0, 0, numeric_format='0.0', type='numeric')\n", + "cell0 = ipysheet.cell(0, 0, 0, numeric_format='.2', type='float')\n", "cell1 = ipysheet.cell(1, 0, \"Hello\", type='text')\n", - "cell2 = ipysheet.cell(0, 1, 0.1, numeric_format='0.000', type='numeric')\n", - "cell3 = ipysheet.cell(1, 1, 15.9, numeric_format='0.00', type='numeric')\n", + "cell2 = ipysheet.cell(0, 1, 10000000000, numeric_format='e', type='int')\n", + "cell3 = ipysheet.cell(1, 1, 5.91234314, numeric_format='.4', type='float')\n", "cell4 = ipysheet.cell(2, 2, \"02/14/2019\", date_format='MM/DD/YYYY', type='date')\n", "\n", "sheet" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/ipysheet/easy.py b/ipysheet/easy.py index 4f2f4a3..f16e47d 100644 --- a/ipysheet/easy.py +++ b/ipysheet/easy.py @@ -5,7 +5,6 @@ """ __all__ = ['sheet', 'current', 'cell', 'calculation', 'row', 'column', 'cell_range', 'hold_cells', 'renderer'] -import numbers import six from contextlib import contextmanager @@ -23,15 +22,16 @@ _common_doc = { 'args': """ - type (string): Type of cell, options are: text, numeric, checkbox, dropdown, numeric, date, widget. + type (string): Type of cell, options are: text, int, float, checkbox, dropdown, date, widget. If type is None, the type is inferred from the type of the value being passed, - numeric (float or int type), boolean (bool type), widget (any widget object), or else text. + float, int, boolean (bool type), widget (any widget object), or else text. When choice is given the type will be assumed to be dropdown. The types refer (currently) to the handsontable types: https://handsontable.com/docs/6.2.2/demo-custom-renderers.html color (string): The text color in the cell background_color (string): The background color in the cell read_only (bool): Whether the cell is editable or not - numeric_format (string): Numbers format + numeric_format (ipywidgets.widgets.trait_types.NumberFormat): Numbers format, default is 'd' for int cells, '.2f' for + float cells date_format (string): Dates format time_format (string): Time format renderer (string): Renderer name to use for the cell @@ -95,7 +95,7 @@ def current(): @doc_subst(_common_doc) def cell(row, column, value=0., type=None, color=None, background_color=None, font_style=None, font_weight=None, style=None, label_left=None, choice=None, - read_only=False, numeric_format='0.000', date_format='YYYY/MM/DD', renderer=None, **kwargs): + read_only=False, numeric_format=None, date_format='YYYY/MM/DD', renderer=None, **kwargs): """Adds a new ``Cell`` widget to the current ``Sheet`` Args: @@ -111,7 +111,8 @@ def cell(row, column, value=0., type=None, color=None, background_color=None, >>> from ipysheet import sheet, cell >>> >>> s1 = sheet() - >>> cell(0, 0, 36.) # The Cell type will be 'numeric' + >>> cell(0, 0, 36) # The Cell type will be 'int' + >>> cell(0, 0, 36.3) # The Cell type will be 'float' >>> cell(1, 0, True) # The Cell type will be 'checkbox' >>> cell(0, 1, 'Hello World!') # The Cell type will be 'text' >>> c = cell(1, 1, True) @@ -121,8 +122,10 @@ def cell(row, column, value=0., type=None, color=None, background_color=None, if type is None: if isinstance(value, bool): type = 'checkbox' - elif isinstance(value, numbers.Number): - type = 'numeric' + elif isinstance(value, int): + type = 'int' + elif isinstance(value, float): + type = 'float' elif isinstance(value, widgets.Widget): type = 'widget' else: @@ -157,7 +160,7 @@ def cell(row, column, value=0., type=None, color=None, background_color=None, @doc_subst(_common_doc) def row(row, value, column_start=0, column_end=None, type=None, color=None, background_color=None, font_style=None, font_weight=None, style=None, choice=None, - read_only=False, numeric_format='0.000', date_format='YYYY/MM/DD', renderer=None, **kwargs): + read_only=False, numeric_format=None, date_format='YYYY/MM/DD', renderer=None, **kwargs): """Create a ``Cell`` widget, representing multiple cells in a sheet, in a horizontal row Args: @@ -187,7 +190,7 @@ def row(row, value, column_start=0, column_end=None, type=None, color=None, back @doc_subst(_common_doc) def column(column, value, row_start=0, row_end=None, type=None, color=None, background_color=None, font_style=None, font_weight=None, style=None, choice=None, - read_only=False, numeric_format='0.000', date_format='YYYY/MM/DD', renderer=None, **kwargs): + read_only=False, numeric_format=None, date_format='YYYY/MM/DD', renderer=None, **kwargs): """Create a ``Cell`` widget, representing multiple cells in a sheet, in a vertical column Args: @@ -219,7 +222,7 @@ def cell_range(value, row_start=0, column_start=0, row_end=None, column_end=None, transpose=False, squeeze_row=False, squeeze_column=False, type=None, color=None, background_color=None, font_style=None, font_weight=None, style=None, choice=None, - read_only=False, numeric_format='0.000', date_format='YYYY/MM/DD', renderer=None, **kwargs): + read_only=False, numeric_format=None, date_format='YYYY/MM/DD', renderer=None, **kwargs): """Create a ``Cell`` widget, representing multiple cells in a sheet Args: @@ -278,7 +281,8 @@ def cell_range(value, # see if we an infer a type from the data, otherwise leave it None if type is None: type_check_map = [('checkbox', lambda x: isinstance(x, bool)), - ('numeric', lambda x: isinstance(x, numbers.Number)), + ('int', lambda x: isinstance(x, int)), + ('float', lambda x: isinstance(x, float) or isinstance(x, int)), ('text', lambda x: isinstance(x, six.string_types)), ('widget', lambda x: isinstance(x, widgets.Widget)), ] diff --git a/ipysheet/numpy_loader.py b/ipysheet/numpy_loader.py index c7870f2..f1de927 100644 --- a/ipysheet/numpy_loader.py +++ b/ipysheet/numpy_loader.py @@ -1,5 +1,5 @@ from .easy import sheet, column, cell_range -from .utils import extract_data, get_cell_type, get_cell_numeric_format +from .utils import extract_data, get_cell_type def from_array(array): @@ -27,7 +27,6 @@ def from_array(array): columns = 1 if len(array.shape) == 1 else array.shape[1] kwargs = { - 'numeric_format': get_cell_numeric_format(array.dtype), 'type': get_cell_type(array.dtype) } diff --git a/ipysheet/pandas_loader.py b/ipysheet/pandas_loader.py index 17140f6..544a3f2 100644 --- a/ipysheet/pandas_loader.py +++ b/ipysheet/pandas_loader.py @@ -1,5 +1,5 @@ from .sheet import Cell, Sheet -from .utils import extract_data, get_cell_numeric_format, get_cell_type +from .utils import extract_data, get_cell_type def _format_date(date): @@ -56,7 +56,6 @@ def from_dataframe(dataframe): column_start=idx, column_end=idx, type=get_cell_type(arr.dtype), - numeric_format=get_cell_numeric_format(arr.dtype), squeeze_row=False, squeeze_column=True )) diff --git a/ipysheet/sheet.py b/ipysheet/sheet.py index 5e17f01..37986ca 100644 --- a/ipysheet/sheet.py +++ b/ipysheet/sheet.py @@ -1,5 +1,6 @@ import ipywidgets as widgets from ipywidgets.widgets.widget_layout import LayoutTraitType +from ipywidgets.widgets.trait_types import NumberFormat import traitlets from traitlets import Unicode, CInt, List, Tuple, Instance, Union, Dict, Bool, Any @@ -33,7 +34,7 @@ class Cell(widgets.Widget): squeeze_column = Bool(True).tag(sync=True) transpose = Bool(False).tag(sync=True) choice = List(Unicode(), allow_none=True, default_value=None).tag(sync=True) - numeric_format = Unicode('0.000', allow_none=True).tag(sync=True) + numeric_format = NumberFormat(None, allow_none=True).tag(sync=True) date_format = Unicode('YYYY/MM/DD', allow_none=True).tag(sync=True) time_format = Unicode('h:mm:ss a', allow_none=True).tag(sync=True) diff --git a/ipysheet/test_all.py b/ipysheet/test_all.py index f780ca9..546e4bd 100644 --- a/ipysheet/test_all.py +++ b/ipysheet/test_all.py @@ -276,10 +276,10 @@ def test_cell_values(): cell = ipysheet.cell(0, 0, value=1.2) assert cell.value == 1.2 - assert cell.type == 'numeric' + assert cell.type == 'float' cell = ipysheet.cell(0, 0, value=1) assert cell.value == 1 - assert cell.type == 'numeric' + assert cell.type == 'int' cell = ipysheet.Cell(value='1.2') assert cell.value == '1.2' @@ -291,18 +291,18 @@ def test_cell_values(): cell = ipysheet.row(0, [0, 1.2]) assert cell.value == [0, 1.2] - assert cell.type == 'numeric' + assert cell.type == 'float' cell = ipysheet.row(0, [0, 1]) assert cell.value == [0, 1] - assert cell.type == 'numeric' + assert cell.type == 'int' cell = ipysheet.row(0, ['a', 'b']) assert cell.value == ['a', 'b'] assert cell.type == 'text' cell = ipysheet.row(0, [True, 0]) - assert cell.type == 'numeric' + assert cell.type == 'int' cell = ipysheet.row(0, [True, 'bla']) assert cell.type is None @@ -442,12 +442,12 @@ def test_from_dataframe(): sheet = ipysheet.from_dataframe(df) assert len(sheet.cells) == 7 assert sheet.cells[0].value == [1., 1., 1., 1.] - assert sheet.cells[0].type == 'numeric' + assert sheet.cells[0].type == 'float' assert sheet.cells[1].value == [None, '2013/01/02', None, '2013/01/02'] assert sheet.cells[1].type == 'date' assert sheet.cells[2].value == [1., 1., 1., 1.] - assert sheet.cells[2].type == 'numeric' - assert sheet.cells[2].numeric_format == '0.000' + assert sheet.cells[2].type == 'float' + assert sheet.cells[2].numeric_format is None assert sheet.cells[3].value == [False, True, False, False] assert sheet.cells[3].type == 'checkbox' assert sheet.cells[4].value == ['test', 'train', 'test', 'train'] @@ -455,8 +455,8 @@ def test_from_dataframe(): assert sheet.cells[5].value == ['foo', 'foo', 'foo', 'foo'] assert sheet.cells[5].type == 'text' assert sheet.cells[6].value == [0, 3, 9, 18] - assert sheet.cells[6].type == 'numeric' - assert sheet.cells[6].numeric_format == '0[.]0' + assert sheet.cells[6].type == 'int' + assert sheet.cells[6].numeric_format is None def test_from_to_dataframe(): @@ -503,7 +503,7 @@ def test_from_array(): arr = np.random.randn(6, 10) sheet = ipysheet.from_array(arr) assert len(sheet.cells) == 1 - assert sheet.cells[0].type == 'numeric' + assert sheet.cells[0].type == 'float' assert sheet.cells[0].value is arr assert sheet.rows == 6 assert sheet.columns == 10 diff --git a/ipysheet/utils.py b/ipysheet/utils.py index e1125be..43bdf22 100644 --- a/ipysheet/utils.py +++ b/ipysheet/utils.py @@ -50,24 +50,15 @@ def extract_data(sheet): def get_cell_type(dt): - # TODO Differentiate integer and float? Using custom renderers and - # validators for integers? # Add support for void type from NumPy? # See https://handsontable.com/docs/6.2.2/tutorial-cell-types.html return { 'b': 'checkbox', - 'i': 'numeric', - 'u': 'numeric', - 'f': 'numeric', - 'm': 'numeric', + 'i': 'int', + 'u': 'int', + 'f': 'float', + 'm': 'float', 'M': 'date', 'S': 'text', 'U': 'text' }.get(dt.kind, 'text') - - -def get_cell_numeric_format(dt): - return { - 'i': '0[.]0', - 'f': '0.000', - }.get(dt.kind) diff --git a/js/src/sheet.ts b/js/src/sheet.ts index 95e986c..8938b89 100644 --- a/js/src/sheet.ts +++ b/js/src/sheet.ts @@ -1,4 +1,5 @@ -import * as widgets from '@jupyter-widgets/base'; +import * as widgets from '@jupyter-widgets/base'; +import * as d3 from 'd3-format'; import {cloneDeep, extend, includes as contains, each, debounce, times, map, unzip as transpose} from 'lodash'; import {semver_range} from './version'; import {RendererModel} from './renderer'; @@ -35,7 +36,7 @@ let CellRangeModel = widgets.WidgetModel.extend({ squeeze_row: true, squeeze_column: true, transpose: false, - numeric_format: '0.000', + numeric_format: null, date_format: 'YYYY/MM/DD', time_format: 'h:mm:ss a' }); @@ -143,8 +144,8 @@ let SheetModel = widgets.DOMWidgetModel.extend({ cell_data.options['readOnly'] = cell.get('read_only'); if (cell.get('choice') != null) cell_data.options['source'] = cell.get('choice') - if (cell.get('numeric_format') && cell.get('type') == 'numeric') - cell_data.options['numericFormat'] = {'pattern': cell.get('numeric_format')}; + if (cell.get('numeric_format') && (cell.get('type') == 'int' || cell.get('type') == 'float')) + cell_data.options['numericFormat'] = cell.get('numeric_format'); if (cell.get('date_format') && cell.get('type') == 'date') { cell_data.options['correctFormat'] = true; cell_data.options['dateFormat'] = cell.get('date_format') || cell_data.options['dateFormat']; @@ -262,7 +263,7 @@ let put_values2d = function(grid, values) { } }; -// calls the original renderer and then applies custom styling +// Custom styled renderer that applies the default renderer then apply the given style on the cell (Handsontable.renderers as any).registerRenderer('styled', function customRenderer(hotInstance, td, row, column, prop, value, cellProperties) { let name = cellProperties.original_renderer || cellProperties.type || 'text'; let original_renderer = (Handsontable.renderers as any).getRenderer(name); @@ -272,6 +273,52 @@ let put_values2d = function(grid, values) { }); }); + +// Register `int` and `float` cell types +class IntEditor extends Handsontable.editors.TextEditor { + getValue() { + return parseInt(this.TEXTAREA.value); + } +}; + +function int_renderer(hotInstance, td, row, column, prop, value, cellProperties) { + const numeric_format = cellProperties.numericFormat || 'd'; + td.innerHTML = d3.format(numeric_format)(value); +} + +function int_validator(query, callback) { + callback(Number.isInteger(query)); +} + +(Handsontable.cellTypes as any).registerCellType('int', { + editor: IntEditor, + renderer: int_renderer, + validator: int_validator, + allowInvalid: false +}); + +class FloatEditor extends Handsontable.editors.TextEditor { + getValue() { + return parseFloat(this.TEXTAREA.value); + } +}; + +function float_renderer(hotInstance, td, row, column, prop, value, cellProperties) { + const numeric_format = cellProperties.numericFormat || '.2f'; + td.innerHTML = d3.format(numeric_format)(value); +} + +function float_validator(query, callback) { + callback(typeof query == 'number'); +} + +(Handsontable.cellTypes as any).registerCellType('float', { + editor: FloatEditor, + renderer: float_renderer, + validator: float_validator, + allowInvalid: false +}); + let SheetView = widgets.DOMWidgetView.extend({ render: function() { // this.widget_view_promises = {} diff --git a/js/src/test/test_sheet.ts b/js/src/test/test_sheet.ts index a634933..8294169 100644 --- a/js/src/test/test_sheet.ts +++ b/js/src/test/test_sheet.ts @@ -147,12 +147,12 @@ describe('sheet', function() { expect(data[1][2].value, 'when cell.value is change').to.equal(999); }) it('numeric cell with value zero should indeed have value zero', async function() { - await make_cell.apply(this, [{value: 0.00, type:'numeric'}]); + await make_cell.apply(this, [{value: 0.00, type:'float'}]); var data = this.sheet.data; - expect(data[1][2].value, 'for initial value').to.equal(0); + expect(data[1][2].value, 'for initial value').to.equal(0.0); }) it('none cell with should be set', async function() { - var cell = await make_cell.apply(this, [{value: 0.00, type:'numeric'}]); + var cell = await make_cell.apply(this, [{value: 0.00, type:'float'}]); var data = this.sheet.data; expect(data[1][2].value, 'for initial value').to.equal(0); cell.set('value', null); diff --git a/js/tsconfig.json b/js/tsconfig.json index a2b14b4..478bd7d 100644 --- a/js/tsconfig.json +++ b/js/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "noImplicitAny": false, - "lib": ["dom", "es5", "es2015.promise", "es2015.iterable"], + "lib": ["dom", "es5", "es2015"], "strictNullChecks": true, "module": "commonjs", "moduleResolution": "node",