Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct detector shape of returned EBSD signal from downsample() #674

Merged
merged 10 commits into from
May 30, 2024
1 change: 0 additions & 1 deletion .github/workflows/perhaps_make_tagged_release_draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

from outdated import check_outdated


with open("../../kikuchipy/release.py") as fid:
for line in fid:
if line.startswith("version"):
Expand Down
34 changes: 24 additions & 10 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ on:
branches:
- '*'
workflow_dispatch:
workflow: '*'

jobs:
code:
name: code style
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: psf/black@stable

- uses: actions/setup-python@v5
with:
python-version: '3.11'

- uses: isort/isort-action@master
with:
configuration: --profile black --filter-files --force-sort-within-sections --check-only --diff

- name: Install Black with Jupyter extension
run: |
pip install black[jupyter]
Expand All @@ -32,9 +39,9 @@ jobs:
name: check manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: actions/setup-python@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'

Expand All @@ -60,17 +67,17 @@ jobs:
python-version: ['3.10', '3.11']
include:
- os: ubuntu-latest
python-version: 3.7
DEPENDENCIES: dask==2021.8.1 diffsims==0.5.1 hyperspy==1.7.3 matplotlib==3.5 numba==0.55 numpy==1.21.6 orix==0.11.1 pooch==1.3.0 pyebsdindex==0.2 scikit-image==0.16.2
python-version: 3.8
DEPENDENCIES: dask==2021.8.1 diffsims==0.5.1 hyperspy==1.7.3 matplotlib==3.5 numba==0.57 numpy==1.23.0 orix==0.11.1 pooch==1.3.0 pyebsdindex==0.2 scikit-image==0.21.0
LABEL: -oldest
- os: ubuntu-latest
python-version: 3.11
LABEL: -minimum_requirement
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -85,13 +92,20 @@ jobs:
run: |
pip install ${{ matrix.DEPENDENCIES }}

- name: Install optional dependencies
if: ${{ contains(matrix.LABEL, 'minimum_requirement') == false }}
- name: Install optional dependencies on Linux and Windows
if: ${{ contains(matrix.LABEL, 'minimum_requirement') == false && matrix.os != 'macos-latest' }}
shell: bash
run: |
pip install -e .'[all]'
pip install pyopencl

- name: Install optional dependencies on macOS (without nlopt)
if: ${{ contains(matrix.LABEL, 'minimum_requirement') == false && matrix.os == 'macos-latest' }}
shell: bash
run: |
pip install -e .
pip install 'pyebsdindex[gpu]' pyvista

- name: Display Python, pip and package versions
run: |
python -V
Expand Down
19 changes: 16 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
repos:
- repo: https://github.com/psf/black
rev: 23.1.0
hooks:
# https://black.readthedocs.io/en/stable/index.html
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black
language_version: python3.11
- id: black-jupyter
files: \.ipynb
args: [--line-length=77]
# https://pycqa.github.io/isort/
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
name: isort (python)
args:
[--profile=black, --filter-files, --force-sort-within-sections]
18 changes: 15 additions & 3 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ Added

Changed
-------
- Minimum Python version is now 3.8.
(`#674 <https://github.com/pyxem/kikuchipy/pull/674>`_)
- Minimum NumPy version is now 1.23.0.
(`#674 <https://github.com/pyxem/kikuchipy/pull/674>`_)
- Minimum Numba version is now 0.57.0.
(`#674 <https://github.com/pyxem/kikuchipy/pull/674>`_)
- Minimum scikit-image version is now 0.22.0.
(`#674 <https://github.com/pyxem/kikuchipy/pull/674>`_)

Deprecated
----------
Expand All @@ -30,7 +38,11 @@ Removed

Fixed
-----

- The order of the new shape of the detector of a downsampled EBSD signal, returned from
``downsample()``, was previously previously incorrect, (n columns, n rows). This is
now correct, (n rows, n columns).
(`#674 <https://github.com/pyxem/kikuchipy/pull/674>`_)

0.9.0 (2023-11-03)
==================

Expand Down Expand Up @@ -531,8 +543,8 @@ Deprecated
removed in version 0.7. Use the ``kikuchipy.simulations.KikuchiPatternSimulator``
class instead. (`#537 <https://github.com/pyxem/kikuchipy/pull/537>`_)
- The ``kikuchipy.crystallography.matrices`` module is deprecated and will be removed in
version 0.7, access the matrices via :class:`diffpy.structure.lattice.Lattice`
attributes instead. (`#537 <https://github.com/pyxem/kikuchipy/pull/537>`_)
version 0.7, access the matrices via ``diffpy.structure.lattice.Lattice`` attributes
instead. (`#537 <https://github.com/pyxem/kikuchipy/pull/537>`_)
- The following functions for processing of pattern chunks in the
``kikuchipy.pattern.chunk`` module are deprecated and will be removed in version 0.7:
``get_image_quality()``, ``remove_dynamic_background()`` and
Expand Down
3 changes: 1 addition & 2 deletions doc/_static/image/reference_frames/doc_reference_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@

import matplotlib.pyplot as plt

from kikuchipy.detectors import EBSDDetector
from kikuchipy import load

from kikuchipy.detectors import EBSDDetector

data = "/home/hakon/kode/kikuchipy/kikuchipy/data/kikuchipy_h5ebsd/patterns.h5"
outdir = "/home/hakon/kode/kikuchipy/doc/_static/image"
Expand Down
5 changes: 2 additions & 3 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,15 @@
from datetime import datetime
import inspect
import os
from os.path import relpath, dirname
from os.path import dirname, relpath
import re
import sys

import pyvista as pv
from numpydoc.docscrape_sphinx import SphinxDocString
import pyvista as pv

import kikuchipy as kp


# If extensions (or modules to document with autodoc) are in another
# directory, add these directories to sys.path here. If the directory
# is relative to the documentation root, use os.path.abspath to make it
Expand Down
4 changes: 3 additions & 1 deletion doc/tutorials/esteem2022_diffraction_workshop.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2178,7 +2178,9 @@
}
],
"source": [
"fig = simulator.plot(hemisphere=\"upper\", mode=\"lines\", return_figure=True, color=\"w\")\n",
"fig = simulator.plot(\n",
" hemisphere=\"upper\", mode=\"lines\", return_figure=True, color=\"w\"\n",
")\n",
"fig.axes[0].scatter(ref, c=hkl_rgb, s=50)\n",
"\n",
"fig.axes[0].imshow(mp_sp.data, cmap=\"gray\", extent=(-1, 1, -1, 1));"
Expand Down
2 changes: 1 addition & 1 deletion doc/tutorials/feature_maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@
" colorbar=True,\n",
" colorbar_label=\"Average dot product\",\n",
" remove_padding=True,\n",
" return_figure=True\n",
" return_figure=True,\n",
")\n",
"fig.axes[0].scatter(x, y, c=\"r\");"
]
Expand Down
10 changes: 5 additions & 5 deletions doc/tutorials/hough_indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@
" [[1, 1, 1], [2, 0, 0], [2, 2, 0], [3, 1, 1]],\n",
" nBands=10,\n",
" tSigma=2,\n",
" rSigma=2\n",
" rSigma=2,\n",
")\n",
"\n",
"print(indexer.vendor)\n",
Expand Down Expand Up @@ -475,7 +475,7 @@
" [[1, 1, 1], [2, 0, 0], [2, 2, 0], [3, 1, 1]],\n",
" nBands=10,\n",
" tSigma=2,\n",
" rSigma=2\n",
" rSigma=2,\n",
")\n",
"indexer.PC"
]
Expand Down Expand Up @@ -527,14 +527,14 @@
"metadata": {},
"outputs": [],
"source": [
"#io.save(\"xmap_ni.h5\", xmap)\n",
"#io.save(\n",
"# io.save(\"xmap_ni.h5\", xmap)\n",
"# io.save(\n",
"# \"xmap_ni.ang\",\n",
"# xmap,\n",
"# image_quality_prop=\"pq\",\n",
"# confidence_index_prop=\"cm\",\n",
"# extra_prop=\"nmatch\",\n",
"#)"
"# )"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions doc/tutorials/hybrid_indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@
"from orix.vector import Vector3d\n",
"\n",
"\n",
"plt.rcParams.update({\n",
" \"figure.facecolor\": \"w\",\n",
" \"font.size\": 15,\n",
" \"figure.dpi\": 75,\n",
"})"
"plt.rcParams.update(\n",
" {\n",
" \"figure.facecolor\": \"w\",\n",
" \"font.size\": 15,\n",
" \"figure.dpi\": 75,\n",
" }\n",
")"
]
},
{
Expand Down Expand Up @@ -1335,9 +1337,7 @@
"\n",
"# Place color key in bottom right corner, coordinates are\n",
"# [left, bottom, width, height]\n",
"ax_ckey = fig.add_axes(\n",
" [0.76, 0.08, 0.2, 0.2], projection=\"ipf\", symmetry=pg\n",
")\n",
"ax_ckey = fig.add_axes([0.76, 0.08, 0.2, 0.2], projection=\"ipf\", symmetry=pg)\n",
"ax_ckey.plot_ipf_color_key(show_title=False)\n",
"ax_ckey.patch.set_facecolor(\"None\")"
]
Expand Down
4 changes: 3 additions & 1 deletion doc/tutorials/kinematical_ebsd_simulations.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@
"ni_kin_data[mask] = np.nan\n",
"\n",
"fig, axes = plt.subplots(ncols=2, layout=\"tight\")\n",
"for ax, data, title in zip(axes, [ni_kin_data, ni_dyn_data], [\"kinematical\", \"dynamical\"]):\n",
"for ax, data, title in zip(\n",
" axes, [ni_kin_data, ni_dyn_data], [\"kinematical\", \"dynamical\"]\n",
"):\n",
" ax.imshow(data, cmap=\"gray\")\n",
" ax.axis(\"off\")\n",
" ax.set(title=f\"Ni {title} 20 kV\")"
Expand Down
16 changes: 10 additions & 6 deletions doc/tutorials/pattern_matching.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,9 @@
" alpha=0.5,\n",
" label=ncc_after_ori_ref_label,\n",
")\n",
"ax.set(xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\")\n",
"ax.set(\n",
" xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\"\n",
")\n",
"ax.legend()\n",
"fig.tight_layout();"
]
Expand Down Expand Up @@ -1200,9 +1202,7 @@
"\n",
"# Place color key in bottom right corner,\n",
"# coordinates are [left, bottom, width, height]\n",
"ax_ckey = fig.add_axes(\n",
" [0.75, 0.08, 0.2, 0.2], projection=\"ipf\", symmetry=pg\n",
")\n",
"ax_ckey = fig.add_axes([0.75, 0.08, 0.2, 0.2], projection=\"ipf\", symmetry=pg)\n",
"ax_ckey.plot_ipf_color_key(show_title=False)\n",
"ax_ckey.patch.set_facecolor(\"None\")\n",
"_ = [text.set_color(\"w\") for text in ax_ckey.texts] # White [uvw]"
Expand Down Expand Up @@ -1418,7 +1418,9 @@
" alpha=0.5,\n",
" label=ncc_after_pc_ref_label,\n",
")\n",
"ax.set(xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\")\n",
"ax.set(\n",
" xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\"\n",
")\n",
"ax.legend()\n",
"fig.tight_layout();"
]
Expand Down Expand Up @@ -1643,7 +1645,9 @@
" alpha=0.5,\n",
" label=ncc_after_ori_pc_ref_label,\n",
")\n",
"ax.set(xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\")\n",
"ax.set(\n",
" xlabel=\"Normalized cross correlation (NCC) scores\", ylabel=\"Frequency\"\n",
")\n",
"ax.legend()\n",
"fig.tight_layout();"
]
Expand Down
4 changes: 3 additions & 1 deletion doc/tutorials/pattern_processing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,9 @@
"metadata": {},
"outputs": [],
"source": [
"s11 = s3.inav[0, 0].normalize_intensity(num_std=1, dtype_out=np.float32, inplace=False)\n",
"s11 = s3.inav[0, 0].normalize_intensity(\n",
" num_std=1, dtype_out=np.float32, inplace=False\n",
")\n",
"np.mean(s11.data)"
]
},
Expand Down
8 changes: 6 additions & 2 deletions doc/tutorials/pc_calibration_moving_screen_technique.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,9 @@
"metadata": {},
"outputs": [],
"source": [
"fig, axes = plt.subplots(ncols=2, sharex=True, sharey=True, figsize=(14, 7), layout=\"tight\")\n",
"fig, axes = plt.subplots(\n",
" ncols=2, sharex=True, sharey=True, figsize=(14, 7), layout=\"tight\"\n",
")\n",
"for ax, data in zip(axes, [s_in.data, s_out5mm.data]):\n",
" ax.imshow(data, cmap=\"gray\")"
]
Expand Down Expand Up @@ -276,7 +278,9 @@
"metadata": {},
"outputs": [],
"source": [
"det_ref = s_in.hough_indexing_optimize_pc(pc0=det.pc, indexer=indexer, method=\"PSO\")\n",
"det_ref = s_in.hough_indexing_optimize_pc(\n",
" pc0=det.pc, indexer=indexer, method=\"PSO\"\n",
")\n",
"\n",
"print(det.pc - det_ref.pc)"
]
Expand Down
8 changes: 6 additions & 2 deletions doc/tutorials/pc_extrapolate_plane.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@
"metadata": {},
"outputs": [],
"source": [
"r_pattern = kp.filters.distance_to_origin(s_cal.axes_manager.signal_shape[::-1], origin=(230, 220))\n",
"r_pattern = kp.filters.distance_to_origin(\n",
" s_cal.axes_manager.signal_shape[::-1], origin=(230, 220)\n",
")\n",
"signal_mask = r_pattern > 310 # Exclude pixels set to True"
]
},
Expand Down Expand Up @@ -1272,7 +1274,9 @@
"source": [
"fig, axes = plt.subplots(ncols=3, nrows=3, figsize=(12, 12))\n",
"for i, ax in enumerate(axes.ravel()):\n",
" ax.imshow(s_cal2.inav[i].data * ~signal_mask, cmap=\"gray\", vmin=-3, vmax=3)\n",
" ax.imshow(\n",
" s_cal2.inav[i].data * ~signal_mask, cmap=\"gray\", vmin=-3, vmax=3\n",
" )\n",
" ax.axis(\"off\")\n",
"\n",
" # Affine\n",
Expand Down
Loading