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 Aug 15, 2022
2 parents 841b8bd + 576114a commit 075f99d
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 19 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/tests_extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

jobs:
integration_test:
if: ${{ contains(github.event.pull_request.labels.*.name, 'run-extension-tests') }}
if: ${{ contains(github.event.pull_request.labels.*.name, 'run-extension-tests') || github.event_name == 'workflow_dispatch' }}
name: Extension_${{ matrix.EXTENSION_VERSION }}
runs-on: ubuntu-latest
strategy:
Expand Down Expand Up @@ -63,10 +63,17 @@ jobs:
pip install https://github.com/pyxem/pyxem/archive/master.zip
pip install https://gitlab.com/atomap/atomap/-/archive/master/atomap-master.zip
- name: Install xvfb
run: |
# required for running kikuchipy test suite
sudo apt-get install xvfb
- name: Run Kikuchipy Test Suite
if: ${{ always() }}
run: |
python -m pytest --pyargs kikuchipy
# Virtual buffer (xvfb) required for tests using PyVista
sudo apt-get install xvfb
xvfb-run python -m pytest --pyargs kikuchipy
- name: Run LumiSpy Test Suite
if: ${{ always() }}
Expand Down
6 changes: 5 additions & 1 deletion azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ steps:
conda list
displayName: Install package

- bash: |
source activate $ENV_NAME
conda clean --all -y
displayName: Clean conda cache

# Note we must use `-n 2` argument for pytest-xdist due to
# https://github.com/pytest-dev/pytest-xdist/issues/9.
- bash: |
Expand All @@ -88,4 +93,3 @@ steps:
# # Set the token generated with github from the developer settings/personal
# # access tokens menu in azure pipeline
# github_token_name: ''

3 changes: 0 additions & 3 deletions hyperspy/_signals/hologram_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,6 @@ def estimate_sideband_position(
max_workers=max_workers,
ragged=False)

# Workaround to a map disfunctionality:
sb_position.set_signal_type('signal1d')

return sb_position

estimate_sideband_position.__doc__ %= (SHOW_PROGRESSBAR_ARG, PARALLEL_ARG, MAX_WORKERS_ARG)
Expand Down
4 changes: 3 additions & 1 deletion hyperspy/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4994,7 +4994,9 @@ def _map_iterate(
testing_kwargs = {}
for ikey, key in enumerate(arg_keys):
test_ind = (0,) * len(os_am.navigation_axes)
testing_kwargs[key] = np.squeeze(args[ikey][test_ind]).compute()
# For discussion on if squeeze is necessary, see
# https://github.com/hyperspy/hyperspy/pull/2981
testing_kwargs[key] = np.squeeze(args[ikey][test_ind].compute())[()]
testing_kwargs = {**kwargs, **testing_kwargs}
test_data = np.array(
old_sig.inav[(0,) * len(os_am.navigation_shape)].data.compute()
Expand Down
12 changes: 6 additions & 6 deletions hyperspy/signal_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,11 @@ def _length_changed(self, old, new):

def apply(self):
if self.new_length is t.Undefined:
_logger.warn("Input a new length before pressing apply.")
_logger.warning("Input a new length before pressing apply.")
return
x0, y0, x1, y1 = self.x0, self.y0, self.x1, self.y1
if np.isnan(x0) or np.isnan(y0) or np.isnan(x1) or np.isnan(y1):
_logger.warn("Line position is not valid")
_logger.warning("Line position is not valid")
return
self.signal._calibrate(
x0=x0, y0=y0, x1=x1, y1=y1, new_length=self.new_length, units=self.units
Expand All @@ -208,7 +208,7 @@ def __init__(self, signal):
# Plot the signal (or model) if it is not already plotted
if signal._plot is None or not signal._plot.is_active:
signal.plot()

from hyperspy.model import BaseModel
if isinstance(signal, BaseModel):
signal = signal.signal
Expand Down Expand Up @@ -257,7 +257,7 @@ def span_selector_changed(self, *args, **kwargs):
return

x0, x1 = sorted(self.span_selector.extents)

# typically during initialisation
if x0 == x1:
return
Expand All @@ -267,7 +267,7 @@ def span_selector_changed(self, *args, **kwargs):
x0 = self.axis.low_value
if x1 > self.axis.high_value or x1 < self.axis.low_value:
x1 = self.axis.high_value

if np.diff(self.axis.value2index(np.array([x0, x1]))) == 0:
return

Expand Down Expand Up @@ -1180,7 +1180,7 @@ def update_histogram(self, clear_selector=True):
if self.auto and self._is_selector_visible and clear_selector:
# in auto mode, the displayed contrast cover the full range
# and we need to reset the span selector
# no need to clear the line, it will updated
# no need to clear the line, it will updated
self.span_selector.clear()

self.update_line()
Expand Down
4 changes: 3 additions & 1 deletion hyperspy/tests/misc/test_date_time_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ def test_update_date_time_in_metadata():
assert_deep_almost_equal(md12.General.time, md1.General.time)
import locale
if locale.getlocale()[0] in ['en_GB', 'en_US']:
assert md12.General.time_zone in ('UTC', 'Coordinated Universal Time')
assert md12.General.time_zone in (
'UTC', 'Coordinated Universal Time', 'Co-ordinated Universal Time',
)

md13 = dtt.update_date_time_in_metadata(iso2, md.deepcopy())
assert_deep_almost_equal(md13.General.date, md2.General.date)
Expand Down
7 changes: 2 additions & 5 deletions hyperspy/tests/signals/test_map_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,7 @@ def test_not_lazy_input_lazy_output_inplace(self):


class TestOutputDtype:

@pytest.mark.parametrize("dtype", [np.uint16, np.uint32, np.uint64, np.int32, np.float32])
def test_output_dtype_specified_not_inplace(self, dtype):
def a_function_dtype(data):
Expand Down Expand Up @@ -496,8 +497,6 @@ def a_function_dtype(data, dtype_to_function):
s_out.compute()
assert s_out.data.dtype == dtype


class TestOutputDtype:
@pytest.mark.parametrize("output_signal_size", [(10,), (10, 20), (10, 20, 30)])
def test_output_signal_size(self, output_signal_size):
def a_function_signal_size(data, output_signal_size_for_function):
Expand Down Expand Up @@ -671,7 +670,6 @@ def test_no_change_1d_signal(self, input_shape):
chunks = (10,) * len(input_shape)
dask_array = da.random.random(input_shape, chunks=chunks)
s = hs.signals.Signal1D(dask_array).as_lazy()
output_signal_size = input_shape[-1:]
arg_pairs, adjust_chunks, new_axis, output_pattern = _get_block_pattern((s.data,), input_shape)
assert new_axis == {}
assert adjust_chunks == {}
Expand Down Expand Up @@ -832,10 +830,9 @@ def test_lazy_output_true(self):
def test_iterating_kwargs_none(self):
s = self.s
s_out = s._map_iterate(np.sum, iterating_kwargs=None)
s_out.compute()
assert (s_out.data == self.dx * self.dy).all()

def test_iterating_kwargs_none(self):
def test_iterating_kwargs_dict(self):
def add_sum(image, add):
out = np.sum(image) + add
return out
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/2981.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix error which occurs when guessing output size in the :py:meth:`~.signal.BaseSignal.map` function and using dask newer than 2022.7.1
1 change: 1 addition & 0 deletions upcoming_changes/2982.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix extension test suite CI workflow. Enable workflow manual trigger
1 change: 1 addition & 0 deletions upcoming_changes/2984.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix deprecation warning and time zone test failing on windows (locale dependent)

0 comments on commit 075f99d

Please sign in to comment.