Skip to content
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

Improve plotting of lazy signals, by keeping current chunk #2568

Merged
merged 28 commits into from Dec 8, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
08ec188
Improve plotting of lazy signals, by keeping current chunk
magnunor Oct 29, 2020
444dadf
Minor style fix in _signals/lazy.py
magnunor Oct 30, 2020
2955e71
Add tests for chunk plotting with lazy signals
magnunor Nov 4, 2020
40ac510
Fix some wrong lazy chunk plot tests
magnunor Nov 4, 2020
b3145ec
Merge branch 'RELEASE_next_minor' into improve_lazy_plotting
magnunor Nov 5, 2020
b124dc5
Rename _get_temporary_plotting_dask_chunk to _get_temporary_dask_chunk
magnunor Nov 5, 2020
72c9a74
Improved lazy plotting: fix issue with data changing using map
magnunor Nov 5, 2020
58699d6
Improved lazy plotting: fix issue when __call__() had not been run
magnunor Nov 5, 2020
ab0ed34
Style fix in _clear_temp_dask_data
magnunor Nov 5, 2020
dfdf33b
Merge remote-tracking branch 'upstream/RELEASE_next_minor' into impro…
ericpre Dec 2, 2020
8a1cf38
Merge branch 'RELEASE_next_minor' into improve_lazy_plotting
magnunor Feb 21, 2021
efc7d4e
Merge branch 'RELEASE_next_minor' into improve_lazy_plotting
magnunor May 25, 2021
c3a2f63
Add lazy plotting improvements to upcoming changes
magnunor May 25, 2021
9244e4f
Merge branch 'RELEASE_next_minor' into improve_lazy_plotting
magnunor Sep 5, 2021
890187a
Rename _get_navigation_dimension_chunk_slice, and several variable names
magnunor Nov 7, 2021
c399e25
Fix some whitespace issues in _get_navigation_dimension_chunk_slice
magnunor Nov 7, 2021
68c474d
Rename _temp_dask_ to _cache_dask_, and position to indices
magnunor Nov 7, 2021
638339b
Improvements to lazy plotting functionality
magnunor Nov 14, 2021
2ae2887
Fix issue in LazySignal init
magnunor Nov 21, 2021
92f084a
Rename unit test to make purpose clearer
magnunor Nov 21, 2021
f51bf43
Improve lazy caching unit tests
magnunor Nov 21, 2021
3f20522
Small change, get_current_signal: make it work with LazySignal.__init__
magnunor Nov 26, 2021
b3eb354
LazySignal init: see if signal has events attribute
magnunor Nov 26, 2021
a978cd6
Add docstring to _get_cache_dask_chunk
magnunor Nov 28, 2021
b691883
Update upcoming_changes, to include multifit
magnunor Nov 28, 2021
cc1a4d3
Merge branch 'RELEASE_next_minor' into improve_lazy_plotting
magnunor Nov 28, 2021
41a0d34
Use existing function to get navigation chunks
magnunor Nov 28, 2021
ed46373
Fix __init__ signals when using `attributes={'_lazy':True}` as keywor…
ericpre Dec 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions hyperspy/_signals/lazy.py
Expand Up @@ -162,8 +162,10 @@ def close_file(self):
_logger.exception("Failed to close lazy Signal file")

def _clear_temp_dask_data(self, obj=None):
magnunor marked this conversation as resolved.
Show resolved Hide resolved
del self._temp_dask_chunk
del self._temp_dask_chunk_slice
if hasattr(self, '_temp_dask_chunk'):
thomasaarholt marked this conversation as resolved.
Show resolved Hide resolved
del self._temp_dask_chunk
if hasattr(self, '_temp_dask_chunk_slice'):
del self._temp_dask_chunk_slice

def _get_dask_chunks(self, axis=None, dtype=None):
"""Returns dask chunks.
Expand Down
16 changes: 12 additions & 4 deletions hyperspy/tests/signal/test_lazy.py
Expand Up @@ -303,11 +303,11 @@ def test_changed_data(self):
s = _lazy_signals.LazySignal2D(da.zeros((6, 6, 8, 8), chunks=(2, 2, 4, 4)))
position = s.axes_manager._getitem_tuple
s._get_temporary_dask_chunk(position)
assert hasattr(s._temp_data_chunk)
assert hasattr(s._temp_data_chunk_slice)
assert hasattr(s, "_temp_dask_chunk")
assert hasattr(s, "_temp_dask_chunk_slice")
s.events.data_changed.trigger(None)
assert not hasattr(s._temp_data_chunk)
assert not hasattr(s._temp_data_chunk_slice)
assert not hasattr(s, "_temp_dask_chunk")
assert not hasattr(s, "_temp_dask_chunk_slice")

def test_map(self):
s = _lazy_signals.LazySignal2D(da.zeros((6, 6, 8, 8), chunks=(2, 2, 4, 4)))
Expand All @@ -317,6 +317,14 @@ def test_map(self):
s.__call__()
assert len(s._temp_dask_chunk.shape) == 3

def test_clear_temp_dask_data(self):
s = _lazy_signals.LazySignal2D(da.zeros((6, 6, 8, 8), chunks=(2, 2, 4, 4)))
s.__call__()
s._clear_temp_dask_data(self)
assert not hasattr(s, "_temp_dask_data")
assert not hasattr(s, "_temp_dask_data_slice")
s._clear_temp_dask_data(self)


class TestLazyPlot:
def test_correct_value(self):
Expand Down