convexengineering / gpkit

Geometric programming for engineers
http://gpkit.readthedocs.org
MIT License
206 stars 40 forks source link

Printing sol.table()/summary() with large arrays is unreadable. #1444

Closed 1ozturkbe closed 3 years ago

1ozturkbe commented 5 years ago

This is for EGPAnet, where I am trying to read the output of very large VectorVariables, some of them 20 long. GPkit likes printing these in a nice long vertical vector, which makes the output actually exceed the length allowed by cmd. I will make a fix.

bqpd commented 5 years ago

what does "allowed by cmd" mean?

bqpd commented 5 years ago

the way row-size is chosen is a bit overly complicated, so feel free to tag me in on this on

1ozturkbe commented 5 years ago

As in, 'my terminal is blowing up, past its ability to contain text', since the output is many pages long. Now that I look at the f'ns for table() I would like some help here :)

1ozturkbe commented 5 years ago

(this model has 600 vars or so, and it's all presented in a one dimensional vector form haha)

bqpd commented 5 years ago

does adding a new line after 780 which reads ncols = 5 (or some other constant) lead to an acceptable table output? If so, the solution may be just to allow the user to hard-code the number of columns. This will create confusion between 1D and 2D variables, which is why we don't do it now...

You could also, without changing the code, do .table(maxcols=600) and see if that looks ok

1ozturkbe commented 5 years ago

That is definitely much nicer (I tried 5). Maybe it is best to leave it to the user. But I also don't mind the format where we have ellipses, and you could set the cutoff in ncols.

1ozturkbe commented 5 years ago

Then if the user wants to be able to dig in, they can just call sol('varname'), because then it prints a flat vector.

1ozturkbe commented 5 years ago

I like the max columns, but it would also be nice to specify ncols like we did in this case.

bqpd commented 5 years ago

I don't think users should be able to specify ncols, because it makes it impossible to distinguish 2D and 1D variables...I like the notion of cutoffs, though.

bqpd commented 5 years ago

What's your ideal table output?

1ozturkbe commented 5 years ago

I think it'd be like this... [ X X ... X X ; X X ... X X ; | | | | ; (could just be a single line indicating continuation). X X ... X X ;]

1ozturkbe commented 5 years ago

I think it's rather impossible to look at more than 5-8 values per row of anything anyways, so we might as well have some arbitrary cutoff.

bqpd commented 5 years ago

in a fixed-width format, is this equivalent? (arbitrary cutoff doesn't work for all use-cases)

[ x1   x2   ... x101 x102
  x103 x104 ... x203 x204
  ...
  x503 x504 ... x599 x600 ]
bqpd commented 5 years ago

what about this instead? (since it's a 1d vector) I'd implement this with a maxrows parameter

[ x1
  x2
  ...
  x599
  x600 ]
1ozturkbe commented 5 years ago

Hmmm, it is useful to have some notion of 1D/2D I guess. Would it be possible to specify multiple rows for 2D vectors, single row for everything else?

bqpd commented 5 years ago

yup! you mean multiple columns, right?

bqpd commented 5 years ago

I'm thinking default maxrows = 50, and anything above that gets chopped down to maxrows.

1ozturkbe commented 5 years ago

Oh I was thinking having rows instead of columns for each output. Columns are confusing because the units and descriptions start floating far away.

bqpd commented 5 years ago

unfortunately having more than a few columns destroys readability in many terminals because they deal with linewrapping terribly.

1ozturkbe commented 5 years ago

I get this creates issues with 2D arrays, but I still think it makes sense to arbitrarily truncate and/or wrap in this case. I think it is worse to have a table that is a page long in each variable, than to have some outputs not showing immediately.

bqpd commented 5 years ago

yeah, i think maybe just taking anything that exceeds max rows and showing it in a single line as [ x1 ...(98 values skipped)... x100] is making the most sense to me

On Thu, Oct 17, 2019, 11:57 Berk Ozturk notifications@github.com wrote:

I get this creates issues with 2D arrays, but I still think it makes sense to arbitrarily truncate and/or wrap in this case. I think it is worse to have a table that is a page long in each variable, than to have some outputs not showing immediately.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/convexengineering/gpkit/issues/1444?email_source=notifications&email_token=AALKAGFBRIPQLIEH7MBAW2DQPCDLZA5CNFSM4JB3FCXKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEBQTREA#issuecomment-543242384, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALKAGB4O3WUQ37CKAUSXK3QPCDLZANCNFSM4JB3FCXA .

1ozturkbe commented 5 years ago

But then why not just show maxrows, equal to maxrows? (eg. [X X ... X X])?

bqpd commented 5 years ago

not following how that's different?

1ozturkbe commented 5 years ago

oh, it's instead of skipping 98 values, you skip 100-maxcols.

bqpd commented 3 years ago

Looking at this a bit later, I think GPkit should always print all info - users can filter by changing which tables/variables they print.