Skip to content

Commit dc68a8a

Browse files
committed
fix #1014 and #1015 - reload on magic and fix print on python2
1 parent 521f86c commit dc68a8a

File tree

3 files changed

+9
-12
lines changed

3 files changed

+9
-12
lines changed

src/jupyter_contrib_nbextensions/nbextensions/varInspector/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,12 @@ The initial configuration can be given using the IPython-contrib nbextensions fa
2525

2626
## Notes
2727
- The displayed size of variables use the `getsizeof()` python method. This method doesn't work for all types, so the reported size is to be considered with some caution. The extension includes some code to correctly return the size of numpy arrays, pandas Series and DataFrame but the size for some other types may be incorrect.
28-
- The extension builds on some
29-
[example code](https://github.com/jupyter-widgets/ipywidgets/blob/ffa094e061c899292036049b00ff93e46e8b4691/docs/source/examples/Variable%20Inspector.ipynb)
30-
provided by the ipywidgets package (essentially the `_fill` method).
28+
- The extension builds on some code provided [here](https://github.com/ipython/ipywidgets/blob/master/docs/source/examples/Variable%20Inspector.ipynb) (essentially the `_fill` method)
3129
- The extension uses Christian Bach's [table sorter jquery plugin](https://github.com/christianbach/tablesorter). License file is included.
3230

3331

3432
## History
3533

3634
- @jfbercher march 22, 2017 -- initial release
37-
- @jfbercher april 03, 2017 -- multiple kernel support. added support for R kernels.
35+
- @jfbercher april 03, 2017 -- multiple kernel support. added support for R kernels.
36+
- @jfbercher june 30, 2017 -- fixed #1014 (use of `%reset` with IPython kernel) and #1015 printing with python 2 kernel.

src/jupyter_contrib_nbextensions/nbextensions/varInspector/main.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,9 @@ function html_table(jsonVars) {
144144

145145
function code_exec_callback(msg) {
146146
var jsonVars = msg.content['text'];
147-
$('#varInspector').html(html_table(jsonVars))
147+
if (jsonVars == undefined) varInspector_init()
148+
//means that msg.text is undefined, that is var_dic_list was cleared ==> need to retart the enxtesnion
149+
else $('#varInspector').html(html_table(jsonVars))
148150

149151
require(['nbextensions/varInspector/jquery.tablesorter.min'],
150152
function() {

src/jupyter_contrib_nbextensions/nbextensions/varInspector/var_list.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
from __future__ import print_function
2-
3-
import json
41
from sys import getsizeof
5-
6-
from IPython import get_ipython
72
from IPython.core.magics.namespace import NamespaceMagics
8-
3+
from IPython import get_ipython
4+
import json
95
_nms = NamespaceMagics()
106
_Jupyter = get_ipython()
117
_nms.shell = _Jupyter.kernel.shell
@@ -24,7 +20,7 @@ def _getsizeof(x):
2420

2521
def var_dic_list():
2622
types_to_exclude = ['module', 'function', 'builtin_function_or_method',
27-
'instance', '_Feature']
23+
'instance', '_Feature', 'type', 'ufunc']
2824
values = _nms.who_ls()
2925
vardic = [{'varName': v, 'varType': type(eval(v)).__name__, 'varSize': _getsizeof(eval(v)), 'varContent': str(eval(v))[:200]} # noqa
3026
for v in values if (v not in ['_html', '_nms', 'NamespaceMagics', '_Jupyter']) & (type(eval(v)).__name__ not in types_to_exclude)] # noqa

0 commit comments

Comments
 (0)