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

Remove deprecation Bruker, EMD, Nexus #30

Merged
merged 8 commits into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ https://rosettasciio.readthedocs.io/en/latest/changes.html

.. towncrier release notes start


Initiation (2022-07-23)
=======================

Expand Down
6 changes: 3 additions & 3 deletions docs/supported_formats/bruker.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ currently supported by RosettaSciIO.
Extra loading arguments
+++++++++++++++++++++++

- ``select_type`` : one of (None, 'spectrum', 'image'). If specified, only the
corresponding type of data, either spectrum or image, is returned.
- ``select_type`` : one of (None, 'spectrum_image', 'image'). If specified, only
the corresponding type of data, either spectrum image or image, is returned.
By default (None), all data are loaded.
- ``index`` : one of (None, int, "all"). Allow to select the index of the dataset
in the ``.bcf`` file, which can contains several datasets. Default None value
Expand Down Expand Up @@ -55,7 +55,7 @@ Example of loading reduced (downsampled, and with energy range cropped)

.. code-block:: python

>>> hs.load("sample80kv.bcf", select_type='spectrum', downsample=2, cutoff_at_kV=10)
>>> hs.load("sample80kv.bcf", select_type='spectrum_image', downsample=2, cutoff_at_kV=10)
<EDSSEMSpectrum, title: EDX, dimensions: (50, 38|595)>

load the same file with limiting array size to SEM acceleration voltage:
Expand Down
6 changes: 3 additions & 3 deletions docs/supported_formats/emd.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ Extra loading arguments
See the ``chunks`` arguments of the ``hspy`` file format for more details.


For files containing several datasets, the `dataset_name` argument can be
For files containing several datasets, the `dataset_path` argument can be
used to select a specific one:

.. code-block:: python

>>> s = hs.load("adatafile.emd", dataset_name="/experimental/science_data_1/data")
>>> s = hs.load("adatafile.emd", dataset_path="/experimental/science_data_1/data")


Or several by using a list:

.. code-block:: python

>>> s = hs.load("adatafile.emd",
... dataset_name=[
... dataset_path=[
... "/experimental/science_data_1/data",
... "/experimental/science_data_2/data"])

Expand Down
10 changes: 0 additions & 10 deletions rsciio/bruker/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@
import dask.array as da
import numpy as np

from rsciio.exceptions import VisibleDeprecationWarning


_logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -1336,14 +1334,6 @@ def bcf_reader(

# objectified bcf file:
obj_bcf = BCF_reader(filename, instrument=instrument)
if select_type == "spectrum":
select_type = "spectrum_image"
msg = (
"The 'spectrum' option for the `select_type` parameter is "
"deprecated and will be removed in v2.0. Use 'spectrum_image' "
"instead."
)
warnings.warn(msg, VisibleDeprecationWarning)
if select_type == "image":
return bcf_images(obj_bcf)
elif select_type == "spectrum_image":
Expand Down
9 changes: 0 additions & 9 deletions rsciio/emd/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
from dateutil import tz

from rsciio.utils.tools import _UREG, DTBox
from rsciio.exceptions import VisibleDeprecationWarning
from rsciio.utils.elements import atomic_number2name
import rsciio.utils.fei_stream_readers as stream_readers
from rsciio._hierarchical import get_signal_chunks
Expand Down Expand Up @@ -1547,14 +1546,6 @@ def file_reader(filename, lazy=False, **kwds):
emd_reader.read_file(file)
elif is_EMD_NCEM(file):
_logger.debug("EMD file is a Berkeley variant.")
dataset_name = kwds.pop("dataset_name", None)
if dataset_name is not None:
msg = (
"Using 'dataset_name' is deprecated and will be removed "
"in HyperSpy 2.0, use 'dataset_path' instead."
)
warnings.warn(msg, VisibleDeprecationWarning)
dataset_path = f"{dataset_name}/data"
dataset_path = kwds.pop("dataset_path", None)
stack_group = kwds.pop("stack_group", None)
emd_reader = EMD_NCEM(**kwds)
Expand Down
23 changes: 0 additions & 23 deletions rsciio/nexus/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@
# along with RosettaSciIO. If not, see <https://www.gnu.org/licenses/#GPL>.
#
import logging
import warnings
import os

import dask.array as da
import h5py
import numpy as np
import pprint

from rsciio.exceptions import VisibleDeprecationWarning
from rsciio._hierarchical import get_signal_chunks
from rsciio.hspy.api import overwrite_dataset
from rsciio.utils.tools import DTBox
Expand Down Expand Up @@ -505,27 +503,6 @@ def file_reader(
fin = h5py.File(filename, "r")
signal_dict_list = []

if "dataset_keys" in kwds:
warnings.warn(
"The `dataset_keys` keyword is deprecated. " "Use `dataset_key` instead.",
VisibleDeprecationWarning,
)
dataset_key = kwds["dataset_keys"]

if "dataset_paths" in kwds:
warnings.warn(
"The `dataset_paths` keyword is deprecated. " "Use `dataset_path` instead.",
VisibleDeprecationWarning,
)
dataset_path = kwds["dataset_paths"]

if "metadata_keys" in kwds:
warnings.warn(
"The `metadata_keys` keyword is deprecated. " "Use `metadata_key` instead.",
VisibleDeprecationWarning,
)
metadata_key = kwds["metadata_keys"]

dataset_key = _check_search_keys(dataset_key)
dataset_path = _check_search_keys(dataset_path)
metadata_key = _check_search_keys(metadata_key)
Expand Down
4 changes: 0 additions & 4 deletions rsciio/tests/test_bruker.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
import numpy as np
import pytest

from rsciio.exceptions import VisibleDeprecationWarning

hs = pytest.importorskip("hyperspy.api", reason="hyperspy not installed")

from hyperspy.misc.test_utils import assert_deep_almost_equal
Expand Down Expand Up @@ -90,8 +88,6 @@ def test_hyperspy_wrap():
filename = os.path.join(my_path, "bruker_data", test_files[0])
print("testing bcf wrap to hyperspy signal...")

with pytest.warns(VisibleDeprecationWarning):
hype = hs.load(filename, select_type="spectrum")
hype = hs.load(filename, select_type="spectrum_image")
np.testing.assert_allclose(hype.axes_manager[0].scale, 1.66740910949362, atol=1e-12)
np.testing.assert_allclose(hype.axes_manager[1].scale, 1.66740910949362, atol=1e-12)
Expand Down
5 changes: 0 additions & 5 deletions rsciio/tests/test_emd.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,6 @@ def test_wrong_dataset_path(self):
dataset_path=[self.dataset_path_list[0], "a_wrong_name"],
)

def test_deprecated_dataset_name(self):
with pytest.warns(UserWarning):
dataset_name = os.path.dirname(self.dataset_path_list[0])
hs.load(self.hdf5_dataset_path, dataset_name=dataset_name)


def test_minimal_save():
signal = hs.signals.Signal1D([0, 1])
Expand Down
29 changes: 8 additions & 21 deletions rsciio/tests/test_nexus_hdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
import traits.api as t
import h5py

from hyperspy.exceptions import VisibleDeprecationWarning as HSVisibleDeprecationWarning
from hyperspy.exceptions import VisibleDeprecationWarning

from rsciio.exceptions import VisibleDeprecationWarning
from rsciio.nexus.api import (
_byte_to_string,
_fix_exclusion_keys,
Expand Down Expand Up @@ -134,18 +133,6 @@ def test_skip_load_array_metadata(self):
with pytest.raises(AttributeError):
s.original_metadata.entry1.instrument.stage1_x.value_set.value

def test_deprecated_metadata_keys(self):
with pytest.warns(VisibleDeprecationWarning):
_ = hs.load(self.file, metadata_keys="stage1_x")

def test_deprecated_dataset_keys(self):
with pytest.warns(VisibleDeprecationWarning):
_ = hs.load(self.file, dataset_keys="rocks")

def test_deprecated_dataset_paths(self):
with pytest.warns(VisibleDeprecationWarning):
_ = hs.load(self.file, dataset_paths="/entry1/testdata/nexustest/data")


class TestDLSNexusNoAxes:
def setup_method(self, method):
Expand Down Expand Up @@ -194,7 +181,7 @@ def test_save_hspy(self, tmp_path):

class TestSavedSignalLoad:
def setup_method(self, method):
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
self.s = hs.load(file1, nxdata_only=True)

def test_string(self):
Expand Down Expand Up @@ -225,7 +212,7 @@ def test_axes_names(self):

class TestSavedMultiSignalLoad:
def setup_method(self, method):
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
self.s = hs.load(
file2, nxdata_only=True, hardlinks_only=True, use_default=False
)
Expand Down Expand Up @@ -455,19 +442,19 @@ def test_saving_multi_signals(tmp_path):


def test_read_file2_dataset_key_test():
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
s = hs.load(file2, nxdata_only=True, dataset_key=["rocks"])
assert not isinstance(s, list)


def test_read_file2_signal1():
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
s = hs.load(file2, nxdata_only=True, dataset_key=["rocks"])
assert s.metadata.General.title == "rocks"


def test_read_file2_default():
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
s = hs.load(
file2,
use_default=False,
Expand All @@ -476,7 +463,7 @@ def test_read_file2_default():
dataset_key=["unnamed__1"],
)
assert s.metadata.General.title == "unnamed__1"
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
s = hs.load(
file2,
use_default=True,
Expand All @@ -488,7 +475,7 @@ def test_read_file2_default():


def test_read_file2_metadata_keys():
with pytest.warns(HSVisibleDeprecationWarning):
with pytest.warns(VisibleDeprecationWarning):
s = hs.load(
file2, nxdata_only=True, dataset_key=["rocks"], metadata_key=["energy"]
)
Expand Down
11 changes: 11 additions & 0 deletions upcoming_changes/30.maintenance.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Following the deprecation cycle announced in `HyperSpy
<https://hyperspy.org/hyperspy-doc/current/user_guide/changes.html>`_,
the following keywords and attributes have been removed:

- :ref:`Bruker composite file (BCF) <bcf-format>`: The 'spectrum' option for the
`select_type` parameter was removed. Use 'spectrum_image' instead.
- :ref:`Electron Microscopy Dataset (EMD) NCEM <emd_ncem-format>`: Using the
keyword 'dataset_name' was removed, use 'dataset_path' instead.
- :ref:`NeXus data format <nexus-format>`: The `dataset_keys`, `dataset_paths`
and `metadata_keys` keywords were removed. Use `dataset_key`, `dataset_path`
and `metadata_key` instead.