From 26d1fed7e9297e0babd5bcc78c17cead63ed99c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:18:19 +0200 Subject: [PATCH 01/16] Remove use of deprecated NumPy np.float MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- diffsims/crystallography/reciprocal_lattice_point.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diffsims/crystallography/reciprocal_lattice_point.py b/diffsims/crystallography/reciprocal_lattice_point.py index 489b4537..e01e64af 100644 --- a/diffsims/crystallography/reciprocal_lattice_point.py +++ b/diffsims/crystallography/reciprocal_lattice_point.py @@ -29,7 +29,7 @@ ) -_FLOAT_EPS = np.finfo(np.float).eps # Used to round values below 1e-16 to zero +_FLOAT_EPS = np.finfo(float).eps # Used to round values below 1e-16 to zero class ReciprocalLatticePoint: From 886b62ab0738affde8621509ceaa568f2eb94a93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:21:01 +0200 Subject: [PATCH 02/16] Update contributors list (add and sort) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- diffsims/release_info.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/diffsims/release_info.py b/diffsims/release_info.py index 124392ab..9efff903 100644 --- a/diffsims/release_info.py +++ b/diffsims/release_info.py @@ -1,27 +1,30 @@ name = "diffsims" -version = "0.5.dev0" +version = "0.5.0" author = "Duncan Johnstone, Phillip Crout" -copyright = "Copyright 2017-2022, The pyXem developers" +copyright = "Copyright 2017-2022, The diffsims developers" +# Initial committer first, then listed by line additions credits = [ "Duncan Johnstone", "Phillip Crout", + "Håkon Wiik Ånes", + "Eric Prestat", + "Rob Tovey", "Simon Høgås", "Ben Martineau", - "Isabel Wood", - "Håkon Wiik Ånes", + "Niels Cautaerts", "Joonatan Laulainen", - "Stef Smeets", + "Isabel Wood", "Sean Collins", - "Endre Jacobsen", - "Niels Cautaerts", - "Eric Prestat", + "Stef Smeets", + "Alex Borrelli", "Tiarnan Doherty", "Jedrzej Morzy", - "Tomas Ostasevicius", - "Alex Borrelli", + "Endre Jacobsen", "Tina Bergh", + "Tomas Ostasevicius", + "Eirik Opheim", ] -license = "GPLv3" +license = "GPLv3+" maintainer = "Duncan Johnstone, Phillip Crout, Håkon Wiik Ånes" email = "pyxem.team@gmail.com" status = "Development" From 2c23aa0055895ca9dbfed533874628b21fa195ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:21:17 +0200 Subject: [PATCH 03/16] Update license identifier to GPLv3+, temp. set orix==0.9.0rc2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- setup.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 69fce407..15fb2fdd 100644 --- a/setup.py +++ b/setup.py @@ -50,7 +50,10 @@ "Programming Language :: Python :: 3.10", "Development Status :: 4 - Beta", "Intended Audience :: Science/Research", - "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", + ( + "License :: OSI Approved :: GNU General Public License v3 or later " + "(GPLv3+)" + ), "Natural Language :: English", "Operating System :: OS Independent", "Topic :: Scientific/Engineering", @@ -63,7 +66,8 @@ "matplotlib >= 3.3", "numba", "numpy >= 1.17", - "orix >= 0.5.0", + # TODO: Revert orix minimal to >= 0.4 once 0.9.0rc2 is confirmed to work + "orix == 0.9.0rc2", "psutil", "scipy >= 1.0", "tqdm >= 4.9", From a7d422c0081ada6c45a0d94324a08224a8909f7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:33:44 +0200 Subject: [PATCH 04/16] Minor cosmetic updates to CI build config file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- .github/workflows/build.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1af73cd2..98903d5b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -9,9 +9,12 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - name: Install dependencies run: pip install manifix + - name: Check MANIFEST.in file run: python setup.py manifix @@ -31,31 +34,39 @@ jobs: - os: ubuntu-latest python-version: 3.6 OLDEST_SUPPORTED_VERSION: true - # orix requires matplotlib 3.3, matplotlib 3.3 requires numpy 1.15 - # numba requires scipy==1.0 DEPENDENCIES: diffpy.structure==3.0.0 matplotlib==3.3 numpy==1.17 orix==0.5.0 scipy==1.0 tqdm==4.9 LABEL: -oldest steps: - uses: actions/checkout@v2 + - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} + - name: Display Python and pip versions - run: python -V; pip -V - - name: Install depedencies and package + run: | + python -V + pip -V + + - name: Install dependencies and package shell: bash run: pip install -U -e .'[tests]' + - name: Install oldest supported version if: ${{ matrix.OLDEST_SUPPORTED_VERSION }} run: pip install ${{ matrix.DEPENDENCIES }} + - name: Display package versions run: pip list + - name: Run tests run: pytest --cov=diffsims --pyargs diffsims + - name: Generate line coverage if: ${{ matrix.os == 'ubuntu-latest' }} run: coverage report --show-missing + - name: Upload coverage to Coveralls if: ${{ matrix.os == 'ubuntu-latest' }} uses: AndreMiras/coveralls-python-action@develop From 7883b8aa2d257dec9b1453c2c5a0b0698c1ce81f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:34:18 +0200 Subject: [PATCH 05/16] Update CI publish workflow file to use PyPI tokens MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- .github/workflows/python-publish.yml | 42 ++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index 03760727..beb6d67d 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -1,31 +1,49 @@ -# This workflows will upload a Python Package using Twine when a release is created -# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries +# This workflow runs when a tagged release is created or it is triggered manually. +# For more information see: +# - Python docs: https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ +# - GitHub action: https://github.com/marketplace/actions/pypi-publish +# - GitHub docs: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries +# The source distribution (sdist) is built with the `build` package +# (https://pypa-build.readthedocs.io/en/stable/index.html). +# The sdist is attempted uploaded to TestPyPI and PyPI whenever the workflow is run -name: Upload Python Package +name: Upload to PyPI on: release: types: [published] + workflow_dispatch: + workflow: "*" jobs: deploy: - runs-on: ubuntu-latest - steps: - uses: actions/checkout@v2 + - name: Set up Python uses: actions/setup-python@v2 with: python-version: '3.x' + - name: Install dependencies run: | python -m pip install --upgrade pip - pip install setuptools wheel twine - - name: Build and publish - env: - TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }} - TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }} + pip install build + + - name: Build package run: | - python setup.py sdist bdist_wheel - twine upload dist/* + python -m build + + - name: Publish package to TestPyPI + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.TEST_PYPI_API_TOKEN }} + repository_url: https://test.pypi.org/legacy/ + + - name: Publish package to PyPI + uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29 + with: + user: __token__ + password: ${{ secrets.PYPI_API_TOKEN }} From ad99da6071d5ec87e22c8726843491885e1860eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 12 May 2022 16:38:09 +0200 Subject: [PATCH 06/16] Bump release to 0.5.0rc1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- diffsims/release_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/diffsims/release_info.py b/diffsims/release_info.py index 9efff903..11766017 100644 --- a/diffsims/release_info.py +++ b/diffsims/release_info.py @@ -1,5 +1,5 @@ name = "diffsims" -version = "0.5.0" +version = "0.5.0rc1" author = "Duncan Johnstone, Phillip Crout" copyright = "Copyright 2017-2022, The diffsims developers" # Initial committer first, then listed by line additions From 98e5136d32bd53a3e799d5d555c6bd4f5d78f3cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Sun, 15 May 2022 13:46:44 +0200 Subject: [PATCH 07/16] Add contributors file for Zenodo, add TODO in PR template MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- .github/PULL_REQUEST_TEMPLATE.md | 2 + .zenodo.json | 65 ++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+) create mode 100644 .zenodo.json diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index b37ab67b..3ebe2a26 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -19,3 +19,5 @@ - [ ] New functions are imported in corresponding `__init__.py`. - [ ] New features, API changes, and deprecations are mentioned in the unreleased section in `CHANGELOG.rst`. +- [ ] Contributor(s) are listed correctly in `credits` in `diffsims/release_info.py` and + in `.zenodo.json`. \ No newline at end of file diff --git a/.zenodo.json b/.zenodo.json new file mode 100644 index 00000000..6b19a039 --- /dev/null +++ b/.zenodo.json @@ -0,0 +1,65 @@ +{ + "creators": [ + { + "name": "Duncan Johnstone" + }, + { + "name":"Phillip Crout", + "orcid": "0000-0001-5754-0938" + }, + { + "name":"Håkon Wiik Ånes", + "orcid": "0000-0002-1213-2911", + "affiliation": "Norwegian University of Science and Technology" + }, + { + "name":"Eric Prestat" + }, + { + "name":"Rob Tovey" + }, + { + "name":"Simon Høgås" + }, + { + "name":"Ben Martineau" + }, + { + "name":"Joonatan Laulainen" + }, + { + "name":"Niels Cautaerts", + "orcid": "0000-0002-6402-9879" + }, + { + "name":"Isabel Wood" + }, + { + "name":"Sean Collins" + }, + { + "name":"Stef Smeets" + }, + { + "name":"Alex Borrelli" + }, + { + "name": "Tiarnan Doherty" + }, + { + "name":"Jedrzej Morzy" + }, + { + "name":"Endre Jacobsen" + }, + { + "name":"Tina Bergh" + }, + { + "name":"Tomas Ostasevicius" + }, + { + "name":"Eirik Opheim" + } + ] +} From 01667ce474d488ee67eef47d43a01ec69998afd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Wed, 18 May 2022 17:43:56 +0200 Subject: [PATCH 08/16] Revert minimal orix version to 0.5 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- setup.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/setup.py b/setup.py index 15fb2fdd..65cf3bb3 100644 --- a/setup.py +++ b/setup.py @@ -66,8 +66,7 @@ "matplotlib >= 3.3", "numba", "numpy >= 1.17", - # TODO: Revert orix minimal to >= 0.4 once 0.9.0rc2 is confirmed to work - "orix == 0.9.0rc2", + "orix >= 0.5", "psutil", "scipy >= 1.0", "tqdm >= 4.9", From 30e7bc42ce267386e881684843a5fefecf7833f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Wed, 18 May 2022 18:16:07 +0200 Subject: [PATCH 09/16] Remove use of "convention" parameter in Rotation.from_euler() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- diffsims/generators/rotation_list_generators.py | 10 +++++----- .../tests/generators/test_rotation_list_generator.py | 5 +++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/diffsims/generators/rotation_list_generators.py b/diffsims/generators/rotation_list_generators.py index 4577106d..e4e3a1c7 100644 --- a/diffsims/generators/rotation_list_generators.py +++ b/diffsims/generators/rotation_list_generators.py @@ -67,7 +67,7 @@ def get_list_from_orix(grid, rounding=2): rotation_list : list of tuples A rotation list """ - z = grid.to_euler(convention="bunge") + z = grid.to_euler() rotation_list = z.data.tolist() i = 0 while i < len(rotation_list): @@ -122,7 +122,7 @@ def get_local_grid(resolution=2, center=None, grid_width=10): """ if isinstance(center, tuple): z = np.deg2rad(np.asarray(center)) - center = Rotation.from_euler(z, convention="bunge", direction="crystal2lab") + center = Rotation.from_euler(z) orix_grid = get_sample_local( resolution=resolution, center=center, grid_width=grid_width @@ -153,11 +153,11 @@ def get_grid_around_beam_direction(beam_rotation, resolution, angular_range=(0, Examples -------- >>> from diffsims.generators.zap_map_generator import get_rotation_from_z_to_direction - >>> beam_rotation = get_rotation_from_z_to_direction(structure,[1,1,1]) - >>> grid = get_grid_around_beam_direction(beam_rotation,1) + >>> beam_rotation = get_rotation_from_z_to_direction(structure, [1, 1, 1]) + >>> grid = get_grid_around_beam_direction(beam_rotation, 1) """ z = np.deg2rad(np.asarray(beam_rotation)) - beam_rotation = Rotation.from_euler(z, convention="bunge", direction="crystal2lab") + beam_rotation = Rotation.from_euler(z) angles = np.deg2rad( np.arange(start=angular_range[0], stop=angular_range[1], step=resolution) diff --git a/diffsims/tests/generators/test_rotation_list_generator.py b/diffsims/tests/generators/test_rotation_list_generator.py index cd8160eb..91edc14a 100644 --- a/diffsims/tests/generators/test_rotation_list_generator.py +++ b/diffsims/tests/generators/test_rotation_list_generator.py @@ -16,8 +16,9 @@ # You should have received a copy of the GNU General Public License # along with diffsims. If not, see . -import pytest import numpy as np +import pytest + from diffsims.generators.rotation_list_generators import ( get_local_grid, get_grid_around_beam_direction, @@ -73,7 +74,7 @@ def test_get_grid_around_beam_direction(): ], ) def test_get_beam_directions_grid(crystal_system, mesh): - grid = get_beam_directions_grid(crystal_system, 5, mesh=mesh) + _ = get_beam_directions_grid(crystal_system, 5, mesh=mesh) @pytest.mark.xfail() From d2e06dc28c98bb00456db6522b36dbf444d043a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Wed, 18 May 2022 18:16:58 +0200 Subject: [PATCH 10/16] Update API reference locations of dependencies, linkcode_resolve() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- doc/conf.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/conf.py b/doc/conf.py index b3d0547a..582f551d 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -21,7 +21,7 @@ import re import sys -from diffsims import __author__, __version__, __file__ +from diffsims import __author__, __file__, __version__ # -- Project information ----------------------------------------------------- @@ -50,11 +50,11 @@ # Create links to references within diffsims' documentation to these packages intersphinx_mapping = { "diffpy.structure": ("https://www.diffpy.org/diffpy.structure", None), - "matplotlib": ("https://matplotlib.org", None), + "matplotlib": ("https://matplotlib.org/stable", None), "numpy": ("https://numpy.org/doc/stable", None), "orix": ("https://orix.readthedocs.io/en/stable", None), "python": ("https://docs.python.org/3", None), - "scipy": ("https://docs.scipy.org/doc/scipy/reference", None), + "scipy": ("https://docs.scipy.org/doc/scipy", None), } # Add any paths that contain templates here, relative to this directory. @@ -86,7 +86,7 @@ def linkcode_resolve(domain, info): """Determine the URL corresponding to Python object. This is taken from SciPy's conf.py: - https://github.com/scipy/scipy/blob/master/doc/source/conf.py. + https://github.com/scipy/scipy/blob/develop/doc/source/conf.py. """ if domain != "py": return None @@ -131,12 +131,12 @@ def linkcode_resolve(domain, info): fn = relpath(fn, start=startdir).replace(os.path.sep, "/") if fn.startswith("diffsims/"): - m = re.match(r"^.*dev0\+([a-f0-9]+)$", __version__) + m = re.match(r"^.*dev0\+([a-f\d]+)$", __version__) pre_link = "https://github.com/pyxem/diffsims/blob/" if m: return pre_link + "%s/%s%s" % (m.group(1), fn, linespec) elif "dev" in __version__: - return pre_link + "master/%s%s" % (fn, linespec) + return pre_link + "develop/%s%s" % (fn, linespec) else: return pre_link + "v%s/%s%s" % (__version__, fn, linespec) else: From e4ff1c509017b731e6794c28917ac33ced6b626c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Wed, 18 May 2022 18:17:21 +0200 Subject: [PATCH 11/16] Update "Unreleased" in changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- CHANGELOG.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 91514ef0..01bece50 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,8 +8,8 @@ The format is based on `Keep a Changelog `_ and this project adheres to `Semantic Versioning `_. -Unreleased -========== +2022-05-20 - version 0.5.0 +========================== Added ----- From e6ddee2979dcc6100238c145e2f6a0649a52878c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 19 May 2022 19:49:28 +0200 Subject: [PATCH 12/16] Bump min. version of orix to 0.9 due to changes in from_euler() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- CHANGELOG.rst | 4 ++-- setup.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 01bece50..aab3b033 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,7 +8,7 @@ The format is based on `Keep a Changelog `_ and this project adheres to `Semantic Versioning `_. -2022-05-20 - version 0.5.0 +2022-05-25 - version 0.5.0 ========================== Added @@ -20,7 +20,7 @@ Added Changed ------- -- Minimal version of dependencies numpy >= 1.17 and tqdm >= 4.9 +- Minimal version of dependencies orix >= 0.9, numpy >= 1.17 and tqdm >= 4.9 2021-04-16 - version 0.4.2 ========================== diff --git a/setup.py b/setup.py index 65cf3bb3..e242df8f 100644 --- a/setup.py +++ b/setup.py @@ -66,7 +66,7 @@ "matplotlib >= 3.3", "numba", "numpy >= 1.17", - "orix >= 0.5", + "orix >= 0.9", "psutil", "scipy >= 1.0", "tqdm >= 4.9", From cfe73458ab36f1ca977f3a64a9e187877a09fc91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Thu, 19 May 2022 19:50:08 +0200 Subject: [PATCH 13/16] Test DiffractionSimulation.size MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- diffsims/tests/sims/test_diffraction_simulation.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/diffsims/tests/sims/test_diffraction_simulation.py b/diffsims/tests/sims/test_diffraction_simulation.py index 01eae28f..55ad8a03 100644 --- a/diffsims/tests/sims/test_diffraction_simulation.py +++ b/diffsims/tests/sims/test_diffraction_simulation.py @@ -18,8 +18,10 @@ import numpy as np import pytest -from diffsims.sims.diffraction_simulation import DiffractionSimulation -from diffsims.sims.diffraction_simulation import ProfileSimulation + +from diffsims.sims.diffraction_simulation import ( + DiffractionSimulation, ProfileSimulation +) def test_wrong_calibration_setting(): @@ -137,6 +139,7 @@ def test_addition(self, diffraction_simulation): ] ), ) + assert sim.size == 4 def test_extend(self, diffraction_simulation): diffraction_simulation.extend(diffraction_simulation) From 1180b4b19cd0d97c684d5bbce9751ad6c379bef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Fri, 20 May 2022 10:59:24 +0200 Subject: [PATCH 14/16] Touch up imports in rotation list generators file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- .../generators/rotation_list_generators.py | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/diffsims/generators/rotation_list_generators.py b/diffsims/generators/rotation_list_generators.py index e4e3a1c7..bc1ec865 100644 --- a/diffsims/generators/rotation_list_generators.py +++ b/diffsims/generators/rotation_list_generators.py @@ -22,9 +22,9 @@ import numpy as np -from orix.sampling.sample_generators import get_sample_fundamental, get_sample_local -from orix.quaternion.rotation import Rotation -from orix.vector.neo_euler import AxAngle +from orix.quaternion import Rotation +from orix.sampling import get_sample_fundamental, get_sample_local +from orix.vector import AxAngle from diffsims.utils.sim_utils import uvtw_to_uvw from diffsims.generators.sphere_mesh_generators import ( @@ -43,7 +43,8 @@ # https://github.com/pyxem/orix/issues/125#issuecomment-698956290. crystal_system_dictionary = { "cubic": [(0, 0, 1), (1, 1, 1), (1, 0, 1)], - "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (2, -1, -1, 0)], +# "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (2, -1, -1, 0)], + "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (-1, 2, -1, 0)], "trigonal": [(0, 0, 0, 1), (-2, 1, 1, 0), (-1, 2, -1, 0)], "tetragonal": [(0, 0, 1), (1, 0, 0), (1, 1, 0)], "orthorhombic": [(0, 0, 1), (-1, 0, 0), (0, 1, 0)], @@ -79,7 +80,7 @@ def get_list_from_orix(grid, rounding=2): return rotation_list -def get_fundamental_zone_grid(resolution=2, point_group=None, space_group=None): +def get_fundamental_zone_grid(resolution=2, space_group=None): """ Generates an equispaced grid of rotations within a fundamental zone. @@ -87,8 +88,6 @@ def get_fundamental_zone_grid(resolution=2, point_group=None, space_group=None): ---------- resolution : float, optional The characteristic distance between a rotation and its neighbour (degrees) - point_group : orix.quaternion.symmetry.Symmetry, optional - One of the 11 proper point groups, defaults to None space_group: int, optional Between 1 and 231, defaults to None @@ -99,7 +98,7 @@ def get_fundamental_zone_grid(resolution=2, point_group=None, space_group=None): """ orix_grid = get_sample_fundamental(resolution=resolution, space_group=space_group) - rotation_list = get_list_from_orix(orix_grid, rounding=2) + rotation_list = get_list_from_orix(orix_grid) return rotation_list @@ -127,7 +126,7 @@ def get_local_grid(resolution=2, center=None, grid_width=10): orix_grid = get_sample_local( resolution=resolution, center=center, grid_width=grid_width ) - rotation_list = get_list_from_orix(orix_grid, rounding=2) + rotation_list = get_list_from_orix(orix_grid) return rotation_list @@ -166,7 +165,7 @@ def get_grid_around_beam_direction(beam_rotation, resolution, angular_range=(0, in_plane_rotation = Rotation.from_neo_euler(AxAngle.from_axes_angles(axes, angles)) orix_grid = beam_rotation * in_plane_rotation - rotation_list = get_list_from_orix(orix_grid, rounding=2) + rotation_list = get_list_from_orix(orix_grid) return rotation_list @@ -179,15 +178,15 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e Parameters ---------- crystal_system : str - Allowed are: 'cubic','hexagonal','trigonal','tetragonal', - 'orthorhombic','monoclinic','triclinic' + Allowed are: 'cubic', 'hexagonal', 'trigonal', 'tetragonal', + 'orthorhombic', 'monoclinic', 'triclinic'. resolution : float - An angle in degrees representing the worst-case angular - distance to a first nearest neighbor grid point. + An angle in degrees representing the worst-case angular distance + to a first nearest neighbor grid point. mesh : str Type of meshing of the sphere that defines how the grid is created. Options are: uv_sphere, normalized_cube, - spherified_cube_corner (default), spherified_cube_edge, + spherified_cube_corner, spherified_cube_edge (default), icosahedral, random. Returns @@ -221,10 +220,9 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e points_in_cartesians = get_random_sphere_vertices(resolution) else: raise NotImplementedError( - f"The mesh {mesh} is not recognized. " - f"Please use: uv_sphere, normalized_cube, " - f"spherified_cube_edge, " - f"spherified_cube_corner, icosahedral, random" + f"The mesh {mesh} is not recognized. Please use: uv_sphere, " + "normalized_cube, spherified_cube_edge, spherified_cube_corner, " + "icosahedral, random" ) # crop to stereographic triangle which depends on crystal system @@ -232,9 +230,6 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e if crystal_system == "triclinic": return beam_directions_grid_to_euler(points_in_cartesians) if crystal_system == "monoclinic": - points_in_cartesian = points_in_cartesians[ - np.dot(np.array([0, 0, 1]), points_in_cartesians.T) >= epsilon - ] points_in_cartesian = points_in_cartesians[ np.dot(np.array([1, 0, 0]), points_in_cartesians.T) >= epsilon ] @@ -261,4 +256,5 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e ] angle_grid = beam_directions_grid_to_euler(points_in_cartesians) + return angle_grid From 7c010b063fb65c3e2b2f46aae028289c6a2231e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Fri, 20 May 2022 11:55:45 +0200 Subject: [PATCH 15/16] Revert "Touch up imports in rotation list generators file" This reverts commit 1180b4b19cd0d97c684d5bbce9751ad6c379bef7. --- .../generators/rotation_list_generators.py | 40 ++++++++++--------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/diffsims/generators/rotation_list_generators.py b/diffsims/generators/rotation_list_generators.py index bc1ec865..e4e3a1c7 100644 --- a/diffsims/generators/rotation_list_generators.py +++ b/diffsims/generators/rotation_list_generators.py @@ -22,9 +22,9 @@ import numpy as np -from orix.quaternion import Rotation -from orix.sampling import get_sample_fundamental, get_sample_local -from orix.vector import AxAngle +from orix.sampling.sample_generators import get_sample_fundamental, get_sample_local +from orix.quaternion.rotation import Rotation +from orix.vector.neo_euler import AxAngle from diffsims.utils.sim_utils import uvtw_to_uvw from diffsims.generators.sphere_mesh_generators import ( @@ -43,8 +43,7 @@ # https://github.com/pyxem/orix/issues/125#issuecomment-698956290. crystal_system_dictionary = { "cubic": [(0, 0, 1), (1, 1, 1), (1, 0, 1)], -# "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (2, -1, -1, 0)], - "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (-1, 2, -1, 0)], + "hexagonal": [(0, 0, 0, 1), (1, 0, -1, 0), (2, -1, -1, 0)], "trigonal": [(0, 0, 0, 1), (-2, 1, 1, 0), (-1, 2, -1, 0)], "tetragonal": [(0, 0, 1), (1, 0, 0), (1, 1, 0)], "orthorhombic": [(0, 0, 1), (-1, 0, 0), (0, 1, 0)], @@ -80,7 +79,7 @@ def get_list_from_orix(grid, rounding=2): return rotation_list -def get_fundamental_zone_grid(resolution=2, space_group=None): +def get_fundamental_zone_grid(resolution=2, point_group=None, space_group=None): """ Generates an equispaced grid of rotations within a fundamental zone. @@ -88,6 +87,8 @@ def get_fundamental_zone_grid(resolution=2, space_group=None): ---------- resolution : float, optional The characteristic distance between a rotation and its neighbour (degrees) + point_group : orix.quaternion.symmetry.Symmetry, optional + One of the 11 proper point groups, defaults to None space_group: int, optional Between 1 and 231, defaults to None @@ -98,7 +99,7 @@ def get_fundamental_zone_grid(resolution=2, space_group=None): """ orix_grid = get_sample_fundamental(resolution=resolution, space_group=space_group) - rotation_list = get_list_from_orix(orix_grid) + rotation_list = get_list_from_orix(orix_grid, rounding=2) return rotation_list @@ -126,7 +127,7 @@ def get_local_grid(resolution=2, center=None, grid_width=10): orix_grid = get_sample_local( resolution=resolution, center=center, grid_width=grid_width ) - rotation_list = get_list_from_orix(orix_grid) + rotation_list = get_list_from_orix(orix_grid, rounding=2) return rotation_list @@ -165,7 +166,7 @@ def get_grid_around_beam_direction(beam_rotation, resolution, angular_range=(0, in_plane_rotation = Rotation.from_neo_euler(AxAngle.from_axes_angles(axes, angles)) orix_grid = beam_rotation * in_plane_rotation - rotation_list = get_list_from_orix(orix_grid) + rotation_list = get_list_from_orix(orix_grid, rounding=2) return rotation_list @@ -178,15 +179,15 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e Parameters ---------- crystal_system : str - Allowed are: 'cubic', 'hexagonal', 'trigonal', 'tetragonal', - 'orthorhombic', 'monoclinic', 'triclinic'. + Allowed are: 'cubic','hexagonal','trigonal','tetragonal', + 'orthorhombic','monoclinic','triclinic' resolution : float - An angle in degrees representing the worst-case angular distance - to a first nearest neighbor grid point. + An angle in degrees representing the worst-case angular + distance to a first nearest neighbor grid point. mesh : str Type of meshing of the sphere that defines how the grid is created. Options are: uv_sphere, normalized_cube, - spherified_cube_corner, spherified_cube_edge (default), + spherified_cube_corner (default), spherified_cube_edge, icosahedral, random. Returns @@ -220,9 +221,10 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e points_in_cartesians = get_random_sphere_vertices(resolution) else: raise NotImplementedError( - f"The mesh {mesh} is not recognized. Please use: uv_sphere, " - "normalized_cube, spherified_cube_edge, spherified_cube_corner, " - "icosahedral, random" + f"The mesh {mesh} is not recognized. " + f"Please use: uv_sphere, normalized_cube, " + f"spherified_cube_edge, " + f"spherified_cube_corner, icosahedral, random" ) # crop to stereographic triangle which depends on crystal system @@ -230,6 +232,9 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e if crystal_system == "triclinic": return beam_directions_grid_to_euler(points_in_cartesians) if crystal_system == "monoclinic": + points_in_cartesian = points_in_cartesians[ + np.dot(np.array([0, 0, 1]), points_in_cartesians.T) >= epsilon + ] points_in_cartesian = points_in_cartesians[ np.dot(np.array([1, 0, 0]), points_in_cartesians.T) >= epsilon ] @@ -256,5 +261,4 @@ def get_beam_directions_grid(crystal_system, resolution, mesh="spherified_cube_e ] angle_grid = beam_directions_grid_to_euler(points_in_cartesians) - return angle_grid From 64910fa4ae3dda2999fe3e6d528d698294e5e48b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5kon=20Wiik=20=C3=85nes?= Date: Fri, 27 May 2022 20:22:08 +0200 Subject: [PATCH 16/16] Update date in changelog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Håkon Wiik Ånes --- CHANGELOG.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index aab3b033..9da6ca1c 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -8,7 +8,7 @@ The format is based on `Keep a Changelog `_ and this project adheres to `Semantic Versioning `_. -2022-05-25 - version 0.5.0 +2022-05-30 - version 0.5.0 ========================== Added