Skip to content

Commit 73f4c35

Browse files
committed
Add missing param docstrings and return type hint
to_xarray() and to_dataset() are both missing the docstring for the dim_order parameter. Additionally this commit adds the appropriate return type hint for each method respectively.
1 parent 4b1d354 commit 73f4c35

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

src/imagej/__init__.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,19 @@ def sync_image(self, imp: "jc.ImagePlus" = None):
421421
pixels = imp.getProcessor().getPixels()
422422
stack.setPixels(pixels, imp.getCurrentSlice())
423423

424-
def to_dataset(self, data, dim_order=None):
424+
def to_dataset(self, data, dim_order=None) -> "jc.Dataset":
425425
"""Convert the data into an ImageJ2 Dataset.
426426
427427
Converts a Python image (e.g. xarray or numpy array) or Java image (e.g.
428428
RandomAccessibleInterval or Img) into a net.imagej.Dataset Java object.
429429
430430
:param data: Image object to be converted to Dataset.
431+
:param dim_order: A sequence of strings (i.e. a list or tuple) specifying the
432+
new dimension names. The length of dim_order must be less than or equal to
433+
the number of dimensions in the input data. dim_order sequences lengths
434+
that are smaller than the dimension shape length are populated with "dim_n"
435+
where "n" is an incrementing counter. Specifying a new dimension order does
436+
not changes its shape or coordinates, but only renames the dimensions.
431437
:return: A net.imagej.Dataset.
432438
"""
433439
if sj.isjava(data):
@@ -500,13 +506,19 @@ def to_java(self, data, **hints):
500506

501507
return sj.to_java(data, **hints)
502508

503-
def to_xarray(self, data, dim_order=None):
509+
def to_xarray(self, data, dim_order=None) -> xr.DataArray:
504510
"""Convert the data into an xarray DataArray.
505511
506512
Converts a Python image (e.g. xarray or numpy array) or Java image (e.g.
507513
RandomAccessibleInterval) into an xarray.DataArray Python object.
508514
509515
:param data: Image object to be converted to xarray.DataArray.
516+
:param dim_order: A sequence of strings (i.e. a list or tuple) specifying the
517+
new dimension names. The length of dim_order must be less than or equal to
518+
the number of dimensions in the input data. dim_order sequences lengths
519+
that are smaller than the dimension shape length are populated with "dim_n"
520+
where "n" is an incrementing counter. Specifying a new dimension order does
521+
not changes its shape or coordinates, but only renames the dimensions.
510522
:return: An xarray.DataArray.
511523
"""
512524
if sj.isjava(data):

0 commit comments

Comments
 (0)