Repository: hyperspy/rosettasciio (language: python)

Issue:
Latest `python-box` release breaks rosettasciio
With `python-box` 7.0, we have the following error:

From https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806
```python
___________________________ test_read_EELS_metadata ____________________________
[gw0] linux -- Python 3.9.16 /opt/hostedtoolcache/Python/3.9.16/x64/bin/python

    def test_read_EELS_metadata():
        fname = os.path.join(MY_PATH, "dm3_1D_data", "test-EELS_spectrum.dm3")
>       s = hs.load(fname)

rsciio/tests/test_digitalmicrograph.py:1[43](https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806#step:10:44): 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/hyperspy/io.py:517: in load
    objects = [load_single_file(filename, lazy=lazy, **kwds)
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/hyperspy/io.py:517: in <listcomp>
    objects = [load_single_file(filename, lazy=lazy, **kwds)
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/hyperspy/io.py:576: in load_single_file
    return load_with_reader(filename=filename, reader=reader, **kwds)
/opt/hostedtoolcache/Python/3.9.16/x64/lib/python3.9/site-packages/hyperspy/io.py:597: in load_with_reader
    file_data_list = importlib.import_module(reader["api"]).file_reader(filename,
rsciio/digitalmicrograph/_api.py:1267: in file_reader
    images = [
rsciio/digitalmicrograph/_api.py:1268: in <listcomp>
    ImageObject(imdict, f, order=order)
rsciio/digitalmicrograph/_api.py:[44](https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806#step:10:45)5: in __init__
    self.imdict = Box(imdict, box_dots=True)
box/box.py:286: in box.box.Box.__init__
    ???
box/box.py:660: in box.box.Box.__setitem__
    ???
box/box.py:569: in box.box.Box.__convert_and_store
    ???
box/box.py:286: in box.box.Box.__init__
    ???
box/box.py:660: in box.box.Box.__setitem__
    ???
box/box.py:569: in box.box.Box.__convert_and_store
    ???
box/box.py:286: in box.box.Box.__init__
    ???
box/box.py:660: in box.box.Box.__setitem__
    ???
box/box.py:569: in box.box.Box.__convert_and_store
    ???
box/box.py:286: in box.box.Box.__init__
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   box.exceptions.BoxKeyError: "'<class 'box.box.Box'>' object has no attribute Align min"

box/box.py:6[53](https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806#step:10:54): BoxKeyError
------------------------------ Captured log call -------------------------------
ERROR    hyperspy.io:io.py:[57](https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806#step:10:58)9 If this file format is supported, please report this error to the HyperSpy developers.
------------------------------ Captured log call -------------------------------
ERROR    hyperspy.io:io.py:5[79](https://github.com/hyperspy/rosettasciio/actions/runs/4091545239/jobs/7055708806#step:10:80) If this file format is supported, please report this error to the HyperSpy developers.
------------------------------ Captured log call -------------------------------
ERROR    hyperspy.io:io.py:579 If this file format is supported, please report this error to the HyperSpy developers.
------------------------------ Captured log call -------------------------------
ERROR    hyperspy.io:io.py:579 If this file format is supported, please report this error to the HyperSpy developers.

```


Discussion / hints:

Fix patch:
diff --git a/rsciio/digitalmicrograph/_api.py b/rsciio/digitalmicrograph/_api.py
index 68b2556c0..922cd7a1c 100644
--- a/rsciio/digitalmicrograph/_api.py
+++ b/rsciio/digitalmicrograph/_api.py
@@ -101,6 +101,10 @@ def parse_tags(self, ntags, group_name="root", group_dict=None):
             _logger.debug("Reading tag name at address: %s", self.f.tell())
             tag_header = self.parse_tag_header()
             tag_name = tag_header["tag_name"]
+            if "." in tag_name:
+                # remove '.' from tag_name to avoid conflict with flattened
+                # syntax of box.Box
+                tag_name = tag_name.replace(".", "")
 
             skip = True if (group_name == "ImageData" and tag_name == "Data") else False
             _logger.debug("Tag name: %s", tag_name[:20])
diff --git a/setup.py b/setup.py
index dd3e2de7f..22cdec569 100644
--- a/setup.py
+++ b/setup.py
@@ -159,7 +159,7 @@ def run(self):
     "numba>=0.52",
     "numpy>=1.17.1",
     "pint>=0.8",
-    "python-box>=6.0,<7.0",
+    "python-box>=6.0",
     "pyyaml",
     "scipy>=1.1",
     "sparse",
diff --git a/upcoming_changes/100.maintenance.rst b/upcoming_changes/100.maintenance.rst
new file mode 100644
index 000000000..6c629e2bd
--- /dev/null
+++ b/upcoming_changes/100.maintenance.rst
@@ -0,0 +1,1 @@
+Add support for python-box 7
\ No newline at end of file


Test patch:
diff --git a/rsciio/tests/test_digitalmicrograph.py b/rsciio/tests/test_digitalmicrograph.py
index ee030a60c..7f03f6782 100644
--- a/rsciio/tests/test_digitalmicrograph.py
+++ b/rsciio/tests/test_digitalmicrograph.py
@@ -183,6 +183,11 @@ def test_read_EELS_metadata():
     np.testing.assert_allclose(
         md.Signal.Noise_properties.Variance_linear_model.gain_offset, 0.0
     )
+    # tag name is "align min. correlation coefficient"
+    assert (
+        s.original_metadata.ImageList.TagGroup0.ImageTags.EELS.Acquisition.Align_min_correlation_coefficient
+        == 0.5
+    )
 
 
 def test_read_SI_metadata():