Skip to content

Commit

Permalink
Update copyright to 2019-2020, Black code style, and pre-commit
Browse files Browse the repository at this point in the history
Signed-off-by: Håkon Wiik Ånes <hwaanes@gmail.com>
  • Loading branch information
hakonanes committed Jan 1, 2020
1 parent 4f5b007 commit bcde148
Show file tree
Hide file tree
Showing 39 changed files with 1,856 additions and 1,175 deletions.
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
repos:
- repo: https://github.com/psf/black
rev: master
hooks:
- id: black
language_version: python3.7
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# The setup of different files for installation and tests on different operating
# systems are based upon HyperSpy:
# The setup of different files for installation and tests on different
# operating systems are based upon how HyperSpy does it:
# https://github.com/hyperspy/hyperspy/blob/RELEASE_next_minor/.travis.yml

language: shell
Expand Down Expand Up @@ -74,6 +74,7 @@ after_success:
before_deploy:
- export DISTRIBUTIONS=$(ls ./dist/*)

# Source: https://docs.travis-ci.com/user/deployment/pypi/
deploy:
provider: pypi
user: "__token__"
Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ standard.
Code formatting
===============

All code in KikuchiPy is formatted according to the `Style Guide for Python Code
<https://www.python.org/dev/peps/pep-0008/>`_.
The code making up KikuchiPy is formatted closely following the `Style Guide for
Python Code <https://www.python.org/dev/peps/pep-0008/>`_ with `The *Black* Code
style <https://black.readthedocs.io/en/stable/the_black_code_style.html>`_.

.. _writing-documentation:

Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[![Build Status](https://api.travis-ci.org/kikuchipy/kikuchipy.svg?branch=master)](https://travis-ci.org/kikuchipy/kikuchipy) [![Coverage Status](https://coveralls.io/repos/github/kikuchipy/kikuchipy/badge.svg?branch=master)](https://coveralls.io/github/kikuchipy/kikuchipy?branch=master) [![Documentation Status](https://readthedocs.org/projects/kikuchipy/badge/?version=latest)](https://kikuchipy.readthedocs.io/en/latest/?badge=latest)
[![Build Status](https://api.travis-ci.org/kikuchipy/kikuchipy.svg?branch=master)](https://travis-ci.org/kikuchipy/kikuchipy) [![Coverage Status](https://coveralls.io/repos/github/kikuchipy/kikuchipy/badge.svg?branch=master)](https://coveralls.io/github/kikuchipy/kikuchipy?branch=master) [![Documentation Status](https://readthedocs.org/projects/kikuchipy/badge/?version=latest)](https://kikuchipy.readthedocs.io/en/latest/?badge=latest) [![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)

*KikuchiPy is an open-source Python library for processing and analysis of
electron backscatter diffraction (EBSD) patterns.*
Expand All @@ -8,6 +8,9 @@ by the [HyperSpy](https://hyperspy.org/) library. This means that the `EBSD`
class, which has several common methods for processing of EBSD patterns, also
inherits all relevant methods from HyperSpy's `Signal2D` and `Signal` classes.

Note that the project is in an alpha stage, and there will likely be breaking
changes with each release.

KikuchiPy is released under the GPL v3 license.

#### User guide
Expand Down
7 changes: 3 additions & 4 deletions doc/background_correction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,13 @@ for the effect of varying ``kernel_size``.
S. Koizuimi, "Quantitative electron backscatter diffraction (EBSD) data
analyses using the dictionary indexing (DI) approach: Overcoming indexing
difficulties on geological materials," *American Mineralogist* **102**
(2017) [`link <https://doi.org/10.2138/am-2017-6062>`_].
(2017), doi: https://doi.org/10.2138/am-2017-6062.
.. [Jackson2019]
M. A. Jackson, E. Pascal, M. De Graef, "Dictionary Indexing of Electron
Back-Scatter Diffraction Patterns: a Hands-On Tutorial," *Integrating
Materials and Manufacturing Innovation* **8** (2019) [`link
<https://doi.org/10.1007/s40192-019-00137-4>`_].
Materials and Manufacturing Innovation* **8** (2019), doi:
https://doi.org/10.1007/s40192-019-00137-4.
.. _rescale-intensities:

Expand Down
67 changes: 67 additions & 0 deletions doc/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,70 @@
=========
Changelog
=========

0.1.0 / 2020-01-02
==================

We're happy to announce the release of KikuchiPy v0.1.0!

KikuchiPy is an open-source Python library for processing and analysis of
electron backscatter diffraction (EBSD) patterns. The library builds upon the
tools for multi-dimensional data analysis provided by the HyperSpy library.

For more information, a user guide, and the full reference API documentation,
please visit: https://kikuchipy.readthedocs.io

This is the initial pre-release, where things start to get serious... seriously
fun!

Features
--------
- Load EBSD patterns and metadata from the NORDIF binary format (.dat) and
Bruker Nano and EDAX TSL's h5ebsd formats (.h5) into an ``EBSD`` object, e.g.
``s``, based upon HyperSpy's `Signal2D` class, using ``s = kp.load()``. This
ensures easy access to patterns and metadata in the attributes ``s.data`` and
``s.metadata``, respectively.
- Save EBSD patterns to the NORDIF binary format (.dat) and our own h5ebsd
format (.h5), using ``s.save()``. Both formats are readable by EMsoft's NORDIF
and EMEBSD readers, respectively.
- Lazy alternative for all functionality (except some multivariate analysis
algorithsm), meaning all operations on a scan, including plotting, can be done
loading only necessary parts of the scan into memory at a time.
- Visualize patterns easily with HyperSpy's powerful and versatile ``s.plot()``.
Any image, e.g. a virtual backscatter electron image, quality map, phase map
or orientation map, can be used to navigate in. Multiple scans of the same
size, e.g. best matching simulated patterns to a scan, can be plotted
simultaneously alongside the experimental patterns with HyperSpy's
``plot_signals()``.
- Virtual backscatter electron (VBSE) imaging is easily performed with
``s.virtual_backscatter_electron_imaging()`` based upon similar functionality
in pyXem. Arbitrary region of interests can be used, and the corresponding
VBSE image can be inspected interactively. Finally, the VBSE image can be
obtained in a new ``EBSD`` object with ``vbse = s.get_virtual_image()``,
before writing the data to an image file in your desired format with
matplotlib's ``imsave('filename.png', vbse.data)``.
- Change scan and pattern size, e.g. by cropping on the detector or extracting
a region of interest, by using ``s.isig`` or ``s.inav``, respectively.
Patterns can be binned (upscaled or downscaled) using ``s.rebin``. These
methods are provided by HyperSpy.
- Perform static and dynamic background correction by subtraction or division
with ``s.static_background_correction()`` and
``s.dynamic_background_correction()``. For the former connection, relative
intensities between patterns can be kept if desired.
- Perform adaptive histogram equalization by setting an appropriate contextual
region (kernel size) with ``s.adaptive_histogram_equalization()``.
- Rescale pattern intensities to desired data type and range using
``s.rescale_intensities()``.
- Multivariate statistical analysis, like principal component analysis and many
other decomposition algorithms, can be easily performed with
``s.decomposition()``, provided by HyperSpy.
- Since the ``EBSD`` class is based upon HyperSpy's ``Signal2D`` class, which
itself is based upon their ``BaseSignal`` class, all functionality available
to ``Signal2D`` is also available to the ``EBSD`` class. See HyperSpy's user
guide (http://hyperspy.org/hyperspy-doc/current/user_guide/tools.html) for
details.

Contributions to this release (alphabetical by first name)
----------------------------------------------------------
- Håkon Wiik Ånes
- Tina Bergh
5 changes: 0 additions & 5 deletions doc/load_save_patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ containing only ``Scan 1``, by passing:
Here the h5ebsd :func:`~kikuchipy.io.plugins.h5ebsd.file_writer` is called.

.. [Jackson2014] M. A. Jackson, M. A. Groeber, M. D. Uchic, D. J. Rowenhorst
and M. De Graef, "h5ebsd: an archival data format for electron back-scatter
diffraction data sets," *Integrating Materials and Manufacturing Innovation*
**3** (2014) [`link <https://doi.org/10.1186/2193-9772-3-4>`_].
.. _nordif-format:

NORDIF binary
Expand Down
66 changes: 0 additions & 66 deletions doc/release/release_0.1.rst

This file was deleted.

2 changes: 1 addition & 1 deletion doc/visualizing_patterns.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Visualizing patterns

The :class:`~kikuchipy.signals.ebsd.EBSD` object has a powerful and versatile
:meth:`~hyperspy.signal.BaseSignal.plot` method provided by HyperSpy, and its
uses are greatly detailed in the `HyperSpy user guide
uses are greatly detailed in HyperSpy's `visualisation user guide
<http://hyperspy.org/hyperspy-doc/current/user_guide/visualisation.html>`_. This
section details example uses specific to
:class:`~kikuchipy.signals.ebsd.EBSD` objects.
Expand Down
2 changes: 1 addition & 1 deletion kikuchipy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 The KikuchiPy developers
# Copyright 2019-2020 The KikuchiPy developers
#
# This file is part of KikuchiPy.
#
Expand Down
18 changes: 11 additions & 7 deletions kikuchipy/conftest.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 The KikuchiPy developers
# Copyright 2019-2020 The KikuchiPy developers
#
# This file is part of KikuchiPy.
#
Expand Down Expand Up @@ -33,24 +33,28 @@ def dummy_signal():
methods using this signal (as input) to hard-coded outputs.
"""

# fmt: off
dummy_array = np.array(
[5, 6, 5, 7, 6, 5, 6, 1, 0, 9, 7, 8, 7, 0, 8, 8, 7, 6, 0, 3, 3, 5, 2, 9,
3, 3, 9, 8, 1, 7, 6, 4, 8, 8, 2, 2, 4, 0, 9, 0, 1, 0, 2, 2, 5, 8, 6, 0,
4, 7, 7, 7, 6, 0, 4, 1, 6, 3, 4, 0, 1, 1, 0, 5, 9, 8, 4, 6, 0, 2, 9, 2,
9, 4, 3, 6, 5, 6, 2, 5, 9], dtype=np.uint8).reshape((3, 3, 3, 3))
9, 4, 3, 6, 5, 6, 2, 5, 9],
dtype=np.uint8
).reshape((3, 3, 3, 3))
# fmt: on

return kp.signals.EBSD(dummy_array)


@pytest.fixture
def dummy_background():
"""Dummy static background pattern for the dummy signal. If this
is changed, all tests using this background will fail since they
"""Dummy static background pattern for the dummy signal. If this is
changed, all tests using this background will fail since they
compare the output from methods using this background (as input) to
hard-coded outputs.
"""

return np.array(
[5, 4, 5, 4, 3, 4, 4, 4, 3], dtype=np.uint8).reshape((3, 3))
return np.array([5, 4, 5, 4, 3, 4, 4, 4, 3], dtype=np.uint8).reshape((3, 3))


@pytest.fixture()
Expand All @@ -60,6 +64,6 @@ def save_path_h5ebsd():
"""

with tempfile.TemporaryDirectory() as tmp:
file_path = os.path.join(tmp, 'patterns_temp.h5')
file_path = os.path.join(tmp, "patterns_temp.h5")
yield file_path
gc.collect()
2 changes: 1 addition & 1 deletion kikuchipy/hyperspy_extension.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 The KikuchiPy developers
# Copyright 2019-2020 The KikuchiPy developers
#
# This file is part of KikuchiPy.
#
Expand Down
2 changes: 1 addition & 1 deletion kikuchipy/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright 2019 The KikuchiPy developers
# Copyright 2019-2020 The KikuchiPy developers
#
# This file is part of KikuchiPy.
#
Expand Down
Loading

0 comments on commit bcde148

Please sign in to comment.