Skip to content

Commit

Permalink
Merge pull request #2663 from ericpre/add_python3.9
Browse files Browse the repository at this point in the history
Add python3.9
  • Loading branch information
jlaehne committed Mar 15, 2021
2 parents bddacac + 736cc88 commit c7a662c
Show file tree
Hide file tree
Showing 18 changed files with 172 additions and 350 deletions.
10 changes: 3 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
fail-fast: false
matrix:
os: [windows-latest, macos-latest]
python-version: [3.6, 3.7, 3.8]
python-version: [3.6, 3.7, 3.8, 3.9]

steps:
- uses: actions/checkout@v2
Expand All @@ -52,11 +52,6 @@ jobs:
python --version
which python
- name: Install Visual C++ for Python 2.7
if: runner.os == 'Windows'
run: |
choco install vcpython27 -f -y
- name: install pep517 and twine
run: |
python -m pip install --upgrade pip
Expand Down Expand Up @@ -109,8 +104,9 @@ jobs:
python -m pip install twine
- name: Build manylinux Python wheels
uses: RalfG/python-wheels-manylinux-build@v0.3.2-manylinux2010_x86_64
uses: RalfG/python-wheels-manylinux-build@v0.3.3
with:
python-versions: 'cp36-cp36m cp37-cp37m cp38-cp38 cp39-cp39'
build-requirements: 'cython'

- name: Build source distribution
Expand Down
17 changes: 10 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
timeout-minutes: 30
env:
MPLBACKEND: agg
PIP_ARGS: --upgrade --use-feature=2020-resolver -e
PIP_ARGS: --upgrade -e
PYTEST_ARGS: --pyargs hyperspy --reruns 3 -n 2 --instafail
PYTEST_ARGS_COVERAGE:
strategy:
Expand All @@ -18,13 +18,13 @@ jobs:
os: [ubuntu, windows, macos]
PYTHON_VERSION: [3.7, 3.8]
PIP_SELECTOR: ['[all, tests]']
UPSTREAM_DEV: [false]
DEPENDENCIES_DEV: [false]
include:
# test oldest supported version of main dependencies on python 3.6
- os: ubuntu
PYTHON_VERSION: 3.6
OLDEST_SUPPORTED_VERSION: true
DEPENDENCIES: matplotlib==2.2.3 numpy==1.16.0 scipy==1.1 imagecodecs==2019.12.3 dask==2.0.0
DEPENDENCIES: matplotlib==2.2.3 numpy==1.17.1 scipy==1.1 imagecodecs==2019.12.3 dask==2.1.0
PIP_SELECTOR: '[all, tests]'
LABEL: -oldest
# test minimum requirement
Expand All @@ -38,13 +38,16 @@ jobs:
PIP_SELECTOR: '[all, tests, coverage]'
PYTEST_ARGS_COVERAGE: --cov=. --cov-report=xml
LABEL: -coverage
# Run test suite against upstream development version
# Run test suite against dependencies development version
- os: ubuntu
PYTHON_VERSION: 3.8
PIP_SELECTOR: '[all, tests]'
LABEL: -upstream_dev
UPSTREAM_DEV: true
LABEL: -dependencies_dev
DEPENDENCIES_DEV: true
DEPENDENCIES: numpy scipy scikit-learn scikit-image
- os: ubuntu
PYTHON_VERSION: 3.9
PIP_SELECTOR: '[all, tests]'
exclude:
# redundant build (same as coverage)
- os: ubuntu
Expand Down Expand Up @@ -74,7 +77,7 @@ jobs:
pip install ${{ matrix.DEPENDENCIES }}
- name: Install dependencies development version
if: ${{ matrix.UPSTREAM_DEV }}
if: ${{ matrix.DEPENDENCIES_DEV }}
run: |
pip install --upgrade --no-deps --pre \
-i https://pypi.anaconda.org/scipy-wheels-nightly/simple \
Expand Down
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ RELEASE_next_patch (Unreleased)
* Plot scalebar when the axis scales have different sign, fixes `#2557 <https://github.com/hyperspy/hyperspy/issues/2557>`_ (`#2657 <https://github.com/hyperspy/hyperspy/pull/2657>`_)
* Fix align1D returning zeros shifts (`#2675 <https://github.com/hyperspy/hyperspy/pull/2675>`_)
* Fix finding dataset path for EMD NCEM file containing more than one dataset in a group `#2673 <https://github.com/hyperspy/hyperspy/pull/2673>`_
* Add support for python 3.9, fix deprecation warning with matplotlib 3.4.0 and bump minimum requirement to numpy 1.17.1 and dask 2.1.0. (`#2663 <https://github.com/hyperspy/hyperspy/pull/2663>`_)
* Add integration test suite documentation in the developer guide. (`#2663 <https://github.com/hyperspy/hyperspy/pull/2663>`_)


Changelog
Expand Down
9 changes: 4 additions & 5 deletions doc/dev_guide/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@ Getting started
Probably you would not be interested in contributing to HyperSpy, if you were
not already a user, but, just in case: the best way to start understanding how
HyperSpy works and to build a broad overview of the code as it stands is to
use it -- so what are you waiting for? `Install HyperSpy
<http://hyperspy.org/hyperspy-doc/current/user_guide/install.html>`_.
use it -- so what are you waiting for? :ref:`Install HyperSpy <install-label>`!

The `HyperSpy User-Guide <http://www.hyperspy.org/hyperspy-doc/current/index
.html>`_ also provides a good overview of all the parts of the code that
are currently implemented as well as much information about how everything
The HyperSpy :ref:`User Guide <user_guide-label>` also provides a good overview
of all the parts of the code that are currently implemented as well as much
information about how everything
works -- so read it well.


Expand Down
58 changes: 56 additions & 2 deletions doc/dev_guide/writing_extensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ It is good practice to add all packages that extend HyperSpy
`to the list of known extensions
<https://github.com/hyperspy/hyperspy-extensions-list>`_ regardless of their
maturity level. In this way, we can avoid duplication of efforts and issues
arising from naming conflicts.
arising from naming conflicts. This repository also runs an `integration test
suite <https://github.com/hyperspy/hyperspy-extensions-list/actions>`__ daily,
which runs the test suite of all extensions to check the status of
the ecosystem. See the :ref:`corresponding section <integration_test_suite-label>`
for more details.

At this point, it is worth noting that HyperSpy's main strength is its amazing
community of users and developers. We trust that the developers of packages
Expand Down Expand Up @@ -331,7 +335,7 @@ Registering toolkeys
^^^^^^^^^^^^^^^^^^^^
To register a new toolkey:
1. Declare a new toolkey, *e. g.* by adding the :py:func:`hyperspy.ui_registry.add_gui_method`
1. Declare a new toolkey, *e. g.* by adding the :py:func:`~.ui_registry.add_gui_method`
decorator to the function you want to assign a widget to.
2. Register a new toolkey that you have declared in your package by adding it to
the ``hyperspy_extension.yaml`` file, as in the following example:
Expand Down Expand Up @@ -367,3 +371,53 @@ resides.
function: get_mycomponent_widget
# The module where the function resides.
module: my_package.widgets
.. _integration_test_suite-label:
Integration test suite
----------------------
The `integration test suite <https://github.com/hyperspy/hyperspy-extensions-list/actions>`__
runs the test suite of hyperspy and hyperspy extension on a daily basis against both the
release and development versions. The build matrix is as follows:
.. list-table:: Build matrix of the integration test suite
:widths: 25 25 25
:header-rows: 1
* - HyperSpy
- Extension
- Dependencies
* - Release
- Release
- Release
* - Release
- Development
- Release
* - RELEASE_next_patch
- Release
- Release
* - RELEASE_next_patch
- Development
- Release
* - RELEASE_next_minor
- Release
- Release
* - RELEASE_next_minor
- Development
- Release
* - RELEASE_next_minor
- Development
- Development
* - RELEASE_next_minor
- Development
- Pre-release
The development packages of the dependencies are provided by the
`scipy-wheels-nightly <https://pypi.anaconda.org/scipy-wheels-nightly/simple>`_
repository, which provides ``scipy``, ``numpy``, ``scikit-learn`` and ``scikit-image``
at the time of writing.
The pre-release packages are obtained from `pypi <https://pypi.org>`_ and these
will be used for any dependency which provides a pre-release package on pypi.
1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
.. _user_guide-label:

Welcome to HyperSpy's documentation!
====================================
Expand Down
3 changes: 2 additions & 1 deletion hyperspy/_signals/eds.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ def add_lines(self,
"%s is not a valid symbol of an element." % element)
xray_not_here = self._get_xray_lines_in_spectral_range(xray_lines)[1]
for xray in xray_not_here:
warnings.warn("%s is not in the data energy range." % xray)
warnings.warn(f"{xray} is not in the data energy range.",
UserWarning)
if "Sample.elements" in self.metadata:
extra_elements = (set(self.metadata.Sample.elements) -
elements)
Expand Down
1 change: 0 additions & 1 deletion hyperspy/drawing/_markers/vertical_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ def __repr__(self):
self.name,
self.get_data_position('x1'),
self.marker_properties['color'],
self.get_data_position('size'),
)
return(string)

Expand Down
13 changes: 7 additions & 6 deletions hyperspy/drawing/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def create_figure(window_title=None,
window_title = window_title.replace(c, '')
window_title = window_title.replace('\n', ' ')
window_title = window_title.replace(':', ' -')
fig.canvas.set_window_title(window_title)
fig.canvas.manager.set_window_title(window_title)
if disable_xyscale_keys and hasattr(fig.canvas, 'toolbar'):
# hack the `key_press_handler` to disable the `k`, `l`, `L` shortcuts
manager = fig.canvas.manager
Expand Down Expand Up @@ -671,11 +671,12 @@ def __check_single_colorbar(cbar):
if cmap is None:
cmap = [preferences.Plot.cmap_signal]
elif cmap == 'mpl_colors':
for n_color, c in enumerate(mpl.rcParams['axes.prop_cycle']):
make_cmap(colors=['#000000', c['color']],
name='mpl{}'.format(n_color))
cmap = ['mpl{}'.format(i) for i in
range(len(mpl.rcParams['axes.prop_cycle']))]
cycle = mpl.rcParams['axes.prop_cycle']
for n_color, c in enumerate(cycle):
name = f'mpl{n_color}'
if name not in plt.colormaps():
make_cmap(colors=['#000000', c['color']], name=name)
cmap = [f'mpl{i}' for i in range(len(cycle))]
__check_single_colorbar(colorbar)
# cmap is list, tuple, or something else iterable (but not string):
elif hasattr(cmap, '__iter__') and not isinstance(cmap, str):
Expand Down
26 changes: 16 additions & 10 deletions hyperspy/misc/label_position.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ def __init__(self, signal):

def _set_active_figure_properties(self):
# set the properties which depend on the figure
self.signal_figure = self.signal._plot.signal_plot.figure
self.figsize = self.signal_figure.get_size_inches()
self.smin, self.smax = self.signal_figure.get_axes()[0].get_ylim()
self.figure = self.signal._plot.signal_plot.figure
self.figsize = self.figure.get_size_inches()
self.smin, self.smax = self.signal._plot.signal_plot.ax.get_ylim()

self.sig_index = self._get_current_signal_index()
self.text_width, self.text_height = self._estimate_textbox_dimension()
Expand All @@ -67,19 +67,26 @@ def _check_signal_figure_changed(self):
# check if the spectrum is changed
# reset its properties if changed
current_sig_index = self._get_current_signal_index()
current_figsize = self.signal_figure.get_size_inches()
current_figsize = self.figure.get_size_inches()
if (current_sig_index != self.sig_index) or \
not np.isclose(current_figsize, self.figsize).all():
return True
else:
return False

def _get_bbox_from_textbox_patch(self, fig, textbox):
def _get_bbox_from_text_artist(self, text):
"""
Parameters
----------
text : matplotlib.text.Text instance
"""
# get the bbox object of the textbox
ax = fig.axes[0]
r = fig.canvas.get_renderer()
ax = text.axes
fig = text.figure
r = text.figure.canvas.get_renderer()
fig.draw(r)
extent = textbox.get_bbox_patch().get_window_extent()
extent = text.get_bbox_patch().get_window_extent()
bbox_patch = extent.transformed(ax.transData.inverted())

return bbox_patch
Expand All @@ -95,8 +102,7 @@ def _estimate_textbox_dimension(self, dummy_text='My_g8'):
**dummy_style)
self.signal.add_marker(tx)

fig = tx.marker.get_figure()
dummybb = self._get_bbox_from_textbox_patch(fig, tx.marker)
dummybb = self._get_bbox_from_text_artist(tx.marker)
tx.close()

text_width = dummybb.width
Expand Down

0 comments on commit c7a662c

Please sign in to comment.