Skip to content

Commit d349777

Browse files
committed
fix column setter, add row get/set
1 parent 54a89ad commit d349777

File tree

2 files changed

+38
-5
lines changed

2 files changed

+38
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Changelog
22

3-
## Version 0.6.0 - 0.6.4
3+
## Version 0.6.0 - 0.6.5
44

55
- Classes now extend `BiocObject` from biocutils, which provides a metadata field.
66
- `valdiate` is renamed to `_validate` for consistency with other classes and packages.

src/summarizedexperiment/base.py

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,9 +1198,9 @@ def to_anndata(self):
11981198

11991199
return obj
12001200

1201-
######################################
1202-
######>> col_data accessors <<########
1203-
######################################
1201+
##########################################
1202+
######>> col/row data accessors <<########
1203+
##########################################
12041204

12051205
def get_column_data_column(self, column: str) -> Any:
12061206
"""Access a column from the ``column_data``.
@@ -1232,5 +1232,38 @@ def set_column_data_column(self, column: str, value: Any, in_place: bool = False
12321232
or as a reference to the (in-place-modified) original.
12331233
"""
12341234
output = self._define_output(in_place)
1235-
output._cols = output._cols.set_column(column, value, in_place=False)
1235+
output._cols.set_column(column, value, in_place=True)
1236+
return output
1237+
1238+
def get_row_data_column(self, column: str) -> Any:
1239+
"""Access a column from the ``row_data``.
1240+
1241+
Args:
1242+
column:
1243+
Name of the column to retrieve.
1244+
1245+
Returns:
1246+
The content of the column.
1247+
"""
1248+
return self._cols.get_column(column)
1249+
1250+
def set_row_data_column(self, column: str, value: Any, in_place: bool = False) -> BaseSE:
1251+
"""Set or replace a column in ``row_data``.
1252+
1253+
Args:
1254+
column:
1255+
Name of the column to set.
1256+
1257+
value:
1258+
Values for the column. Must match the number of features (rows).
1259+
1260+
in_place:
1261+
Whether to modify the ``BaseSE`` in place.
1262+
1263+
Returns:
1264+
A modified ``BaseSE`` object, either as a copy of the original
1265+
or as a reference to the (in-place-modified) original.
1266+
"""
1267+
output = self._define_output(in_place)
1268+
output._rows.set_column(column, value, in_place=True)
12361269
return output

0 commit comments

Comments
 (0)