MCPcopy Create free account
hub / github.com/Cantera/cantera / info

Method info

src/base/SolutionArray.cpp:475–557  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

473} // end unnamed namespace
474
475string SolutionArray::info(const vector<string>& keys, int rows, int width)
476{
477 fmt::memory_buffer b;
478 int col_width = 12; // targeted maximum column width
479 vector<string> components;
480 if (keys.size()) {
481 components = keys;
482 } else {
483 components = componentNames();
484 }
485 try {
486 // build columns
487 vector<long int> index;
488 for (const auto ix : m_active) {
489 index.push_back(ix);
490 }
491 vector<vector<string>> cols = {integerColumn("", index, rows, col_width)};
492 vector<vector<string>> tail; // trailing columns in reverse order
493 size_t size = cols.back().size();
494
495 // assemble columns fitting within a maximum width; if this width is exceeded,
496 // a "..." separator is inserted close to the center. Accordingly, the matrix
497 // needs to be assembled from two halves.
498 int front = 0;
499 int back = len(components) - 1;
500 int fLen = len(cols.back()[0]);
501 int bLen = 0;
502 int sep = 5; // separator width
503 bool done = false;
504 while (!done && front <= back) {
505 string key;
506 while (bLen + sep <= fLen && front <= back) {
507 // add trailing columns
508 key = components[back];
509 auto col = formatColumn(key, getComponent(key), rows, col_width);
510 if (len(col[0]) + fLen + bLen + sep > width) {
511 done = true;
512 break;
513 }
514 tail.push_back(col);
515 bLen += len(tail.back()[0]);
516 back--;
517 }
518 if (done || front > back) {
519 break;
520 }
521 while (fLen <= bLen + sep && front <= back) {
522 // add leading columns
523 key = components[front];
524 auto col = formatColumn(key, getComponent(key), rows, col_width);
525 if (len(col[0]) + fLen + bLen + sep > width) {
526 done = true;
527 break;
528 }
529 cols.push_back(col);
530 fLen += len(cols.back()[0]);
531 front++;
532 }

Callers 15

test_shortMethod · 0.95
test_longMethod · 0.95
test_scientificMethod · 0.95
test_plus_minus_iMethod · 0.95
test_plus_minus_fMethod · 0.95
test_plus_minus_eMethod · 0.95
test_stringsMethod · 0.95
test_double_vectorMethod · 0.95
test_integer_vectorMethod · 0.95
test_string_vectorMethod · 0.95
test_water_simpleMethod · 0.95
test_water_extraMethod · 0.95

Calls 9

integerColumnFunction · 0.85
lenFunction · 0.85
formatColumnFunction · 0.85
fmt_appendFunction · 0.85
nativeModeMethod · 0.80
whatMethod · 0.80
sizeMethod · 0.45
endMethod · 0.45
thermoMethod · 0.45

Tested by 14

test_shortMethod · 0.76
test_longMethod · 0.76
test_scientificMethod · 0.76
test_plus_minus_iMethod · 0.76
test_plus_minus_fMethod · 0.76
test_plus_minus_eMethod · 0.76
test_stringsMethod · 0.76
test_double_vectorMethod · 0.76
test_integer_vectorMethod · 0.76
test_string_vectorMethod · 0.76
test_water_simpleMethod · 0.76
test_water_extraMethod · 0.76