Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
rusty1s committed Nov 18, 2024
1 parent 947f331 commit 19f0651
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions torch_frame/data/tensor_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ def __init__(
feat_dict: dict[torch_frame.stype, TensorData],
col_names_dict: dict[torch_frame.stype, list[str]],
y: Tensor | None = None,
num_rows: int | None = None,
) -> None:
self.feat_dict = feat_dict
self.col_names_dict = col_names_dict
self.y = y
self._num_rows = num_rows
self.validate()

# Quick mapping from column names into their (stype, idx) pairs in
Expand Down Expand Up @@ -176,6 +178,8 @@ def num_cols(self) -> int:
@property
def num_rows(self) -> int:
r"""The number of rows in the :class:`TensorFrame`."""
if self._num_rows is not None:
return self._num_rows
if self.is_empty:
return 0
feat = next(iter(self.feat_dict.values()))
Expand Down

0 comments on commit 19f0651

Please sign in to comment.