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/.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 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 }} 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" + } + ] +} diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 82de0c90..39987d9e 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-30 - 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. - The Laue group representing the rotation list sampling of "hexagonal" from 6/m to 6/mmm. - Loosened the angle tolerance in ``DiffractionLibrary.get_library_entry()`` from 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: diff --git a/diffsims/generators/rotation_list_generators.py b/diffsims/generators/rotation_list_generators.py index 1239f6eb..488f7c23 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/release_info.py b/diffsims/release_info.py index 124392ab..11766017 100644 --- a/diffsims/release_info.py +++ b/diffsims/release_info.py @@ -1,27 +1,30 @@ name = "diffsims" -version = "0.5.dev0" +version = "0.5.0rc1" 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" diff --git a/diffsims/tests/generators/test_rotation_list_generator.py b/diffsims/tests/generators/test_rotation_list_generator.py index b81826e7..829b7539 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.parametrize( diff --git a/diffsims/tests/sims/test_diffraction_simulation.py b/diffsims/tests/sims/test_diffraction_simulation.py index 90e3b951..8c3c0252 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(): @@ -140,6 +142,7 @@ def test_addition(self, diffraction_simulation): ] ), ) + assert sim.size == 4 def test_extend(self, diffraction_simulation): diffraction_simulation.extend(diffraction_simulation) 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: diff --git a/setup.py b/setup.py index 69fce407..e242df8f 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,7 @@ "matplotlib >= 3.3", "numba", "numpy >= 1.17", - "orix >= 0.5.0", + "orix >= 0.9", "psutil", "scipy >= 1.0", "tqdm >= 4.9",