|
16 | 16 | # You should have received a copy of the GNU General Public License |
17 | 17 | # along with HyperSpy. If not, see <https://www.gnu.org/licenses/#GPL>. |
18 | 18 |
|
19 | | -import logging |
20 | 19 | from copy import deepcopy |
21 | 20 |
|
22 | 21 | import matplotlib.collections as mpl_collections |
|
25 | 24 | from matplotlib.transforms import IdentityTransform |
26 | 25 |
|
27 | 26 | from hyperspy.events import Event, Events |
28 | | -from hyperspy.misc._markers import markers_dict_to_markers |
29 | | -from hyperspy.misc.dask_utils import _get_navigation_dimension_chunk_slice |
30 | | -from hyperspy.misc.utils import is_dask_array, isiterable |
31 | | - |
32 | | -_logger = logging.getLogger(__name__) |
| 27 | +from hyperspy.misc import _markers, dask_utils, utils |
33 | 28 |
|
34 | 29 |
|
35 | 30 | def convert_positions(peaks, signal_axes): |
@@ -194,16 +189,16 @@ def __init__( |
194 | 189 | for key, value in self.kwargs.items(): |
195 | 190 | # Populate `_iterable_argument_keys` |
196 | 191 | if ( |
197 | | - isiterable(value) |
| 192 | + utils.isiterable(value) |
198 | 193 | and not isinstance(value, str) |
199 | 194 | and key != self._position_key |
200 | 195 | ): |
201 | 196 | self._iterable_argument_keys.append(key) |
202 | 197 |
|
203 | 198 | # Handling dask arrays |
204 | | - if is_dask_array(value) and value.dtype == object: |
| 199 | + if utils.is_dask_array(value) and value.dtype == object: |
205 | 200 | self.dask_kwargs[key] = self.kwargs[key] |
206 | | - elif is_dask_array(value): # and value.dtype != object: |
| 201 | + elif utils.is_dask_array(value): # and value.dtype != object: |
207 | 202 | self.kwargs[key] = value.compute() |
208 | 203 | # Patches or verts shouldn't be cast to array |
209 | 204 | elif ( |
@@ -414,7 +409,7 @@ def remove_items(self, indices, keys=None, navigation_indices=None): |
414 | 409 | # Don't remove when it doesn't have the same length as the |
415 | 410 | # position kwargs because it is a "cycling" argument |
416 | 411 | if ( |
417 | | - isiterable(value) |
| 412 | + utils.isiterable(value) |
418 | 413 | and not isinstance(value, str) |
419 | 414 | and len(value) == len(self.kwargs[self._position_key]) |
420 | 415 | ): |
@@ -498,7 +493,7 @@ def _get_cache_dask_kwargs_chunk(self, indices): |
498 | 493 |
|
499 | 494 | chunks = {key: value.chunks for key, value in self.dask_kwargs.items()} |
500 | 495 | chunk_slices = { |
501 | | - key: _get_navigation_dimension_chunk_slice(indices, chunk) |
| 496 | + key: dask_utils._get_navigation_dimension_chunk_slice(indices, chunk) |
502 | 497 | for key, chunk in chunks.items() |
503 | 498 | } |
504 | 499 | to_compute = {} |
@@ -612,7 +607,7 @@ def from_signal( |
612 | 607 | return cls(**kwargs) |
613 | 608 |
|
614 | 609 | def __deepcopy__(self, memo): |
615 | | - new_marker = markers_dict_to_markers(self._to_dictionary()) |
| 610 | + new_marker = _markers.markers_dict_to_markers(self._to_dictionary()) |
616 | 611 | return new_marker |
617 | 612 |
|
618 | 613 | def _to_dictionary(self): |
@@ -843,4 +838,6 @@ def plot_colorbar(self): |
843 | 838 |
|
844 | 839 |
|
845 | 840 | def is_iterating(arg): |
846 | | - return (isinstance(arg, np.ndarray) or is_dask_array(arg)) and arg.dtype == object |
| 841 | + return ( |
| 842 | + isinstance(arg, np.ndarray) or utils.is_dask_array(arg) |
| 843 | + ) and arg.dtype == object |
0 commit comments