Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/add-mcols' into add-mcols
Browse files Browse the repository at this point in the history
  • Loading branch information
LTLA committed Oct 24, 2023
2 parents 83bc33e + f5ccb32 commit 1519a1c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/biocframe/BiocFrame.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ def _validate(self):
self._number_of_rows = validate_rows(
self._data, self._number_of_rows, self._row_names
)
self._column_names, self._data, self._mcols = validate_cols(self._column_names, self._data)
self._column_names, self._data, self._mcols = validate_cols(
self._column_names, self._data
)

if self._number_of_rows is None:
self._number_of_rows = 0
Expand Down Expand Up @@ -371,10 +373,14 @@ def mcols(self) -> Union[None, "BiocFrame"]:
def mcols(self, mcols: Union[None, "BiocFrame"]):
if mcols is not None:
if mcols.shape[0] != self.shape[1]:
raise ValueError("Number of rows in `mcols` should be equal to the number of columns.")
raise ValueError(
"Number of rows in `mcols` should be equal to the number of columns."
)
if mcols.row_names is not None:
if mcols.row_names != column_names:
raise ValueError("Row names of `mcols` should be equal to the column names.")
raise ValueError(
"Row names of `mcols` should be equal to the column names."
)
self._mcols = mcols

@property
Expand Down
8 changes: 6 additions & 2 deletions src/biocframe/_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,14 @@ def validate_cols(

if mcols is not None:
if mcols.shape[0] != len(column_names):
raise ValueError("Number of rows in `mcols` should be equal to the number of columns.")
raise ValueError(
"Number of rows in `mcols` should be equal to the number of columns."
)
if mcols.row_names is not None:
if mcols.row_names != column_names:
raise ValueError("Row names of `mcols` should be equal to the column names.")
raise ValueError(
"Row names of `mcols` should be equal to the column names."
)

return column_names, data, mcols

Expand Down

0 comments on commit 1519a1c

Please sign in to comment.