-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
print_truncated() does not handle other list-like objects (e.g. numpy arrays), making for messy outputs for __repr__().
BiocUtils/src/biocutils/print_truncated.py
Lines 26 to 29 in e4d9f8b
| elif isinstance(x, list): | |
| return print_truncated_list( | |
| x, truncated_to=truncated_to, full_threshold=full_threshold | |
| ) |
Current behavior
When executing in a jupyter notebook, the output is not truncated:
import numpy as np
from biocframe import BiocFrame
bframe = BiocFrame(
{
"x": np.random.normal(size=40),
"y": np.random.normal(size=40)
}
)
bframe
>>
BiocFrame(data={'x': array([ 0.30948609, -1.38289079, -0.43285149, 0.37465808, 0.47068355,
0.72958816, -1.99939489, 0.22849544, -0.15900403, 0.1183286 ,
-0.12025139, -0.31011542, 0.2261699 , -1.23073433, -0.98790469,
0.37100134, 1.11801526, 1.89313668, -0.72167481, 1.21427698]), 'y': array([-0.96331348, 0.90240032, 0.45289567, 0.74154537, 0.09252068,
-0.30991981, 0.81609081, -0.21092948, 0.17191497, 0.01036059,
0.21667765, -0.35905261, -0.53184703, -0.64036229, 0.25275972,
-0.31644878, -0.57082027, -0.39594529, 2.26653958, -0.31656108])}, number_of_rows=20, column_names=['x', 'y'])Proposed solution
As a start,
elif isinstance(x, (list, np.ndarray)):
return print_truncated_list(
list(x), truncated_to=truncated_to, full_threshold=full_threshold
)Question
Should we handle other list-like objects?
Metadata
Metadata
Assignees
Labels
No labels