From 8690339e7bd41d3d86fd3d2e4c3c76651f0143c3 Mon Sep 17 00:00:00 2001
From: Michael Innerberger <michael.innerberger@asc.tuwien.ac.at>
Date: Wed, 9 Aug 2023 17:00:38 -0400
Subject: [PATCH] Make sure examples don't create a folder per default

---
 examples/timingWithLevelDataCollection.m          |  5 +++--
 lib/storage/@LevelData/LevelData.m                |  1 -
 lib/storage/@LevelData/plotLevel.m                |  6 +++---
 .../@LevelDataCollection/LevelDataCollection.m    |  1 -
 lib/storage/TimeIt.m                              | 15 +++++++++------
 5 files changed, 15 insertions(+), 13 deletions(-)

diff --git a/examples/timingWithLevelDataCollection.m b/examples/timingWithLevelDataCollection.m
index ad36a75..720e65e 100644
--- a/examples/timingWithLevelDataCollection.m
+++ b/examples/timingWithLevelDataCollection.m
@@ -7,8 +7,9 @@
 nRuns = 10;
 
 %% run time measurements
+storeResults = false;
 leveldatacollection = ...
-    TimeIt('debugTiming', nRuns, 'storingLevelOrientedData', false, false);
+    TimeIt('debugTiming', nRuns, storeResults, 'storingLevelOrientedData', false, false);
 
 %% print statistical analysis of timing results
 leveldatacollection.printStatistics();
@@ -18,4 +19,4 @@ figure();
 leveldatacollection.plotStatistics('ndof');
 
 %% save results to comma-separated file
-leveldatacollection.saveToTable();
+% leveldatacollection.saveToTable();
diff --git a/lib/storage/@LevelData/LevelData.m b/lib/storage/@LevelData/LevelData.m
index 662bf4b..5b4955d 100644
--- a/lib/storage/@LevelData/LevelData.m
+++ b/lib/storage/@LevelData/LevelData.m
@@ -90,7 +90,6 @@ classdef LevelData < handle & matlab.mixin.CustomDisplay
 
             obj.category = dictionary();
 
-            ensureFolderExists(obj.root);
             % Initialise dictionary with some default values
             obj.dictionary = getDefaultDictionary();
         end
diff --git a/lib/storage/@LevelData/plotLevel.m b/lib/storage/@LevelData/plotLevel.m
index 5db7116..455d829 100644
--- a/lib/storage/@LevelData/plotLevel.m
+++ b/lib/storage/@LevelData/plotLevel.m
@@ -25,13 +25,13 @@ function ax = plotLevel(obj, category, xVariable, yVariable)
         obj
         category DataCategory
         xVariable {mustBeTextScalar}
-        yVariable cell
+        yVariable (1,:) cell
     end
 
     % Extract variables with correct category, type, and shape for y-axis
     idx = (obj.category(yVariable) == category) ...
-        & ([obj.type(yVariable).rawType]' == RawType.FLOAT) ...
-        & [obj.type(yVariable).isScalar]';
+        & ([obj.type(yVariable).rawType] == RawType.FLOAT) ...
+        & [obj.type(yVariable).isScalar];
     yVariable = yVariable(idx); 
 
     % Create handle to currently active axis object
diff --git a/lib/storage/@LevelDataCollection/LevelDataCollection.m b/lib/storage/@LevelDataCollection/LevelDataCollection.m
index 6cc2e4f..bf88675 100644
--- a/lib/storage/@LevelDataCollection/LevelDataCollection.m
+++ b/lib/storage/@LevelDataCollection/LevelDataCollection.m
@@ -57,7 +57,6 @@ classdef LevelDataCollection < handle
             if nargin >= 1
                 obj.root = rootpath;
             end
-            ensureFolderExists(obj.root);
 
             obj.metaData = dictionary(...
                 "problem", "problem", ...
diff --git a/lib/storage/TimeIt.m b/lib/storage/TimeIt.m
index b437843..dfc7b06 100644
--- a/lib/storage/TimeIt.m
+++ b/lib/storage/TimeIt.m
@@ -1,4 +1,4 @@
-function leveldatacollection = TimeIt(identifier, nRun, functionName, arguments)
+function leveldatacollection = TimeIt(identifier, nRun, storeResults, functionName, arguments)
 %%TIMEIT function wrapper for multiple runs of functions storing timing
 %data in LevelData objects
 %   leveldatacollection = TIMEIT(identifier, nRun, functionName, arguments, ...)
@@ -20,9 +20,10 @@ function leveldatacollection = TimeIt(identifier, nRun, functionName, arguments)
 %
 
     arguments
-        identifier
-        nRun
-        functionName
+        identifier {mustBeTextScalar}
+        nRun (1,1) double
+        storeResults (1,1) logical
+        functionName {mustBeTextScalar}
     end
 
     arguments (Repeating)
@@ -49,8 +50,10 @@ function leveldatacollection = TimeIt(identifier, nRun, functionName, arguments)
         leveldata.removeNonscalar();
         % Store information
         leveldatacollection.append(leveldata);
-        % Save intermediate collection to file
-        leveldatacollection.saveToFile();
+        if storeResults
+            % Save intermediate collection to file
+            leveldatacollection.saveToFile();
+        end
         % Print information on current run
         leveldatacollection.printItem();
     end
-- 
GitLab