Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WiP: Fancy print #361

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

WiP: Fancy print #361

wants to merge 6 commits into from

Conversation

dinga92
Copy link
Contributor

@dinga92 dinga92 commented Sep 6, 2015

Nice printing of dataset objects, so that samples and sa are in rows and features/fa are in columns. Just disclosing it here for a feedback, not intended for merge at the moment. For now it is using external library "tabulate" (pipable, MIT licence).

example:
ds = normal_feature_dataset(nonbogus_features=[0,1])
ds.prt()

------  -------  ----------------  -----  -----  -----  -----
                 nonbogus_targets  L0     L1
chunks  targets
0       L0                         0.130  -0.10  -0.02  0.077
0       L0                         0.318  0.238  -0.14  -0.40
0       L0                         0.286  -0.02  0.101  -0.24
0       L0                         0.757  -0.20  -0.43  -0.21
0       L0                         0.345  0.070  -0.31  0.010
0       L0                         0.613  0.217  0.125  -0.32
0       L0                         0.329  0.129  -0.20  0.024
0       L0                         0.691  -0.06  0.074  0.375
0       L0                         0.745  -0.03  0.173  0.295
0       L0                         0.282  -0.23  0.188  0.281
1       L0                         0.244  -0.26  0.042  0.171
1       L0                         0.485  -0.10  -0.35  0.319
1       L0                         0.715  -0.10  0.103  0.178
1       L0                         0.710  -0.04  0.016  0.337
1       L0                         0.586  0.225  -0.37  0.085
1       L0                         0.633  -0.07  -0.23  0.369
1       L0                         0.054  -0.47  -0.20  0.306
1       L0                         0.655  -0.04  -0.19  0.095
1       L0                         0.648  -0.09  0.261  -0.26
1       L0                         0.659  -0.40  -0.03  0.350
2       L0                         0.152  -0.00  0.133  0.221
2       L0                         0.611  0.121  0.273  -0.35
2       L0                         1.0    0.119  -0.13  -0.21
2       L0                         0.118  -0.30  -0.10  -0.04
2       L0                         0.467  -0.16  0.723  0.048
2       L0                         0.375  -0.16  0.389  -0.19
2       L0                         0.192  0.201  0.129  0.441
2       L0                         0.308  -0.03  0.096  0.161
2       L0                         0.426  0.177  -0.03  -0.42
2       L0                         0.293  -0.59  0.217  0.203
3       L0                         0.526  -0.23  -0.28  0.089
3       L0                         0.778  -0.41  -0.16  -0.11
3       L0                         0.457  -0.06  0.552  -0.29
3       L0                         0.412  -0.06  0.286  -0.11
3       L0                         0.434  0.093  -0.07  -0.00
3       L0                         0.457  0.200  0.004  -0.31
3       L0                         0.146  -0.01  0.119  0.086
3       L0                         0.589  -0.07  -0.17  -0.53
3       L0                         0.741  -0.16  -0.25  -0.13
3       L0                         0.803  -0.01  0.205  -0.00
4       L0                         0.593  0.201  0.227  -0.25
4       L0                         0.378  -0.21  -0.09  0.325
4       L0                         0.473  -0.11  -0.45  -0.01
4       L0                         0.322  0.206  0.119  0.394
4       L0                         0.785  -0.15  0.190  0.139
4       L0                         0.317  0.211  -0.19  0.149
4       L0                         0.406  0.162  0.037  0.259
4       L0                         0.739  0.079  -0.16  -0.32
4       L0                         0.317  0.363  -0.36  -0.07
4       L0                         0.486  0.143  -0.00  0.019
------  -------  ----------------  -----  -----  -----  -----
Ommitted 50 rows and 0 columns

ds.prt(sa='targets', height=10)

-------  ----------------  -----  -----  -----  -----
         nonbogus_targets  L0     L1
targets
L0                         0.531  0.254  0.227  0.131
L0                         0.664  -0.02  0.117  -0.13
L0                         0.501  0.157  0.039  -0.29
L0                         0.250  0.237  0.122  0.034
L0                         0.617  -0.09  -0.13  0.419
L0                         0.105  0.033  -0.04  -0.40
L0                         0.167  0.040  0.136  0.186
L0                         0.578  -0.08  -0.20  0.656
L0                         0.154  0.032  -0.17  0.320
L0                         0.129  -0.03  0.335  0.144
-------  ----------------  -----  -----  -----  -----
Ommitted 90 rows and 0 columns

@yarikoptic yarikoptic changed the title Fancy print WiP: Fancy print Sep 6, 2015
@yarikoptic
Copy link
Member

in general i wholeheartedly support this feature! Could you include example in the pr description of how it would look like?

@dinga92
Copy link
Contributor Author

dinga92 commented Sep 6, 2015

of course I immediately found a bug and it doesn't work for datasets with attributesCollection :)

# Check if ds stays intact
table = ds.to_table(n_digits=1)
assert_array_equal(ds.samples, old_ds.samples)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would be nice also to add a smoke test which would sweep through all test datasets and see if code doesn't blow. smth like

@sweepargs(ds=datasets.itervalues())
def test_to_table_test_datasets(ds):
    dstxt = ds.to_table()
    for a in itertools.chain(ds.sa.keys(), ds.fa.keys(), ds.a.keys()):
         assert(a in dstxt)

@yarikoptic
Copy link
Member

@dinga92 interested to bring this baby to the finish line? ;)

@mih
Copy link
Member

mih commented Jan 16, 2016

@dinga92 Ping! Let's get this done -- would be most appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants