diff --git a/CHANGELOG.md b/CHANGELOG.md index 462d631..ae5240f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Version 0.5.1 +## Version 0.5.1 - 0.5.2 - Add wrapper methods to combine Summarized and RangedSummarized by rows or columns. - Implement getters and setters to access and modify an assay. diff --git a/src/summarizedexperiment/BaseSE.py b/src/summarizedexperiment/BaseSE.py index cd6f285..7558473 100644 --- a/src/summarizedexperiment/BaseSE.py +++ b/src/summarizedexperiment/BaseSE.py @@ -250,8 +250,8 @@ def __deepcopy__(self, memo=None, _nil=[]): _rows_copy = deepcopy(self._rows) _cols_copy = deepcopy(self._cols) _metadata_copy = deepcopy(self.metadata) - _row_names_copy = None if self._row_names is None else deepcopy(self._row_names) - _col_names_copy = None if self._column_names is None else deepcopy(self._column_names) + _row_names_copy = deepcopy(self._row_names) + _col_names_copy = deepcopy(self._column_names) current_class_const = type(self) return current_class_const( @@ -270,12 +270,12 @@ def __copy__(self): """ current_class_const = type(self) return current_class_const( - assays=self._assays.copy(), - row_data=self._rows.__copy__(), - column_data=self._cols.__copy__(), - row_names=None if self._row_names is None else self._row_names.copy(), - column_names=None if self._column_names is None else self._column_names.copy(), - metadata=self._metadata.copy(), + assays=self._assays, + row_data=self._rows, + column_data=self._cols, + row_names=self._row_names, + column_names=self._column_names, + metadata=self._metadata, ) def copy(self): @@ -961,7 +961,7 @@ def assay(self, assay: Union[int, str]) -> Any: return self.get_assay(assay) def set_assay(self, name: str, assay: Any, in_place: bool = False) -> "BaseSE": - """Add or Replace :py:attr:`~summarizedexperiment.BaseSE.BaseSE.assays`'s. + """Add or replace :py:attr:`~summarizedexperiment.BaseSE.BaseSE.assays`'s. Args: name: @@ -989,6 +989,8 @@ def set_assay(self, name: str, assay: Any, in_place: bool = False) -> "BaseSE": raise ValueError("Porvided assay does not match the dimensions of the experiment.") output = self._define_output(in_place) + if in_place is False: + output._assays = output._assays.copy() output._assays[name] = assay return output diff --git a/src/summarizedexperiment/RangedSummarizedExperiment.py b/src/summarizedexperiment/RangedSummarizedExperiment.py index 0588ec9..af1320a 100644 --- a/src/summarizedexperiment/RangedSummarizedExperiment.py +++ b/src/summarizedexperiment/RangedSummarizedExperiment.py @@ -184,8 +184,8 @@ def __deepcopy__(self, memo=None, _nil=[]): _rows_copy = deepcopy(self._rows) _rowranges_copy = deepcopy(self._row_ranges) _cols_copy = deepcopy(self._cols) - _row_names_copy = None if self._row_names is None else deepcopy(self._row_names) - _col_names_copy = None if self._column_names is None else deepcopy(self._column_names) + _row_names_copy = deepcopy(self._row_names) + _col_names_copy = deepcopy(self._column_names) _metadata_copy = deepcopy(self.metadata) current_class_const = type(self) @@ -206,13 +206,13 @@ def __copy__(self): """ current_class_const = type(self) return current_class_const( - assays=self._assays.copy(), - row_ranges=self._row_ranges.__copy__(), - row_data=self._rows.__copy__(), - column_data=self._cols.__copy__(), - row_names=None if self._row_names is None else self._row_names.copy(), - column_names=None if self._column_names is None else self._column_names.copy(), - metadata=self._metadata.copy(), + assays=self._assays, + row_ranges=self._row_ranges, + row_data=self._rows, + column_data=self._cols, + row_names=self._row_names, + column_names=self._column_names, + metadata=self._metadata, ) def copy(self): @@ -933,11 +933,11 @@ def relaxed_combine_columns(self, *other) -> "RangedSummarizedExperiment": return relaxed_combine_columns(self, *other) def combine_rows(self, *other) -> "RangedSummarizedExperiment": - """Wrapper around :py:func:`~biocutils.combine_rows`.""" + """Wrapper around :py:func:`~combine_rows`.""" return combine_rows(self, *other) def combine_columns(self, *other) -> "RangedSummarizedExperiment": - """Wrapper around :py:func:`~biocutils.combine_columns`.""" + """Wrapper around :py:func:`~combine_columns`.""" return combine_columns(self, *other) diff --git a/src/summarizedexperiment/SummarizedExperiment.py b/src/summarizedexperiment/SummarizedExperiment.py index 8147a44..e6bb13c 100644 --- a/src/summarizedexperiment/SummarizedExperiment.py +++ b/src/summarizedexperiment/SummarizedExperiment.py @@ -115,11 +115,11 @@ def relaxed_combine_columns(self, *other) -> "SummarizedExperiment": return relaxed_combine_columns(self, *other) def combine_rows(self, *other) -> "SummarizedExperiment": - """Wrapper around :py:func:`~biocutils.combine_rows`.""" + """Wrapper around :py:func:`~combine_rows`.""" return combine_rows(self, *other) def combine_columns(self, *other) -> "SummarizedExperiment": - """Wrapper around :py:func:`~biocutils.combine_columns`.""" + """Wrapper around :py:func:`~combine_columns`.""" return combine_columns(self, *other)