Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update develop after 0.13.2 #529

Merged
merged 9 commits into from
Oct 5, 2024
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -48,7 +48,8 @@ jobs:
include:
- os: ubuntu-latest
python-version: '3.10'
DEPENDENCIES: diffpy.structure==3.0.2 matplotlib==3.6.1
# Matplotlib 3.6.1 is not compatible with NumPy v2
DEPENDENCIES: diffpy.structure==3.0.2 matplotlib==3.6.1 "numpy<2"
LABEL: -oldest
- os: ubuntu-latest
python-version: '3.12'
7 changes: 7 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -24,6 +24,13 @@ Deprecated
Fixed
-----

2024-09-25 - version 0.13.2
===========================

Added
-----
- Compatibility with NumPy v2.0.

2024-09-20 - version 0.13.1
===========================

2 changes: 1 addition & 1 deletion orix/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.14.dev1"
__version__ = "0.14.dev2"
# Sorted by line contributions (ideally excluding lines in notebook files)
__credits__ = [
"Håkon Wiik Ånes",
10 changes: 5 additions & 5 deletions orix/_util.py
Original file line number Diff line number Diff line change
@@ -22,7 +22,7 @@
import inspect
import warnings

import numpy as np
from orix.constants import VisibleDeprecationWarning


class deprecated:
@@ -88,12 +88,12 @@ def __call__(self, func):
@functools.wraps(func)
def wrapped(*args, **kwargs):
warnings.simplefilter(
action="always", category=np.VisibleDeprecationWarning, append=True
action="always", category=VisibleDeprecationWarning, append=True
)
func_code = func.__code__
warnings.warn_explicit(
message=msg,
category=np.VisibleDeprecationWarning,
category=VisibleDeprecationWarning,
filename=func_code.co_filename,
lineno=func_code.co_firstlineno + 1,
)
@@ -141,12 +141,12 @@ def wrapped(*args, **kwargs):
msg += f"Use `{self.alternative}` instead. "
msg += f"See the documentation of `{func.__name__}()` for more details."
warnings.simplefilter(
action="always", category=np.VisibleDeprecationWarning, append=True
action="always", category=VisibleDeprecationWarning, append=True
)
func_code = func.__code__
warnings.warn_explicit(
message=msg,
category=np.VisibleDeprecationWarning,
category=VisibleDeprecationWarning,
filename=func_code.co_filename,
lineno=func_code.co_firstlineno + 1,
)
10 changes: 10 additions & 0 deletions orix/constants.py
Original file line number Diff line number Diff line change
@@ -35,4 +35,14 @@
eps9 = 1e-9
eps12 = 1e-12

# TODO: Remove and use numpy.exceptions.VisibleDeprecationWarning once
# NumPy 1.25 is minimal supported version
try:
# Added in NumPy 1.25.0
from numpy.exceptions import VisibleDeprecationWarning
except ImportError: # pragma: no cover
# Removed in NumPy 2.0.0
from numpy import VisibleDeprecationWarning


del optional_deps
3 changes: 2 additions & 1 deletion orix/tests/io/test_ang.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
import numpy as np
import pytest

from orix.constants import VisibleDeprecationWarning
from orix.crystal_map import CrystalMap, Phase
from orix.io import load, loadang, save
from orix.io.plugins.ang import (
@@ -76,7 +77,7 @@
indirect=["angfile_astar"],
)
def test_loadang(angfile_astar, expected_data):
with pytest.warns(np.VisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
loaded_data = loadang(angfile_astar)
assert np.allclose(loaded_data.data, expected_data)

3 changes: 2 additions & 1 deletion orix/tests/io/test_io.py
Original file line number Diff line number Diff line change
@@ -27,6 +27,7 @@
import numpy as np
import pytest

from orix.constants import VisibleDeprecationWarning
from orix.crystal_map import Phase, PhaseList
from orix.io import _overwrite_or_not, _plugin_from_manufacturer, load, loadctf, save
from orix.io.plugins import bruker_h5ebsd, emsoft_h5ebsd, orix_hdf5
@@ -151,6 +152,6 @@ def test_loadctf():
fname = "temp.ctf"
np.savetxt(fname, z)

with pytest.warns(np.VisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
_ = loadctf(fname)
os.remove(fname)
12 changes: 6 additions & 6 deletions orix/tests/test_util.py
Original file line number Diff line number Diff line change
@@ -17,10 +17,10 @@

import warnings

import numpy as np
import pytest

from orix._util import deprecated, deprecated_argument
from orix.constants import VisibleDeprecationWarning


class TestDeprecateFunctionOrProperty:
@@ -58,7 +58,7 @@ def bar_func2(self, n):

my_foo = Foo()

with pytest.warns(np.VisibleDeprecationWarning) as record:
with pytest.warns(VisibleDeprecationWarning) as record:
assert my_foo.bar_func1(4) == 5
desired_msg = (
"Function `bar_func1()` is deprecated and will be removed in version 0.8. "
@@ -72,7 +72,7 @@ def bar_func2(self, n):
f" {desired_msg}"
)

with pytest.warns(np.VisibleDeprecationWarning) as record2:
with pytest.warns(VisibleDeprecationWarning) as record2:
assert my_foo.bar_func2(4) == 6
desired_msg2 = "Function `bar_func2()` is deprecated."
assert str(record2[0].message) == desired_msg2
@@ -84,7 +84,7 @@ def bar_func2(self, n):
f" {desired_msg2}"
)

with pytest.warns(np.VisibleDeprecationWarning) as record3:
with pytest.warns(VisibleDeprecationWarning) as record3:
assert my_foo.bar_prop == 1
desired_msg3 = (
"Property `bar_prop` is deprecated and will be removed in version 1.4. "
@@ -123,7 +123,7 @@ def bar_arg_alt(self, **kwargs):
assert my_foo.bar_arg(b=1) == {"b": 1}

# Warns
with pytest.warns(np.VisibleDeprecationWarning) as record2:
with pytest.warns(VisibleDeprecationWarning) as record2:
assert my_foo.bar_arg(a=2) == {"a": 2}
assert str(record2[0].message) == (
r"Argument `a` is deprecated and will be removed in version 1.4. "
@@ -132,7 +132,7 @@ def bar_arg_alt(self, **kwargs):
)

# Warns with alternative
with pytest.warns(np.VisibleDeprecationWarning) as record3:
with pytest.warns(VisibleDeprecationWarning) as record3:
assert my_foo.bar_arg_alt(a=3) == {"a": 3}
assert str(record3[0].message) == (
r"Argument `a` is deprecated and will be removed in version 1.4. "