diff --git a/TimeSeriesAnalysis.Tests/Tests/PlantSimulatorSerialization.cs b/TimeSeriesAnalysis.Tests/Tests/PlantSimulatorSerialization.cs
index d869812..b0e9062 100644
--- a/TimeSeriesAnalysis.Tests/Tests/PlantSimulatorSerialization.cs
+++ b/TimeSeriesAnalysis.Tests/Tests/PlantSimulatorSerialization.cs
@@ -97,7 +97,9 @@ public void DeserializedPlantSimulatorAndTimeSeriesDataObjects_AreAbleToSimulate
var inputDataJsonTxt = new CsvContent(inputData.ToCsvText());
var inputData2 = new TimeSeriesDataSet();
- inputData2.LoadFromCsv(inputDataJsonTxt);
+ var isOkData = inputData2.LoadFromCsv(inputDataJsonTxt);
+
+ Assert.IsTrue(isOkData,"uanble to load data from csv");
// 3. deserialize to a new object
var plantSim2 = PlantSimulatorSerializer.LoadFromJsonTxt(plantsimJsonTxt);
diff --git a/TimeSeriesAnalysis.csproj b/TimeSeriesAnalysis.csproj
index 5dbff76..4f8d940 100644
--- a/TimeSeriesAnalysis.csproj
+++ b/TimeSeriesAnalysis.csproj
@@ -14,7 +14,7 @@
False
https://github.com/equinor/TimeSeriesAnalysis.git
readme.md
- 1.3.38
+ 1.3.39
Equinor
Equinor
true
diff --git a/TimeSeriesAnalysis/TimeSeriesDataSet.cs b/TimeSeriesAnalysis/TimeSeriesDataSet.cs
index 250483e..1e31165 100644
--- a/TimeSeriesAnalysis/TimeSeriesDataSet.cs
+++ b/TimeSeriesAnalysis/TimeSeriesDataSet.cs
@@ -225,12 +225,21 @@ public TimeSeriesDataSet Combine(TimeSeriesDataSet inputDataSet)
///
- /// Fills a dataset with variables, values and dates
+ /// Fills a dataset with variables, values and dates, removes "time" or "Time" from variableDict if present, and stores timestamps in internal dateTimes
///
///
///
- private void Fill(DateTime[] dateTimes, Dictionary variableDict)
+ private bool Fill(DateTime[] dateTimes, Dictionary variableDict)
{
+ if (dateTimes == null)
+ return false;
+ if (variableDict == null)
+ return false;
+ if (variableDict.Keys == null)
+ return false;
+ if (variableDict.Keys.Count() == 0)
+ return false;
+
if (variableDict.ContainsKey("Time"))
{
variableDict.Remove("Time");
@@ -239,12 +248,22 @@ private void Fill(DateTime[] dateTimes, Dictionary variableDic
{
variableDict.Remove("time");
}
+ N = variableDict[variableDict.Keys.First()].Length;
+ if (N == 0)
+ {
+ return false;
+ }
+ // load actual dataset
dataset = variableDict;
- N = dataset[dataset.Keys.First()].Length;
if (dateTimes.Length > 1)
{
timeStamps = dateTimes.ToList();
}
+ else
+ {
+ return false;
+ }
+ return true;
}
@@ -481,9 +500,9 @@ public void InitNewSignal(string signalName, double initalValue, int N, double n
out Dictionary variableDict, dateTimeFormat);
if (isOK)
{
- Fill(dateTimes, variableDict);
+ return Fill(dateTimes, variableDict);
}
- return isOK;
+ return false;
}
@@ -546,9 +565,9 @@ public void CreateTimestamps(double timeBase_s, DateTime? t0 = null)
out Dictionary variableDict, dateTimeFormat);
if (isOk)
{
- Fill(dateTimes, variableDict);
+ return Fill(dateTimes, variableDict);
}
- return isOk;
+ return false;
}
///