Skip to content

Commit

Permalink
Merge 8aa1c88 into 200c26f
Browse files Browse the repository at this point in the history
  • Loading branch information
pc494 committed Sep 14, 2020
2 parents 200c26f + 8aa1c88 commit b140ae6
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 28 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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

name: Upload Python Package

on:
release:
types: [published]

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 }}
run: |
python setup.py sdist bdist_wheel
twine upload dist/*
8 changes: 2 additions & 6 deletions diffsims/generators/diffraction_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,7 @@ def calculate_profile_data(
self,
structure,
reciprocal_radius=1.0,
magnitude_tolerance=1e-5,
minimum_intensity=1e-3,
minimum_intensity=1e-3
):
"""
Calculates a one dimensional diffraction profile for a structure.
Expand All @@ -205,9 +204,6 @@ def calculate_profile_data(
reciprocal_radius : float
The maximum radius of the sphere of reciprocal space to sample, in
reciprocal angstroms.
magnitude_tolerance : float
The minimum difference between diffraction magnitudes in reciprocal
angstroms for two peaks to be considered different.
minimum_intensity : float
The minimum intensity required for a diffraction peak to be
considered real. Deals with numerical precision issues.
Expand Down Expand Up @@ -269,7 +265,7 @@ def calculate_profile_data(
y.append(v[0])
hkls.append(k)

y = y / max(y) * 100
y = np.asarray(y) / max(y) * 100

return ProfileSimulation(x, y, hkls)

Expand Down
11 changes: 4 additions & 7 deletions diffsims/libraries/diffraction_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,17 +135,14 @@ def get_library_entry(self, phase=None, angle=None):
if phase is not None:
phase_entry = self[phase]
if angle is not None:
orientations = phase_entry["orientations"]
if isinstance(orientations, np.ndarray):
orientations = orientations.tolist()
orientation_index = _get_library_entry_from_angles(self, phase, angle)
else:
orientation_index = 0
else:
if angle is not None:
raise ValueError(
"To select a certain angle you must first specify a phase"
elif angle is not None:
raise ValueError(
"To select a certain angle you must first specify a phase"
)
else:
phase_entry = next(iter(self.values()))
orientation_index = 0

Expand Down
2 changes: 1 addition & 1 deletion diffsims/release_info.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name = "diffsims"
version = "0.2.3"
version = "0.3.0"
author = "Duncan Johnstone, Phillip Crout"
copyright = "Copyright 2017-2020, The pyXem Developers"
credits = [
Expand Down
11 changes: 1 addition & 10 deletions diffsims/sims/diffraction_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,31 +175,22 @@ class ProfileSimulation:
Magnitudes of scattering vectors.
intensities : array-like, shape [n_peaks, 1]
The kinematic intensity of the diffraction peaks.
Returns
-------
hkls: [{(h, k, l): mult}] {(h, k, l): mult} is a dict of Miller
indices for all diffracted lattice facets contributing to each
intensity.
"""

def __init__(self, magnitudes, intensities, hkls):
"""Initializes the ProfileSimulation object with data values for the
magnitudes, intensities, and hkls.
"""
self.magnitudes = magnitudes
self.intensities = intensities
self.hkls = hkls

def get_plot(self, g_max, annotate_peaks=True, with_labels=True, fontsize=12):

def get_plot(self,annotate_peaks=True, with_labels=True, fontsize=12):
"""Plots the diffraction profile simulation for the
calculate_profile_data method in DiffractionGenerator.
Parameters
----------
g_max : float
Maximum g-vector magnitude to plot.
annotate_peaks : boolean
If True, peaks are annotaed with hkl information.
with_labels : boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
"grid",
[
pytest.param(
get_local_grid(resolution=30, center=(0, 1, 0), grid_width=35),
marks=pytest.mark.xfail(reason="Downstream bug"),
get_local_grid(resolution=30, center=(0,1,0), grid_width=35)
),
get_fundamental_zone_grid(space_group=20, resolution=20),
],
Expand Down
2 changes: 1 addition & 1 deletion diffsims/tests/test_sims/test_diffraction_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def profile_simulation():


def test_plot_profile_simulation(profile_simulation):
profile_simulation.get_plot(g_max=1)
profile_simulation.get_plot()


class TestDiffractionSimulation:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"tqdm>=0.4.9",
"transforms3d",
"diffpy.structure>=3.0.0", # First Python 3 support
"orix>=0.4.0",
"orix>=0.5.0",
"numba",
"psutil",
],
Expand Down

0 comments on commit b140ae6

Please sign in to comment.