From 6aea4e3afa6e9b4940a3227b1273512ab27c7416 Mon Sep 17 00:00:00 2001 From: Yiming Yang Date: Fri, 19 Jan 2024 18:34:29 -0800 Subject: [PATCH] UnimodalDataView.copy() returns MultimodalData by default --- pegasusio/views.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pegasusio/views.py b/pegasusio/views.py index 20fb314..74e81b0 100644 --- a/pegasusio/views.py +++ b/pegasusio/views.py @@ -394,9 +394,15 @@ def _copy_matrices(self) -> Dict[str, csr_matrix]: self.matrices[key] = X[self.barcode_index][:,self.feature_index] # X[self.barcode_index.reshape(-1, 1), self.feature_index] if self._all_arrays else X[self.barcode_index, self.feature_index] return self.matrices - def copy(self) -> "UnimodalData": + def copy( + self, + to_unidata: bool = False, + ) -> Union["MultimodalData", "UnimodalData"]: """ After copy, this View object becomes invalid """ data = self.parent._copy_view(self) + if not to_unidata: + from pegasusio import MultimodalData + data = MultimodalData(data) self.parent = None self.barcode_index = self.feature_index = None