Skip to content

Commit

Permalink
Merge pull request #577 from hakonanes/remove-deprecated-after-0.7.0
Browse files Browse the repository at this point in the history
Remove old and add new deprecations
  • Loading branch information
hakonanes committed Nov 2, 2022
2 parents 17a9942 + 33566c9 commit a2754c0
Show file tree
Hide file tree
Showing 23 changed files with 190 additions and 513 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -24,9 +24,16 @@ Changed

Deprecated
----------
- ``projections`` module with classes ``GnomonicProjection``, ``HesseNormalForm``,
``LambertProjection`` and ``SphericalProjection``. These will be removed in version
0.9.0, as they are unused internally. If you depend on this module, please open an
issue at https://github.com/pyxem/kikuchipy/issues.

Removed
-------
- ``mask`` parameter in EBSD refinement methods; use ``signal_mask`` instead.
(`#577 <https://github.com/pyxem/kikuchipy/pull/577>`_)
- ``ebsd_projections`` module. (`#577 <https://github.com/pyxem/kikuchipy/pull/577>`_)

Fixed
-----
Expand Down
1 change: 0 additions & 1 deletion kikuchipy/__init__.py
Expand Up @@ -58,7 +58,6 @@ def set_log_level(level: str): # pragma: no cover
__all__ = [
"__version__",
"_pyvista_installed",
"crystallography",
"data",
"detectors",
"draw",
Expand Down
5 changes: 4 additions & 1 deletion kikuchipy/_util/_deprecated.py
Expand Up @@ -85,7 +85,10 @@ def __call__(self, func: Callable):
rm_msg = f" and will be removed in version {self.removal}"
else:
rm_msg = ""
msg = f"Function `{func.__name__}()` is deprecated{rm_msg}.{alt_msg}"
if self.alternative_is_function:
msg = f"Function `{func.__name__}()` is deprecated{rm_msg}.{alt_msg}"
else:
msg = f"Attribute `{func.__name__}` is deprecated{rm_msg}.{alt_msg}"

@functools.wraps(func)
def wrapped(*args, **kwargs):
Expand Down
22 changes: 22 additions & 0 deletions kikuchipy/_util/tests/test_deprecated.py
Expand Up @@ -90,6 +90,28 @@ def foo(n):
f" {desired_msg}"
)

def test_deprecate_class_attribute(self):
class Foo:
def __init__(self, a):
self.a = a

@property
@deprecated(since=0.7, alternative_is_function=False, alternative="c")
def b(self):
return 1

foo1 = Foo(1)
with pytest.warns(np.VisibleDeprecationWarning) as record:
assert foo1.b == 1
desired_msg = "Attribute `b` is deprecated. Use `c` instead."
assert str(record[0].message) == desired_msg
assert Foo.b.__doc__ == (
"[*Deprecated*] \n"
"\nNotes\n-----\n"
".. deprecated:: 0.7\n"
f" {desired_msg}"
)


class TestDeprecateArgument:
def test_deprecate_argument(self):
Expand Down
19 changes: 0 additions & 19 deletions kikuchipy/_util/tests/test_import.py
Expand Up @@ -39,17 +39,6 @@ def test_import_pyvista_installed(self):

assert isinstance(_pyvista_installed, bool)

def test_import_crystallography(self):
import kikuchipy.crystallography

for obj_name in kikuchipy.crystallography.__all__:
getattr(kikuchipy.crystallography, obj_name)
with pytest.raises(
AttributeError,
match="module 'kikuchipy.crystallography' has no attribute 'foo'",
):
_ = kikuchipy.crystallography.foo

def test_import_data(self):
import kikuchipy.data

Expand Down Expand Up @@ -194,7 +183,6 @@ def test_dir(self):
assert dir(kikuchipy) == [
"__version__",
"_pyvista_installed",
"crystallography",
"data",
"detectors",
"draw",
Expand All @@ -211,13 +199,6 @@ def test_dir(self):
"simulations",
]

def test_dir_crystallography(self):
import kikuchipy.crystallography

assert dir(kikuchipy.crystallography) == [
"get_direct_structure_matrix",
]

def test_dir_data(self):
import kikuchipy.data

Expand Down
7 changes: 0 additions & 7 deletions kikuchipy/conftest.py
Expand Up @@ -30,7 +30,6 @@
import numpy as np
from orix.crystal_map import CrystalMap, create_coordinate_arrays, Phase, PhaseList
from orix.quaternion import Rotation
from orix.vector import Vector3d
import pytest

import kikuchipy as kp
Expand Down Expand Up @@ -205,12 +204,6 @@ def detector(request, pc1):
)


@pytest.fixture
def r_tsl2bruker():
"""A rotation from the TSL to Bruker crystal reference frame."""
yield Rotation.from_axes_angles(Vector3d.zvector(), np.pi / 2)


@pytest.fixture
def rotations():
return Rotation([(2, 4, 6, 8), (-1, -3, -5, -7)])
Expand Down
39 changes: 0 additions & 39 deletions kikuchipy/crystallography/__init__.py

This file was deleted.

52 changes: 0 additions & 52 deletions kikuchipy/crystallography/matrices.py

This file was deleted.

16 changes: 0 additions & 16 deletions kikuchipy/crystallography/tests/__init__.py

This file was deleted.

40 changes: 0 additions & 40 deletions kikuchipy/crystallography/tests/test_crystallographic_matrices.py

This file was deleted.

9 changes: 8 additions & 1 deletion kikuchipy/projections/__init__.py
Expand Up @@ -15,7 +15,14 @@
# You should have received a copy of the GNU General Public License
# along with kikuchipy. If not, see <http://www.gnu.org/licenses/>.

"""Various projections and transformations relevant to EBSD."""
"""[*Deprecated*] Various projections and transformations relevant to
EBSD.
.. deprecated:: 0.8.0
This module is deprecated and will be removed in 0.9.0, since it
is not used internally. If you depend on it, please open an issue at
https://github.com/pyxem/kikuchipy/issues.
"""

__all__ = [
"GnomonicProjection",
Expand Down

0 comments on commit a2754c0

Please sign in to comment.