Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/RELEASE_next_patch' into RELEA…
Browse files Browse the repository at this point in the history
…SE_next_minor
  • Loading branch information
ericpre committed Oct 17, 2022
2 parents d46c5bd + 34c7165 commit fd4b1ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
6 changes: 3 additions & 3 deletions hyperspy/io_plugins/emd.py
Original file line number Diff line number Diff line change
Expand Up @@ -1098,11 +1098,11 @@ def _read_image(self, image_group, image_sub_group_key):
# a traditional view the negative half must be created and the data
# must be re-centered
# Similar story for DPC signal
fft_dtype = [('realFloatHalfEven', '<f4'),
('imagFloatHalfEven', '<f4')]
fft_dtype = [[('realFloatHalfEven', '<f4'),('imagFloatHalfEven', '<f4')],
[('realFloatHalfOdd', '<f4'), ('imagFloatHalfOdd', '<f4')]]
dpc_dtype = [('realFloat', '<f4'),
('imagFloat', '<f4')]
if h5data.dtype == fft_dtype or h5data.dtype == dpc_dtype:
if h5data.dtype in fft_dtype or h5data.dtype == dpc_dtype:
_logger.debug("Found an FFT or DPC, loading as Complex2DSignal")
real = h5data.dtype.descr[0][0]
imag = h5data.dtype.descr[1][0]
Expand Down
13 changes: 12 additions & 1 deletion hyperspy/misc/math_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,18 @@ def check_random_state(seed, lazy=False):
# All rights reserved.

if seed is None or seed is np.random:
return da.random._state if lazy else np.random.mtrand._rand
if lazy:
try:
# For dask<2022.10.0
return da.random._state
except AttributeError:
backend = da.backends.array_creation_dispatch.backend
if backend not in da.random._cached_random_states.keys():
# Need to initialise the backend
da.random.seed()
return da.random._cached_random_states[backend]
else:
return np.random.mtrand._rand

if isinstance(seed, numbers.Integral):
return da.random.RandomState(seed) if lazy else np.random.RandomState(seed)
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/3040.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error when reading Velox containing FFT with odd number of pixels
1 change: 1 addition & 0 deletions upcoming_changes/3049.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix getting random state dask for dask>=2022.10.0

0 comments on commit fd4b1ae

Please sign in to comment.