Skip to content

0.34.6 #282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions doc/source/changes.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
Change log
##########

Version 0.34.6
==============

In development.

.. include:: ./changes/version_0_34_6.rst.inc


Version 0.34.5
==============

Expand Down
9 changes: 9 additions & 0 deletions doc/source/changes/version_0_34_6.rst.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
.. py:currentmodule:: larray_editor

Fixes
^^^^^

* fixed some console plots (again) because a "fix" in the partially done
0.34.5 release introduced other problems. Sadly, these new problems were
discovered after the release process for 0.34.5 was started, hence the
partial release.
2 changes: 1 addition & 1 deletion larray_editor/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from larray_editor.api import * # noqa: F403

__version__ = '0.34.5'
__version__ = '0.34.6-dev'
16 changes: 10 additions & 6 deletions larray_editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,13 @@

REOPEN_LAST_FILE = object()

assignment_pattern = re.compile(r'[^\[\]]+[^=]=[^=].+')
setitem_pattern = re.compile(r'(\w+)(\.i|\.iflat|\.points|\.ipoints)?\[.+\][^=]*=[^=].+')
history_vars_pattern = re.compile(r'_i?\d+')
ASSIGNMENT_PATTERN = re.compile(r'[^\[\]]+[^=]=[^=].+')
SUBSET_UPDATE_PATTERN = re.compile(r'(\w+)'
r'(\.i|\.iflat|\.points|\.ipoints)?'
r'\[.+\]\s*'
r'([-+*/%&|^><]|//|\*\*|>>|<<)?'
r'=\s*[^=].*')
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
# tuple, list
Expand Down Expand Up @@ -668,7 +672,7 @@ def delete_current_item(self):
def line_edit_update(self):
import larray as la
last_input = self.eval_box.text()
if assignment_pattern.match(last_input):
if ASSIGNMENT_PATTERN.match(last_input):
context = self.data._objects.copy()
exec(last_input, la.__dict__, context)
varname = self.update_mapping(context)
Expand All @@ -690,13 +694,13 @@ def ipython_cell_executed(self):
ip_keys = {'In', 'Out', '_', '__', '___', '__builtin__', '_dh', '_ih', '_oh', '_sh', '_i', '_ii', '_iii',
'exit', 'get_ipython', 'quit'}
# '__builtins__', '__doc__', '__loader__', '__name__', '__package__', '__spec__',
clean_ns = {k: v for k, v in user_ns.items() if k not in ip_keys and not history_vars_pattern.match(k)}
clean_ns = {k: v for k, v in user_ns.items() if k not in ip_keys and not HISTORY_VARS_PATTERN.match(k)}

# user_ns['_i'] is not updated yet (refers to the -2 item)
# 'In' and '_ih' point to the same object (but '_ih' is supposed to be the non-overridden one)
cur_input_num = len(user_ns['_ih']) - 1
last_input = user_ns['_ih'][-1]
setitem_match = setitem_pattern.match(last_input)
setitem_match = SUBSET_UPDATE_PATTERN.match(last_input)
if setitem_match:
varname = setitem_match.group(1)
# setitem to (i)python special variables do not concern us
Expand Down
32 changes: 32 additions & 0 deletions larray_editor/tests/test_inplace_modification_pattern.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from larray_editor.editor import SUBSET_UPDATE_PATTERN


def test_pattern():
assert SUBSET_UPDATE_PATTERN.match('arr1[1] = 2')
assert SUBSET_UPDATE_PATTERN.match('arr1[1]= 2')
assert SUBSET_UPDATE_PATTERN.match('arr1[1]=2')
assert SUBSET_UPDATE_PATTERN.match("arr1['a'] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[func(mapping['a'])] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1.i[0, 0] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1.iflat[0, 0] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1.points[0, 0] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1.ipoints[0, 0] = arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] += arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] -= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] *= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] /= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] %= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] //= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] **= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] &= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] |= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] ^= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] >>= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0] <<= arr2")
assert SUBSET_UPDATE_PATTERN.match("arr1[0]") is None
assert SUBSET_UPDATE_PATTERN.match("arr1.method()") is None
assert SUBSET_UPDATE_PATTERN.match("arr1[0].method()") is None
assert SUBSET_UPDATE_PATTERN.match("arr1[0].method(arg=thing)") is None
assert SUBSET_UPDATE_PATTERN.match("arr1[0].method(arg==thing)") is None
# this test fails but I don't think it is possible to fix it with regex
# assert SUBSET_UPDATE_PATTERN.match("arr1[func('[]=0')].method()") is None
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def readlocal(fname):


DISTNAME = 'larray-editor'
VERSION = '0.34.5'
VERSION = '0.34.6-dev'
AUTHOR = 'Gaetan de Menten, Geert Bryon, Johan Duyck, Alix Damman'
AUTHOR_EMAIL = '[email protected]'
DESCRIPTION = "Graphical User Interface for LArray library"
Expand Down
Loading