Skip to content

Commit

Permalink
Merge pull request #32 from jasondet/main
Browse files Browse the repository at this point in the history
Avoid `nda.tolist()` in `Table.get_dataframe()` when possible
  • Loading branch information
gipert authored Nov 3, 2023
2 parents 763769d + e53fc41 commit 1607492
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/lgdo/types/scalar.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Scalar(LGDO):

# TODO: do scalars need proper numpy dtypes?

def __init__(self, value: int | float, attrs: dict[str, Any] = None) -> None:
def __init__(self, value: int | float | str, attrs: dict[str, Any] = None) -> None:
"""
Parameters
----------
Expand Down
5 changes: 4 additions & 1 deletion src/lgdo/types/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,10 @@ def get_dataframe(
if not hasattr(column, "nda"):
raise ValueError(f"column {col} does not have an nda")
else:
df[prefix + str(col)] = column.nda.tolist()
if len(column.nda.shape) == 1:
df[prefix + str(col)] = column.nda
else:
df[prefix + str(col)] = column.nda.tolist()

return df

Expand Down

0 comments on commit 1607492

Please sign in to comment.