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

# Conflicts:
#	.github/workflows/release.yml
  • Loading branch information
ericpre committed May 3, 2023
2 parents e5023ad + ddeae91 commit b43ed1d
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 42 deletions.
26 changes: 7 additions & 19 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,10 @@ jobs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- name: Checkout code
uses: actions/checkout@v3.3.0
uses: actions/checkout@v3
- name: Create Release
id: create_release
uses: softprops/action-gh-release@de2c0eb89ae2a093876385947365aca7b0e5f844
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
draft: false
prerelease: false

build_wheels:
name: Wheels on ${{ matrix.os }}/py${{ matrix.python-version }}
Expand All @@ -39,7 +34,7 @@ jobs:
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3

- uses: actions/setup-python@v4
name: Install Python
Expand Down Expand Up @@ -92,16 +87,12 @@ jobs:
needs: create_release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3.3.0
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.8

- name: install twine
run: |
python -m pip install twine
python-version: '3.10'

- name: Build source distribution
run: |
Expand Down Expand Up @@ -134,13 +125,10 @@ jobs:
- name: Publish wheels to PyPI
if: github.repository_owner == 'hyperspy'
env:
uses: pypa/gh-action-pypi-publish@release/v1
with:
# Github secret set in the hyperspy/hyperspy repository
# Not available from fork or pull request
# Secrets are not passed to workflows that are triggered by a pull request from a fork
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
run: |
twine upload dist/*-manylinux*.whl --verbose
twine upload dist/*.tar.gz --verbose
password: ${{ secrets.PYPI_API_TOKEN }}

6 changes: 3 additions & 3 deletions hyperspy/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4890,14 +4890,14 @@ def map(
# inspect.
_logger.warning(error)

# If the function has an `axes` or `axis` argument
# we suppose that it can operate on the full array and we don't
# iterate over the coordinates.
if not ndkwargs and not lazy_output and (self.axes_manager.signal_dimension == 1 and
"axis" in fargs):
kwargs['axis'] = self.axes_manager.signal_axes[-1].index_in_array

result = self._map_all(function, inplace=inplace, **kwargs)
# If the function has an axes argument
# we suppose that it can operate on the full array and we don't
# iterate over the coordinates.
elif not ndkwargs and not lazy_output and "axes" in fargs and not parallel:
kwargs['axes'] = tuple([axis.index_in_array for axis in
self.axes_manager.signal_axes])
Expand Down
2 changes: 1 addition & 1 deletion hyperspy/tests/misc/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
to_numpy,
get_array_module
)
from hyperspy.exceptions import VisibleDeprecationWarning, LazyCupyConversion
from hyperspy.exceptions import VisibleDeprecationWarning

try:
import cupy as cp
Expand Down
10 changes: 5 additions & 5 deletions hyperspy/tests/signals/test_hologram_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import matplotlib.pyplot as plt
import numpy as np
import pytest
from scipy.interpolate import interp2d
from scipy.interpolate import RectBivariateSpline

import hyperspy.api as hs
from hyperspy.decorators import lazifyTestClass
Expand Down Expand Up @@ -192,16 +192,16 @@ def test_reconstruct_phase_nonstandard(lazy):
# interpolate reconstructed phase to compare with the input (reference
# phase):
interp_x = np.arange(output_shape[0])
phase_interp0 = interp2d(
interp_x, interp_x, wave_image2.inav[0].unwrapped_phase().data, kind="cubic",
phase_interp0 = RectBivariateSpline(
interp_x, interp_x, wave_image2.inav[0].unwrapped_phase().data,
)
phase_new0 = phase_interp0(
np.linspace(0, output_shape[0], img_size),
np.linspace(0, output_shape[0], img_size),
)

phase_interp1 = interp2d(
interp_x, interp_x, wave_image2.inav[1].unwrapped_phase().data, kind="cubic",
phase_interp1 = RectBivariateSpline(
interp_x, interp_x, wave_image2.inav[1].unwrapped_phase().data,
)
phase_new1 = phase_interp1(
np.linspace(0, output_shape[0], img_size),
Expand Down
37 changes: 23 additions & 14 deletions hyperspy/tests/signals/test_map_method.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def test_constant_sigma(self, parallel):
[14.15585247, 14.7337787, 15.31170493]]]))

@pytest.mark.parametrize('parallel', [True, False])
def test_constant_sigma_navdim0(self, parallel):
def test_constant_sigma_signal_navdim0(self, parallel):
# navigation dimension of signal is 0
# sigma is constant
s = self.im.inav[0]
s.map(gaussian_filter, sigma=1, parallel=parallel, ragged=self.ragged, inplace= not self.ragged)
np.testing.assert_allclose(s.data, np.array(
Expand All @@ -62,25 +64,32 @@ def test_constant_sigma_navdim0(self, parallel):
def test_variable_sigma(self, parallel):
s = self.im

sigmas = np.array([0, 1])
sigmas = hs.signals.BaseSignal(np.array([0, 1])).T
s.map(gaussian_filter, sigma=sigmas, parallel=parallel, ragged=self.ragged)

s.map(gaussian_filter,
sigma=sigmas, parallel=parallel, ragged=self.ragged)
np.testing.assert_allclose(s.data, np.array(
[[[0.42207377, 1., 1.57792623],
[3.42207377, 4., 4.57792623],
[6.42207377, 7., 7.57792623]],

[[9.42207377, 10., 10.57792623],
[12.42207377, 13., 13.57792623],
[15.42207377, 16., 16.57792623]]]))
# For inav[0], sigma is 0, data unchanged
np.testing.assert_allclose(s.inav[0].data, np.arange(9).reshape((3, 3)))
# For inav[1], sigma is 1
np.testing.assert_allclose(s.inav[1].data, np.array(
[[10.68829507, 11.2662213 , 11.84414753],
[12.42207377, 13. , 13.57792623],
[14.15585247, 14.7337787 , 15.31170493]]))

@pytest.mark.parametrize('parallel', [True, False])
def test_variable_sigma_navdim0(self, parallel):
# navigation dimension of signal is 1, length 2
# navigation dimension of sigmas is 1, length 1
# raise ValueError because of navigation dimension mismatch
s = self.im

sigma = 1
s.map(gaussian_filter, sigma=sigma, parallel=parallel,
sigmas = hs.signals.BaseSignal(np.array([[0], ])).T
with pytest.raises(ValueError):
s.map(gaussian_filter, sigma=sigmas, parallel=parallel,
ragged=self.ragged)

# sigmas is a number
sigmas = 1
s.map(gaussian_filter, sigma=sigmas, parallel=parallel,
ragged=self.ragged)
np.testing.assert_allclose(s.data, np.array(
[[[1.68829507, 2.2662213, 2.84414753],
Expand Down
1 change: 1 addition & 0 deletions upcoming_changes/3117.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Simplify release workflow and replace deprecated ``actions/create-release`` action with ``softprops/action-gh-release``.
1 change: 1 addition & 0 deletions upcoming_changes/3124.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix test with scipy1.11 and update deprecated ``scipy.interpolate.interp2d`` in the test suite

0 comments on commit b43ed1d

Please sign in to comment.