From e3e53a233f33f00ca425c136740a8fc130aef76d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 11:06:20 +0200 Subject: [PATCH 1/6] bump version to 0.34.5-dev --- doc/source/changes.rst | 8 +++++ doc/source/changes/version_0_34_5.rst.inc | 41 +++++++++++++++++++++++ larray_editor/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 doc/source/changes/version_0_34_5.rst.inc diff --git a/doc/source/changes.rst b/doc/source/changes.rst index b45d743..e58ad8f 100644 --- a/doc/source/changes.rst +++ b/doc/source/changes.rst @@ -1,6 +1,14 @@ Change log ########## +Version 0.34.5 +============== + +In development. + +.. include:: ./changes/version_0_34_5.rst.inc + + Version 0.34.3 ============== diff --git a/doc/source/changes/version_0_34_5.rst.inc b/doc/source/changes/version_0_34_5.rst.inc new file mode 100644 index 0000000..c4533eb --- /dev/null +++ b/doc/source/changes/version_0_34_5.rst.inc @@ -0,0 +1,41 @@ +.. py:currentmodule:: larray_editor + +Syntax changes +^^^^^^^^^^^^^^ + +* renamed ``MappingEditor.old_method_name()`` to :py:obj:`MappingEditor.new_method_name()` (closes :editor_issue:`1`). + +* renamed ``old_argument_name`` argument of :py:obj:`MappingEditor.method_name()` to ``new_argument_name``. + + +Backward incompatible changes +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* other backward incompatible changes + + +New features +^^^^^^^^^^^^ + +* added a feature (see the :ref:`miscellaneous section ` for details). + +* added another feature in the editor (closes :editor_issue:`1`). + + .. note:: + + - It works for foo bar ! + - It does not work for foo baz ! + + +.. _misc_editor: + +Miscellaneous improvements +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +* improved something. + + +Fixes +^^^^^ + +* fixed something (closes :editor_issue:`1`). diff --git a/larray_editor/__init__.py b/larray_editor/__init__.py index 2821270..800c599 100644 --- a/larray_editor/__init__.py +++ b/larray_editor/__init__.py @@ -1,3 +1,3 @@ from larray_editor.api import * # noqa: F403 -__version__ = '0.34.3' +__version__ = '0.34.5-dev' diff --git a/setup.py b/setup.py index 888afa1..75a49cb 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ def readlocal(fname): DISTNAME = 'larray-editor' -VERSION = '0.34.3' +VERSION = '0.34.5-dev' AUTHOR = 'Gaetan de Menten, Geert Bryon, Johan Duyck, Alix Damman' AUTHOR_EMAIL = 'gdementen@gmail.com' DESCRIPTION = "Graphical User Interface for LArray library" From 2a46bfe8e57e37a3cbd36e8220b76a6e91456874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 10:55:34 +0200 Subject: [PATCH 2/6] FIX: fixed console plots when xlwings 0.31.4+ is imported (closes #278) --- doc/source/changes/version_0_34_5.rst.inc | 37 +---------------------- larray_editor/editor.py | 2 ++ 2 files changed, 3 insertions(+), 36 deletions(-) diff --git a/doc/source/changes/version_0_34_5.rst.inc b/doc/source/changes/version_0_34_5.rst.inc index c4533eb..59f65e7 100644 --- a/doc/source/changes/version_0_34_5.rst.inc +++ b/doc/source/changes/version_0_34_5.rst.inc @@ -1,41 +1,6 @@ .. py:currentmodule:: larray_editor -Syntax changes -^^^^^^^^^^^^^^ - -* renamed ``MappingEditor.old_method_name()`` to :py:obj:`MappingEditor.new_method_name()` (closes :editor_issue:`1`). - -* renamed ``old_argument_name`` argument of :py:obj:`MappingEditor.method_name()` to ``new_argument_name``. - - -Backward incompatible changes -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -* other backward incompatible changes - - -New features -^^^^^^^^^^^^ - -* added a feature (see the :ref:`miscellaneous section ` for details). - -* added another feature in the editor (closes :editor_issue:`1`). - - .. note:: - - - It works for foo bar ! - - It does not work for foo baz ! - - -.. _misc_editor: - -Miscellaneous improvements -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -* improved something. - - Fixes ^^^^^ -* fixed something (closes :editor_issue:`1`). +* fixed console plots when xlwings 0.31.4+ is installed (closes :editor_issue:`278`). diff --git a/larray_editor/editor.py b/larray_editor/editor.py index 857a8a6..f6b791a 100644 --- a/larray_editor/editor.py +++ b/larray_editor/editor.py @@ -24,6 +24,8 @@ asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy()) import matplotlib +# explicitly request Qt backend (fixes #278) +matplotlib.use('QtAgg') import matplotlib.axes import numpy as np From 84c0c67f20c10a594fdc63a8e533ad55d0f1b8db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 10:53:27 +0200 Subject: [PATCH 3/6] FIX: matplotlib version did not show in about dialog (closes #279) --- larray_editor/utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/larray_editor/utils.py b/larray_editor/utils.py index fc873b1..e76721f 100644 --- a/larray_editor/utils.py +++ b/larray_editor/utils.py @@ -62,9 +62,10 @@ def get_module_version(module_name): from qtpy import API_NAME, PYQT_VERSION # API_NAME --> PyQt5 or PyQt4 qt_version = module.__version__ return f'{qt_version}, {API_NAME} {PYQT_VERSION}' - elif '__version__' in dir(module): + # at least for matplotlib, we cannot test this using '__version__' in dir(module) + elif hasattr(module, '__version__'): return module.__version__ - elif '__VERSION__' in dir(module): + elif hasattr(module, '__VERSION__'): return module.__VERSION__ else: return 'N/A' From 9ca60ba11a8c06b78892bc02176e6217a6a3d54b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 10:59:39 +0200 Subject: [PATCH 4/6] ENH: show dependencies versions in about dialog even when N/A (not installed) the fact that an (optional) dependency is missing is important information (it is often more important than actual versions of dependencies) and should be shown explicitly --- larray_editor/editor.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/larray_editor/editor.py b/larray_editor/editor.py index f6b791a..dcc7a83 100644 --- a/larray_editor/editor.py +++ b/larray_editor/editor.py @@ -270,8 +270,7 @@ def about(self):
  • Python {python} on {system} {bitness:d}bits
  • """ for dep in dependencies['editor']: - if kwargs[dep] != 'N/A': - message += f"
  • {dep} {{{dep}}}
  • \n" + message += f"
  • {dep} {kwargs[dep]}
  • \n" message += "" QMessageBox.about(self, _("About LArray Editor"), message.format(**kwargs)) From fda168b4e7bbdc495e2db866bc82bea9c34f5186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 11:02:32 +0200 Subject: [PATCH 5/6] CLN: renames for clarity * use uppercase for constants * ... --- larray_editor/editor.py | 16 ++++++++-------- larray_editor/utils.py | 32 +++++++++++++++++--------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/larray_editor/editor.py b/larray_editor/editor.py index dcc7a83..f082cac 100644 --- a/larray_editor/editor.py +++ b/larray_editor/editor.py @@ -32,8 +32,8 @@ import larray as la from larray_editor.traceback_tools import StackSummary -from larray_editor.utils import (_, create_action, show_figure, ima, commonpath, dependencies, - get_versions, get_documentation_url, urls, RecentlyUsedList) +from larray_editor.utils import (_, create_action, show_figure, ima, commonpath, DEPENDENCIES, + get_versions, get_documentation_url, URLS, RecentlyUsedList) from larray_editor.arraywidget import ArrayEditorWidget from larray_editor.commands import EditSessionArrayCommand, EditCurrentArrayCommand @@ -236,11 +236,11 @@ def _report_issue(*args, **kwargs): * Python {python} on {system} {bitness:d}bits """ issue_template += f"* {package} {{{package}}}\n" - for dep in dependencies[package]: + for dep in DEPENDENCIES[package]: issue_template += f"* {dep} {{{dep}}}\n" issue_template = issue_template.format(**versions) - url = QUrl(urls[f'new_issue_{package}']) + url = QUrl(URLS[f'new_issue_{package}']) from qtpy.QtCore import QUrlQuery query = QUrlQuery() query.addQueryItem("body", quote(issue_template)) @@ -250,15 +250,15 @@ def _report_issue(*args, **kwargs): return _report_issue def open_users_group(self): - QDesktopServices.openUrl(QUrl(urls['users_group'])) + QDesktopServices.openUrl(QUrl(URLS['users_group'])) def open_announce_group(self): - QDesktopServices.openUrl(QUrl(urls['announce_group'])) + QDesktopServices.openUrl(QUrl(URLS['announce_group'])) def about(self): """About Editor""" kwargs = get_versions('editor') - kwargs.update(urls) + kwargs.update(URLS) message = """\

    LArray Editor {editor}
    The Graphical User Interface for LArray @@ -269,7 +269,7 @@ def about(self):

    • Python {python} on {system} {bitness:d}bits
    • """ - for dep in dependencies['editor']: + for dep in DEPENDENCIES['editor']: message += f"
    • {dep} {kwargs[dep]}
    • \n" message += "
    " QMessageBox.about(self, _("About LArray Editor"), message.format(**kwargs)) diff --git a/larray_editor/utils.py b/larray_editor/utils.py index e76721f..b40ed69 100644 --- a/larray_editor/utils.py +++ b/larray_editor/utils.py @@ -32,18 +32,18 @@ logger = logging.getLogger("editor") -core_dependencies = ['numpy', 'pandas', 'matplotlib', 'pytables', 'xlwings', 'xlsxwriter', 'xlrd', 'openpyxl'] -editor_dependencies = ['larray', 'larray_eurostat', 'qt'] + core_dependencies -eurostat_dependencies = ['larray'] -dependencies = {'editor': editor_dependencies, 'larray': core_dependencies, 'larray_eurostat': eurostat_dependencies} +CORE_DEPENDENCIES = ['matplotlib', 'numpy', 'openpyxl', 'pandas', 'pytables', 'xlsxwriter', 'xlrd', 'xlwings'] +EDITOR_DEPENDENCIES = ['larray', 'larray_eurostat', 'qt'] + CORE_DEPENDENCIES +EUROSTAT_DEPENDENCIES = ['larray'] +DEPENDENCIES = {'editor': EDITOR_DEPENDENCIES, 'larray': CORE_DEPENDENCIES, 'larray_eurostat': EUROSTAT_DEPENDENCIES} -doc = "http://larray.readthedocs.io/en/{version}" -urls = {"fpb": "http://www.plan.be/index.php?lang=en", +DOC = "http://larray.readthedocs.io/en/{version}" +URLS = {"fpb": "http://www.plan.be/index.php?lang=en", "GPL3": "https://www.gnu.org/licenses/gpl-3.0.html", - "doc_index": f"{doc}/index.html", - "doc_tutorial": f"{doc}/tutorial.html", - "doc_api": f"{doc}/api.html", + "doc_index": f"{DOC}/index.html", + "doc_tutorial": f"{DOC}/tutorial.html", + "doc_api": f"{DOC}/api.html", "new_issue_editor": "https://github.com/larray-project/larray-editor/issues/new", "new_issue_larray": "https://github.com/larray-project/larray/issues/new", "new_issue_larray_eurostat": "https://github.com/larray-project/larray_eurostat/issues/new", @@ -74,9 +74,11 @@ def get_module_version(module_name): def get_versions(package): - """Get version information of dependencies of a package""" + """Get version information of dependencies of one of our packages + `package` can be one of 'editor', 'larray' or 'larray_eurostat' + """ import platform - modules = {'editor': 'larray_editor', 'qt': 'qtpy.QtCore', 'pytables': 'tables'} + module_with_version = {'editor': 'larray_editor', 'qt': 'qtpy.QtCore', 'pytables': 'tables'} versions = { 'system': platform.system() if sys.platform != 'darwin' else 'Darwin', @@ -84,9 +86,9 @@ def get_versions(package): 'bitness': 64 if sys.maxsize > 2**32 else 32, } - versions[package] = get_module_version(modules.get(package, package)) - for dep in dependencies[package]: - versions[dep] = get_module_version(modules.get(dep, dep)) + versions[package] = get_module_version(module_with_version.get(package, package)) + for dep in DEPENDENCIES[package]: + versions[dep] = get_module_version(module_with_version.get(dep, dep)) return versions @@ -95,7 +97,7 @@ def get_documentation_url(key): version = get_module_version('larray') if version == 'N/A': version = 'stable' - return urls[key].format(version=version) + return URLS[key].format(version=version) # Note: string and unicode data types will be formatted with '%s' (see below) From e5eeb7c68e2c5118be95cdb47d58524324aee58a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ga=C3=ABtan=20de=20Menten?= Date: Fri, 26 Jul 2024 14:03:22 +0200 Subject: [PATCH 6/6] FIX: fixed inplace operations not refreshing window title and/or array (closes #22 and #280) --- doc/source/changes/version_0_34_5.rst.inc | 4 ++++ larray_editor/editor.py | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/source/changes/version_0_34_5.rst.inc b/doc/source/changes/version_0_34_5.rst.inc index 59f65e7..7b6b92d 100644 --- a/doc/source/changes/version_0_34_5.rst.inc +++ b/doc/source/changes/version_0_34_5.rst.inc @@ -4,3 +4,7 @@ Fixes ^^^^^ * fixed console plots when xlwings 0.31.4+ is installed (closes :editor_issue:`278`). + +* fixed some inplace modifications on arrays done via in the console not refreshing + the displayed array automatically and/or not adding a `*` to the window title + to inform the session is modified (closes :editor_issue:`22` and :editor_issue:`280`). diff --git a/larray_editor/editor.py b/larray_editor/editor.py index f082cac..a06da13 100644 --- a/larray_editor/editor.py +++ b/larray_editor/editor.py @@ -77,7 +77,7 @@ REOPEN_LAST_FILE = object() assignment_pattern = re.compile(r'[^\[\]]+[^=]=[^=].+') -setitem_pattern = re.compile(r'(\w+)(\.i|\.iflat|\.points|\.ipoints)?\[.+\][^=]=[^=].+') +setitem_pattern = re.compile(r'(\w+)(\.i|\.iflat|\.points|\.ipoints)?\[.+\][^=]*=[^=].+') history_vars_pattern = re.compile(r'_i?\d+') # XXX: add all scalars except strings (from numpy or plain Python)? # (long) strings are not handled correctly so should NOT be in this list @@ -699,9 +699,13 @@ def ipython_cell_executed(self): setitem_match = setitem_pattern.match(last_input) if setitem_match: varname = setitem_match.group(1) - # otherwise it should have failed at this point, but let us be sure + # setitem to (i)python special variables do not concern us if varname in clean_ns: if self._display_in_grid(varname, clean_ns[varname]): + # For better or worse, _save_data() only saves "displayable data" + # so changes to variables we cannot display do not concern us, + # and this line should not be moved outside the if condition. + self.unsaved_modifications = True # XXX: this completely refreshes the array, including detecting scientific & ndigits, which might # not be what we want in this case self.select_list_item(varname)