Skip to content

Commit ddb903d

Browse files
authored
Merge pull request #214 from hakonanes/189-remove-reciprocal-lattice-point
Remove deprecated ReciprocalLatticePoint class
2 parents 684828e + 9f7b660 commit ddb903d

10 files changed

+280
-830
lines changed

CHANGELOG.rst

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Removed
2828
-------
2929
- Removed support for Python 3.6 and Python 3.7, leaving 3.8 as the oldest supported
3030
version.
31+
- ``ReciprocalLatticePoint`` class; Use the ``ReciprocalLatticeVector`` class instead,
32+
which is an improved replacement.
3133

3234
Fixed
3335
-----

CONTRIBUTING.rst

+15-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ We have a `Code of Conduct
1212
<https://github.com/pyxem/diffsims/blob/master/.github/CODE_OF_CONDUCT.md>`_ that must
1313
be honoured by contributors.
1414

15+
1516
Start using diffsims
1617
====================
1718

@@ -42,6 +43,7 @@ install of diffsims!
4243
PS: If you choose to develop in Windows/Mac you may find the `Github Desktop
4344
<https://desktop.github.com>`_ useful.
4445

46+
4547
Questions?
4648
==========
4749

@@ -56,6 +58,7 @@ scary but it ensures that issues are identified and logged until dealt with. Thi
5658
also a good place to make a proposal for some new feature or tool that you want to work
5759
on.
5860

61+
5962
Good coding practice
6063
====================
6164

@@ -89,7 +92,6 @@ your newly added and modified files prior to each PR.
8992
If this doesn't work for you, you can also use the Pre-commit CI to reformat your code
9093
on github by commenting "pre-commit autofix" on your PR.
9194

92-
9395
Run and write tests
9496
-------------------
9597

@@ -128,7 +130,6 @@ Useful hints on testing:
128130
error-prone. See `pytest documentation for more details
129131
<https://doc.pytest.org/en/latest/how-to/parametrize.html>`_.
130132

131-
132133
Deprecations
133134
------------
134135
We attempt to adhere to semantic versioning as best we can. This means that as little,
@@ -138,16 +139,20 @@ so that users get a heads-up one (minor) release before something is removed or
138139
with a possible alternative to be used.
139140

140141

141-
A deprecation decorator should be placed right above the object signature to be deprecated.
142+
A deprecation decorator should be placed right above the object signature to be deprecated::
142143

143-
.. code-block:: python
144144
from diffsims.utils._deprecated import deprecated
145+
145146
@deprecated(since=0.8, removal=0.9, alternative="bar")
146-
def foo(self, n):
147-
return n + 1
148-
@property
149-
@deprecated(since=0.9, removal=0.10, alternative="another", is_function=True)
147+
def foo(self, n): ...
150148

149+
@property
150+
@deprecated(
151+
since="0.9",
152+
removal="0.10",
153+
alternative="another",
154+
alternative_is_function=True
155+
): ...
151156

152157
Build and write documentation
153158
-----------------------------
@@ -173,6 +178,7 @@ in the `reStructuredText (reST)
173178
plaintext markup language. They should be accessible in the browser by typing
174179
``file:///your-absolute/path/to/diffsims/doc/build/html/index.html`` in the address bar.
175180

181+
176182
Continuous integration (CI)
177183
===========================
178184

@@ -181,6 +187,7 @@ diffsims can be installed on Windows, macOS and Linux. After a successful instal
181187
the CI server runs the tests. After the tests return no errors, code coverage is
182188
reported to `Coveralls <https://coveralls.io/github/pyxem/diffsims?branch=master>`_.
183189

190+
184191
Learn more
185192
==========
186193

MANIFEST.in

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Info on valid syntax for controlling files in the distribution in this file:
2+
# * https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html
3+
# * https://setuptools.pypa.io/en/latest/userguide/datafiles.html
4+
15
include CHANGELOG.rst
26
include CONTRIBUTING.rst
37
include LICENSE
@@ -6,5 +10,6 @@ include README.rst
610
include readthedocs.yaml
711
include setup.cfg
812
include setup.py
13+
include diffsims/tests/**/*.npy
914

10-
recursive-include doc Makefile make.bat *.rst *.py *.png
15+
recursive-include doc Makefile make.bat *.rst *.py *.png

diffsims/crystallography/__init__.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
g, hkl) for a crystal structure.
2121
"""
2222

23-
from diffsims.crystallography.reciprocal_lattice_point import (
24-
ReciprocalLatticePoint,
23+
from diffsims.crystallography.get_hkl import (
2524
get_equivalent_hkl,
2625
get_highest_hkl,
2726
get_hkl,
@@ -32,6 +31,5 @@
3231
"get_equivalent_hkl",
3332
"get_highest_hkl",
3433
"get_hkl",
35-
"ReciprocalLatticePoint",
3634
"ReciprocalLatticeVector",
3735
]

diffsims/crystallography/get_hkl.py

+132
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2017-2023 The diffsims developers
3+
#
4+
# This file is part of diffsims.
5+
#
6+
# diffsims is free software: you can redistribute it and/or modify
7+
# it under the terms of the GNU General Public License as published by
8+
# the Free Software Foundation, either version 3 of the License, or
9+
# (at your option) any later version.
10+
#
11+
# diffsims is distributed in the hope that it will be useful,
12+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
# GNU General Public License for more details.
15+
#
16+
# You should have received a copy of the GNU General Public License
17+
# along with diffsims. If not, see <http://www.gnu.org/licenses/>.
18+
19+
from itertools import product
20+
21+
import numpy as np
22+
from orix.vector import Vector3d
23+
24+
from diffsims.utils._deprecated import deprecated
25+
26+
27+
@deprecated(
28+
since="0.6",
29+
alternative="diffsims.crystallography.ReciprocalLatticeVector.from_min_dspacing",
30+
removal="0.7",
31+
)
32+
def get_highest_hkl(lattice, min_dspacing=0.5):
33+
"""Return the highest Miller indices hkl of the plane with a direct
34+
space interplanar spacing (d-spacing) greater than but closest to
35+
*min_dspacing*.
36+
37+
Parameters
38+
----------
39+
lattice : diffpy.structure.Lattice
40+
Crystal lattice.
41+
min_dspacing : float, optional
42+
Smallest interplanar spacing to consider. Default is 0.5 Å.
43+
44+
Returns
45+
-------
46+
highest_hkl : np.ndarray
47+
Highest Miller indices.
48+
"""
49+
highest_hkl = np.ones(3, dtype=int)
50+
for i in range(3):
51+
hkl = np.zeros(3)
52+
d = min_dspacing + 1
53+
while d > min_dspacing:
54+
hkl[i] += 1
55+
d = 1 / lattice.rnorm(hkl)
56+
highest_hkl[i] = hkl[i]
57+
return highest_hkl
58+
59+
60+
@deprecated(
61+
since="0.6",
62+
alternative="diffsims.crystallography.ReciprocalLatticeVector.from_highest_hkl",
63+
removal="0.7",
64+
)
65+
def get_hkl(highest_hkl):
66+
"""Return a list of planes from a set of highest Miller indices.
67+
68+
Parameters
69+
----------
70+
highest_hkl : orix.vector.Vector3d, np.ndarray, list, or tuple of int
71+
Highest Miller indices to consider.
72+
73+
Returns
74+
-------
75+
hkl : np.ndarray
76+
An array of Miller indices.
77+
"""
78+
index_ranges = [np.arange(-i, i + 1) for i in highest_hkl]
79+
return np.asarray(list(product(*index_ranges)))
80+
81+
82+
@deprecated(
83+
since="0.6",
84+
alternative="diffsims.crystallography.ReciprocalLatticeVector.symmetrise",
85+
removal="0.7",
86+
)
87+
def get_equivalent_hkl(hkl, operations, unique=False, return_multiplicity=False):
88+
"""Return symmetrically equivalent Miller indices.
89+
90+
Parameters
91+
----------
92+
hkl : orix.vector.Vector3d, np.ndarray, list or tuple of int
93+
Miller indices.
94+
operations : orix.quaternion.symmetry.Symmetry
95+
Point group describing allowed symmetry operations.
96+
unique : bool, optional
97+
Whether to return only unique Miller indices. Default is False.
98+
return_multiplicity : bool, optional
99+
Whether to return the multiplicity of the input indices. Default
100+
is False.
101+
102+
Returns
103+
-------
104+
new_hkl : orix.vector.Vector3d
105+
The symmetrically equivalent Miller indices.
106+
multiplicity : np.ndarray
107+
Number of symmetrically equivalent indices. Only returned if
108+
`return_multiplicity` is True.
109+
"""
110+
new_hkl = operations.outer(Vector3d(hkl))
111+
new_hkl = new_hkl.flatten().reshape(*new_hkl.shape[::-1])
112+
113+
multiplicity = None
114+
if unique:
115+
n_families = new_hkl.shape[0]
116+
multiplicity = np.zeros(n_families, dtype=int)
117+
temp_hkl = new_hkl[0].unique().data
118+
multiplicity[0] = temp_hkl.shape[0]
119+
if n_families > 1:
120+
for i, hkl in enumerate(new_hkl[1:]):
121+
temp_hkl2 = hkl.unique()
122+
multiplicity[i + 1] = temp_hkl2.size
123+
temp_hkl = np.append(temp_hkl, temp_hkl2.data, axis=0)
124+
new_hkl = Vector3d(temp_hkl[: multiplicity.sum()])
125+
126+
# Remove 1-dimensions
127+
new_hkl = new_hkl.squeeze()
128+
129+
if unique and return_multiplicity:
130+
return new_hkl, multiplicity
131+
else:
132+
return new_hkl

0 commit comments

Comments
 (0)