Skip to content

Commit

Permalink
Merge branch 'master' into 0.13.x
Browse files Browse the repository at this point in the history
  • Loading branch information
pc494 committed May 24, 2021
2 parents f6c23ab + 3c549fd commit 8e94418
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 11 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/build.yml
Expand Up @@ -22,9 +22,11 @@ jobs:
python-version: ${{ matrix.python-version }}
- name: Display versions
run: python -V; pip -V
- name: Install depedencies and package
- name: Install dependencies and package
shell: bash
run: pip install -U -e .'[tests]'
- name: Run docstring tests
run: pytest --doctest-modules --ignore=pyxem/tests pyxem
- name: Run tests
run: pytest --cov=pyxem --runslow --pyargs pyxem
- name: Generate line coverage
Expand Down
1 change: 0 additions & 1 deletion CHANGELOG.md
Expand Up @@ -4,7 +4,6 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## 2021-04-14 - version 0.13.2
### Added
- Code now support python 3.9
Expand Down
2 changes: 2 additions & 0 deletions pytest.ini
@@ -0,0 +1,2 @@
[pytest]
addopts = --ignore=pyxem/detectors/generic_flat_detector.py --ignore=pyxem/detectors/medipix_256x256.py --ignore=pyxem/detectors/medipix_515x515.py --ignore pyxem/signals/common_diffraction.py --ignore=pyxem/signals/diffraction2d.py --ignore=pyxem/signals/indexation_results.py --ignore=pyxem/utils/marker_tools.py
45 changes: 45 additions & 0 deletions pyxem/conftest.py
@@ -0,0 +1,45 @@
# -*- coding: utf-8 -*-
# Copyright 2016-2021 The pyXem developers
#
# This file is part of pyXem.
#
# pyXem is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# pyXem is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with pyXem. If not, see <http://www.gnu.org/licenses/>.

import os
from tempfile import TemporaryDirectory
import pytest
import numpy
import matplotlib.pyplot as plt
import hyperspy.api as hs
import pyxem as pxm


@pytest.fixture(autouse=True)
def doctest_setup_teardown(request):
plt.ioff()
tmp_dir = TemporaryDirectory()
hs.preferences.General.show_progressbar = False
org_dir = os.getcwd()
os.chdir(tmp_dir.name)
yield
os.chdir(org_dir)
tmp_dir.cleanup()
plt.close("all")


@pytest.fixture(autouse=True)
def add_np_am(doctest_namespace):
doctest_namespace["np"] = numpy
doctest_namespace["hs"] = hs
doctest_namespace["pxm"] = pxm
2 changes: 1 addition & 1 deletion pyxem/dummy_data/make_diffraction_test_data.py
Expand Up @@ -90,7 +90,7 @@ def _get_elliptical_ring(xx, yy, x, y, semi_len0, semi_len1, rotation, lw_r=1):
Examples
--------
>>> from hyperspy.signals import Signal2D
>>> from pyxem.dummy_data importmake_diffraction_test_data as mdtd
>>> from pyxem.dummy_data import make_diffraction_test_data as mdtd
>>> s = Signal2D(np.zeros((110, 130)))
>>> s.axes_manager[0].offset, s.axes_manager[1].offset = -50, -80
>>> xx, yy = np.meshgrid(
Expand Down
7 changes: 4 additions & 3 deletions pyxem/utils/dask_tools.py
Expand Up @@ -106,9 +106,9 @@ def _get_chunking(signal, chunk_shape=None, chunk_bytes=None):
Examples
--------
>>> import dask.array as da
>>> import pyxem as pxm
>>> from hyperspy.signals import Signal2D
>>> import pyxem.utils.dask_tools as dt
>>> s = pxm.LazySignal2D(da.zeros((32, 32, 256, 256), chunks=(16, 16, 256, 256)))
>>> s = Signal2D(da.zeros((32, 32, 256, 256), chunks=(16, 16, 256, 256))).as_lazy()
>>> chunks = dt._get_chunking(s)
Limiting to 60 MiB per chunk
Expand Down Expand Up @@ -272,7 +272,8 @@ def _process_dask_array(
... return image * value
>>> dask_array = da.ones((4, 6, 10, 15), chunks=(2, 2, 2, 2))
>>> iter_array = da.random.randint(0, 99, (4, 6), chunks=(2, 2))
>>> output_dask_array = _process_dask_array(dask_array, test_function2)
>>> output_dask_array = _process_dask_array(
... dask_array, test_function2, iter_array)
>>> output_array = output_dask_array.compute()
Getting output which is different shape than the input. For example
Expand Down
2 changes: 1 addition & 1 deletion pyxem/utils/pixelated_stem_tools.py
Expand Up @@ -385,7 +385,7 @@ def _get_angle_sector_mask(
--------
>>> import numpy as np
>>> import pyxem.utils.pixelated_stem_tools as pst
>>> s = ps.PixelatedSTEM(np.arange(100).reshape(10, 10))
>>> s = pxm.signals.Diffraction2D(np.arange(100).reshape(10, 10))
>>> s.axes_manager.signal_axes[0].offset = -5
>>> s.axes_manager.signal_axes[1].offset = -5
>>> mask = pst._get_angle_sector_mask(s, 0.5*np.pi, np.pi)
Expand Down
8 changes: 4 additions & 4 deletions pyxem/utils/radial_utils.py
Expand Up @@ -655,7 +655,7 @@ def fit_single_ellipse_to_signal(
Examples
--------
>>> import pyxem.dummy_data import make_diffraction_test_data as mdtd
>>> from pyxem.dummy_data import make_diffraction_test_data as mdtd
>>> s = pxm.signals.Diffraction2D(np.zeros((200, 220)))
>>> s.axes_manager[0].offset, s.axes_manager[1].offset = -100, -110
>>> xx, yy = np.meshgrid(s.axes_manager[0].axis, s.axes_manager[1].axis)
Expand Down Expand Up @@ -715,13 +715,13 @@ def fit_ellipses_to_signal(
Examples
--------
>>> import pyxem.dummy_data import make_diffraction_test_data as mdtd
>>> s = ps.PixelatedSTEM(np.zeros((200, 220)))
>>> from pyxem.dummy_data import make_diffraction_test_data as mdtd
>>> s = pxm.signals.Diffraction2D(np.zeros((200, 220)))
>>> s.axes_manager[0].offset, s.axes_manager[1].offset = -100, -110
>>> xx, yy = np.meshgrid(s.axes_manager[0].axis, s.axes_manager[1].axis)
>>> ellipse_ring = mdtd._get_elliptical_ring(xx, yy, 0, 0, 50, 70, 0.8)
>>> s.data += ellipse_ring
>>> from pyxem..utils.radial_tools import fit_ellipses_to_signal
>>> from pyxem.utils.radial_utils import fit_ellipses_to_signal
>>> output = fit_ellipses_to_signal(
... s, [(40, 80)], angleN=30, show_progressbar=False)
Expand Down

0 comments on commit 8e94418

Please sign in to comment.