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
Lazy save improvement #2797
Lazy save improvement #2797
Changes from 10 commits
2338918
2526e78
6272e58
716e94f
f4ea563
986c1cf
7d2abea
c94aa9f
1196121
8b66647
f03c2f8
84ced7a
caf6a01
3d02aa0
28d6812
50fdde7
575c975
de5ec73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ | |
from natsort import natsorted | ||
from inspect import isgenerator | ||
from pathlib import Path | ||
from collections import MutableMapping | ||
from collections.abc import MutableMapping | ||
|
||
from hyperspy.drawing.marker import markers_metadata_dict_to_markers | ||
from hyperspy.exceptions import VisibleDeprecationWarning | ||
|
@@ -277,6 +277,17 @@ def load(filenames=None, | |
acquisition stopped before the end: if True, load only the acquired | ||
data. If False, fill empty data with zeros. Default is False and this | ||
default value will change to True in version 2.0. | ||
chunks : tuple of integer or None | ||
Only for hspy files. Define the chunking used for saving the dataset. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the user guide it says these extra arguments are only relevant for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this docstring is for |
||
If None, calculates chunks for the signal, with preferably at least | ||
one chunk per signal space. | ||
close_file : bool, optional | ||
Only for hspy files. Close the file after writing, default is True. | ||
write_dataset : bool, optional | ||
Only for hspy files. If True, write the dataset, otherwise, don't | ||
write it. Useful to save attributes without having to write the whole | ||
dataset. Default is True. | ||
|
||
|
||
Returns | ||
------- | ||
|
@@ -516,6 +527,11 @@ def load_with_reader( | |
signal.tmp_parameters.folder = folder | ||
signal.tmp_parameters.filename = filename | ||
signal.tmp_parameters.extension = extension.replace('.', '') | ||
# original_filename and original_file are used to keep track of | ||
# where is the file which has been open lazily | ||
signal.tmp_parameters.original_folder = folder | ||
signal.tmp_parameters.original_filename = filename | ||
signal.tmp_parameters.original_extension = extension.replace('.', '') | ||
# test if binned attribute is still in metadata | ||
if signal.metadata.has_item('Signal.binned'): | ||
for axis in signal.axes_manager.signal_axes: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this sentence correct? Or at least ambiguous?
I'm guessing it should say that using compression can cause file saving and loading to be much slower.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is correct in many cases when the IO time is balanced against with the CPU time - most of the time, CPU are fast enough and compressor are efficient enough.