@@ -83,21 +83,10 @@ def test_file_context_manager(tmpdir, field1, field2):
8383 assert "axes" in w2 ["entry/data" ].attrs
8484
8585
86- def test_read_lazy_field_after_same_path_rewrap (tmpdir ):
87- """A file-backed NXfield that has been deep-copied into a new
88- in-memory container at the same on-disk path used to raise
89- ``RuntimeError: destination object already exists`` when read,
90- because ``_get_uncopied_data`` asked HDF5 to copy the field onto
91- itself. This is the scenario hit by the nexpy PlotDialog when a
92- field inside an NXdata is selected as the signal: the dialog
93- wraps it in a fresh NXdata with the same name and reparents to
94- the original grandparent, so the wrapped field's nxpath collides
95- with the source. The field must be large enough to stay
96- lazy-loaded (``_value is None``) so the deepcopy preserves the
97- ``_uncopied_data`` reference.
98- """
86+ def test_read_lazy_field_on_copy (tmpdir ):
87+
9988 filename = os .path .join (tmpdir , "file.nxs" )
100- shape = (2000 , 2000 ) # big enough to stay lazy-loaded
89+ shape = (2000 , 2000 )
10190 root = NXroot (NXentry (NXdata (
10291 NXfield (np .zeros (shape , dtype = np .int64 ), name = "signal" ),
10392 name = "data" )))
@@ -108,10 +97,6 @@ def test_read_lazy_field_after_same_path_rewrap(tmpdir):
10897
10998 root = nxload (filename , "rw" )
11099 src = root ["entry/data" ]
111- # Mimic PlotDialog: wrap the mask in a new NXdata named after the
112- # original group, reparented to the entry. The wrapped field
113- # ends up at /entry/data/signal_mask -- the same path as the
114- # source.
115100 wrapper = NXdata (src ["signal_mask" ], name = src .nxname )
116101 wrapper .nxgroup = src .nxgroup
117102 field = wrapper .nxsignal
0 commit comments