Skip to content

Commit a6a3f64

Browse files
Merge pull request #548 from highperformancecoder/bugfix-1789
Add checks of edge conditions in VariableValue::exportToCSV. For #1789.
2 parents cacc4a6 + 68f0a73 commit a6a3f64

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

doc/Ravel.pdf

22 Bytes
Binary file not shown.

engine/variableValue.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,8 @@ namespace minsky
417417
void VariableValue::exportAsCSV(const string& filename, const string& comment, bool tabular) const
418418
{
419419
ofstream of(filename);
420+
if (!of)
421+
throw runtime_error("Unable to open "+filename+" for writing.");
420422
if (!comment.empty())
421423
of<<R"(""")"<<comment<<R"(""")"<<endl;
422424

@@ -433,14 +435,14 @@ namespace minsky
433435
os<<json(static_cast<const NamedDimension&>(i));
434436
}
435437
of<<quoted("RavelHypercube=["+os.str()+"]")<<endl;
436-
if (tabular)
438+
if (tabular && rank()>0)
437439
of<<"HorizontalDimension="<<quoted(xv[longestDim].name)<<endl;
438440

439441
for (size_t i=0; i<xv.size(); ++i)
440442
if (!tabular || i!=longestDim)
441443
of<<CSVQuote(xv[i].name,',')<<",";
442444

443-
if (tabular)
445+
if (tabular && rank()>0)
444446
for (size_t k=0; k<dims[longestDim]; ++k)
445447
{
446448
if (k>0) of<<",";
@@ -452,7 +454,7 @@ namespace minsky
452454

453455
auto idxv=index();
454456

455-
if (tabular)
457+
if (tabular && rank()>0)
456458
{
457459
size_t stride=1;
458460
for (size_t i=0; i<longestDim; ++i)

0 commit comments

Comments
 (0)