@@ -124,7 +124,7 @@ def __init__( # noqa: PLR0913
124124 segmentation_file_regex : Optional [Dict [str , str ]] = None ,
125125 image_adjustment : Optional [Callable ] = None ,
126126 display_options : Optional [Dict [str , Any ]] = None ,
127- * args : Tuple [ Any , ...] ,
127+ * args : Any ,
128128 ** kwargs : Dict [str , Any ],
129129 ) -> None :
130130 """
@@ -385,15 +385,16 @@ def _constructor(self: CytoDataFrame_type) -> Callable[..., CytoDataFrame_type]:
385385 def _build_result_cdf (
386386 self : CytoDataFrame_type ,
387387 data : Union ["CytoDataFrame" , pd .DataFrame , pd .Series , Any ],
388- * args : Tuple [ Any , ...] ,
388+ * args : Any ,
389389 ** kwargs : Dict [str , Any ],
390390 ) -> CytoDataFrame_type :
391391 """Construct a result frame while preserving CytoDataFrame metadata."""
392392 if data is None and "data" in kwargs :
393393 data = kwargs .pop ("data" )
394394
395395 cdf = CytoDataFrame (
396- data = data ,
396+ data ,
397+ * args ,
397398 data_context_dir = self ._custom_attrs ["data_context_dir" ],
398399 data_image_paths = self ._custom_attrs ["data_image_paths" ],
399400 data_bounding_box = self ._custom_attrs ["data_bounding_box" ],
@@ -403,7 +404,6 @@ def _build_result_cdf(
403404 segmentation_file_regex = self ._custom_attrs ["segmentation_file_regex" ],
404405 image_adjustment = self ._custom_attrs ["image_adjustment" ],
405406 display_options = self ._custom_attrs ["display_options" ],
406- * args ,
407407 ** kwargs ,
408408 )
409409
@@ -422,7 +422,7 @@ def _return_cytodataframe(
422422 self : CytoDataFrame_type ,
423423 method : Callable ,
424424 method_name : str ,
425- * args : Tuple [ Any , ...] ,
425+ * args : Any ,
426426 ** kwargs : Dict [str , Any ],
427427 ) -> Any :
428428 """
@@ -434,7 +434,7 @@ def _return_cytodataframe(
434434 The method to be called and wrapped.
435435 method_name (str):
436436 The name of the method to be wrapped.
437- *args (Tuple[ Any, ...] ):
437+ *args (Any):
438438 Positional arguments to be passed to the method.
439439 **kwargs (Dict[str, Any]):
440440 Keyword arguments to be passed to the method.
@@ -453,12 +453,14 @@ def _return_cytodataframe(
453453 else method (* args , ** kwargs )
454454 )
455455
456- if isinstance (result , pd .DataFrame ):
457- cdf = self ._build_result_cdf (result )
458- # If the method name is transpose we know that
459- # the dataframe has been transposed.
460- if method_name == "transpose" and not self ._custom_attrs ["is_transposed" ]:
461- cdf ._custom_attrs ["is_transposed" ] = True
456+ if not isinstance (result , pd .DataFrame ):
457+ return result
458+
459+ cdf = self ._build_result_cdf (result )
460+ # If the method name is transpose we know that
461+ # the dataframe has been transposed.
462+ if method_name == "transpose" and not self ._custom_attrs ["is_transposed" ]:
463+ cdf ._custom_attrs ["is_transposed" ] = True
462464
463465 return cdf
464466
@@ -482,7 +484,7 @@ def _wrap_method(self: CytoDataFrame_type, method_name: str) -> Callable:
482484 the result is a CytoDataFrame.
483485 """
484486
485- def wrapper (* args : Tuple [ Any , ...] , ** kwargs : Dict [str , Any ]) -> Any :
487+ def wrapper (* args : Any , ** kwargs : Dict [str , Any ]) -> Any :
486488 """
487489 Wraps the specified method to ensure
488490 it returns a CytoDataFrame.
@@ -494,7 +496,7 @@ def wrapper(*args: Tuple[Any, ...], **kwargs: Dict[str, Any]) -> Any:
494496 custom attributes.
495497
496498 Args:
497- *args (Tuple[ Any, ...] ):
499+ *args (Any):
498500 Positional arguments to be passed to the method.
499501 **kwargs (Dict[str, Any]):
500502 Keyword arguments to be passed to the method.
0 commit comments