Skip to content

Commit d066ae7

Browse files
authored
Merge pull request #323 from imagej/rai-name
Simplify Named RAI name conversion
2 parents 9099654 + 778d253 commit d066ae7

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/imagej/convert.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ def java_to_xarray(ij: "jc.ImageJ", jobj) -> xr.DataArray:
239239
xr_dims.reverse()
240240
xr_dims = dims._convert_dims(xr_dims, direction="python")
241241
xr_coords = dims._get_axes_coords(xr_axes, xr_dims, narr.shape)
242-
name = jobj.getName() if isinstance(jobj, jc.Named) else None
243-
name = ij.py.from_java(name)
242+
name = str(jobj.getName()) if isinstance(jobj, jc.Named) else None
244243
return xr.DataArray(narr, dims=xr_dims, coords=xr_coords, attrs=xr_attrs, name=name)
245244

246245

tests/test_image_conversion.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,8 @@ def test_direct_to_xarray_conversion(
650650
im_data = im_req()
651651
# convert the image data to xarray
652652
xarr_out = ij.py.to_xarray(im_data, dim_order=new_dims)
653+
name = xarr_out.name
654+
assert name is None or isinstance(name, str)
653655
assert xarr_out.dims == exp_dims
654656
assert xarr_out.shape == exp_shape
655657
if hasattr(im_data, "dim_axes") and obj_type == "java":

0 commit comments

Comments
 (0)