diff --git a/condarecipe/larray-editor/larray-editor.json b/condarecipe/larray-editor/larray-editor.json index 3052aa6..aafd073 100644 --- a/condarecipe/larray-editor/larray-editor.json +++ b/condarecipe/larray-editor/larray-editor.json @@ -9,7 +9,7 @@ }, { "name": "LArray Documentation", - "webbrowser": "http://larray.readthedocs.io/en/0.32.1", + "webbrowser": "http://larray.readthedocs.io/en/0.32.2", "icon": "${MENU_DIR}/larray-help.ico" }, { diff --git a/condarecipe/larray-editor/meta.yaml b/condarecipe/larray-editor/meta.yaml index 9f7a89a..e527745 100644 --- a/condarecipe/larray-editor/meta.yaml +++ b/condarecipe/larray-editor/meta.yaml @@ -1,9 +1,9 @@ package: name: larray-editor - version: 0.32.1 + version: 0.32.2 source: - git_tag: 0.32.1 + git_tag: 0.32.2 git_url: https://github.com/larray-project/larray-editor.git # git_tag: master # git_url: file://c:/Users/gdm/devel/larray-editor/.git diff --git a/doc/source/changes.rst b/doc/source/changes.rst index 0fbde99..66c8854 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -1,6 +1,14 @@ Change log ########## +Version 0.32.2 +============== + +Released on 2020-03-31. + +.. include:: ./changes/version_0_32_2.rst.inc + + Version 0.32.1 ============== diff --git a/doc/source/changes/version_0_32_2.rst.inc b/doc/source/changes/version_0_32_2.rst.inc new file mode 100644 index 0000000..fb03061 --- /dev/null +++ b/doc/source/changes/version_0_32_2.rst.inc @@ -0,0 +1,8 @@ +.. py:currentmodule:: larray_editor + +Fixes +^^^^^ + +* fixed spurious warning in the console when an expression results in an empty sequence (array, list, tuple). + +* fixed displaying arrays entirely filled with NaN. diff --git a/larray_editor/__init__.py b/larray_editor/__init__.py index 4aabcff..18cb03b 100644 --- a/larray_editor/__init__.py +++ b/larray_editor/__init__.py @@ -2,4 +2,4 @@ from larray_editor.api import * -__version__ = '0.32.1' +__version__ = '0.32.2' diff --git a/larray_editor/editor.py b/larray_editor/editor.py index 7e850d5..8af812b 100644 --- a/larray_editor/editor.py +++ b/larray_editor/editor.py @@ -694,15 +694,24 @@ def ipython_cell_executed(self): # last command. Which means that if the last command did not produce any output, _ is not modified. cur_output = user_ns['_oh'].get(cur_input_num) if cur_output is not None: + if 'inline' not in matplotlib.get_backend(): + if isinstance(cur_output, np.ndarray) and cur_output.size > 0: + first_output = cur_output.flat[0] + if isinstance(first_output, matplotlib.axes.Subplot): + show_figure(self, first_output.figure) + # we use a different path for sequences than for arrays to avoid copying potentially + # big non-array sequences using np.ravel(). This code does not support nested sequences, + # but I am already unsure supporting simple non-array sequences is useful. + elif isinstance(cur_output, collections.Sequence) and len(cur_output) > 0: + first_output = cur_output[0] + if isinstance(first_output, matplotlib.axes.Subplot): + show_figure(self, first_output.figure) + elif isinstance(cur_output, matplotlib.axes.Subplot): + show_figure(self, cur_output.figure) + if self._display_in_grid('', cur_output): self.view_expr(cur_output) - if isinstance(cur_output, collections.Iterable): - cur_output = np.ravel(cur_output)[0] - - if isinstance(cur_output, matplotlib.axes.Subplot) and 'inline' not in matplotlib.get_backend(): - show_figure(self, cur_output.figure) - def on_selection_changed(self): selected = self._listwidget.selectedItems() if selected: diff --git a/larray_editor/tests/test_api_larray.py b/larray_editor/tests/test_api_larray.py index a934cd7..b889ffa 100644 --- a/larray_editor/tests/test_api_larray.py +++ b/larray_editor/tests/test_api_larray.py @@ -72,7 +72,7 @@ # test isssue #35 arr7 = la.from_lists([['a', 1, 2, 3], - [ '', 1664780726569649730, -9196963249083393206, -7664327348053294350]]) + [ '', 1664780726569649730, -9196963249083393206, -7664327348053294350]]) def make_circle(width=20, radius=9): @@ -99,8 +99,10 @@ def make_demo(width=20, ball_radius=5, path_radius=5, steps=30): demo = make_demo(9, 2.5, 1.5) sphere = make_sphere(9, 4) extreme_array = la.Array([-la.inf, -1, 0, la.nan, 1, la.inf]) -scalar = la.Array(0) +array_scalar = la.Array(0) +arr_all_nan = la.Array([la.nan, la.nan]) arr_empty = la.Array([]) +arr_empty_2d = la.Array([[], []]) arr_obj = la.ndtest((2, 3)).astype(object) arr_str = la.ndtest((2, 3)).astype(str) big = la.ndtest((1000, 1000, 500)) diff --git a/larray_editor/utils.py b/larray_editor/utils.py index 32f95fd..9427b6e 100644 --- a/larray_editor/utils.py +++ b/larray_editor/utils.py @@ -539,7 +539,7 @@ def scale_to_01range(value, vmin, vmax): array([ 0. , 1. , 0.5, 0. , 0.1, 1. ]) """ if hasattr(value, 'shape') and value.shape: - if vmin == vmax: + if (np.isnan(vmin) and np.isnan(vmax)) or (vmin == vmax): return np.where(np.isnan(value), np.nan, 0) else: assert vmin < vmax diff --git a/setup.py b/setup.py index 144dee0..60933eb 100644 --- a/setup.py +++ b/setup.py @@ -9,7 +9,7 @@ def readlocal(fname): DISTNAME = 'larray-editor' -VERSION = '0.32.1' +VERSION = '0.32.2' AUTHOR = 'Gaetan de Menten, Geert Bryon, Johan Duyck, Alix Damman' AUTHOR_EMAIL = 'gdementen@gmail.com' DESCRIPTION = "Graphical User Interface for LArray library"