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

Simplify Named RAI name conversion #323

Merged
merged 2 commits into from
Apr 7, 2025
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/imagej/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@ def java_to_xarray(ij: "jc.ImageJ", jobj) -> xr.DataArray:
xr_dims.reverse()
xr_dims = dims._convert_dims(xr_dims, direction="python")
xr_coords = dims._get_axes_coords(xr_axes, xr_dims, narr.shape)
name = jobj.getName() if isinstance(jobj, jc.Named) else None
name = ij.py.from_java(name)
name = str(jobj.getName()) if isinstance(jobj, jc.Named) else None
return xr.DataArray(narr, dims=xr_dims, coords=xr_coords, attrs=xr_attrs, name=name)


Expand Down
2 changes: 2 additions & 0 deletions tests/test_image_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,8 @@ def test_direct_to_xarray_conversion(
im_data = im_req()
# convert the image data to xarray
xarr_out = ij.py.to_xarray(im_data, dim_order=new_dims)
name = xarr_out.name
assert name is None or isinstance(name, str)
assert xarr_out.dims == exp_dims
assert xarr_out.shape == exp_shape
if hasattr(im_data, "dim_axes") and obj_type == "java":
Expand Down
Loading