Closed MgSam closed 5 years ago
When trying to retrieve an item from an empty series, Deedle throws
System.InvalidOperationException: 'OptionalValue.Value: Value is not available'
rather than an IndexOutOfBoundsException. This misleading exception caused me to spend a lot of time trying to find the problem.
IndexOutOfBoundsException
Repro using NUnit:
[TestCase(true, new object[] { "foo", null})] public void SeriesBrokenTest(bool shouldThrow, object[] pairs) { var dict = arrayToDictionary<string, double?>(pairs); var series = dict.ToSeries(); Assert.Throws<Exception>(() => { var newSeries = series.Where(k => k.Value != null).Sort(); var item = newSeries.GetAt(0); //Throws wrong exception here }); } private Dictionary<K, V> arrayToDictionary<K, V>(object[] pairs) { var dict = new Dictionary<K, V>(); for (var i = 0; i < pairs.Length - 1; i += 2) { dict.Add((K)pairs[i], (V)pairs[i + 1]); } return dict; }
fixed in #437
When trying to retrieve an item from an empty series, Deedle throws
rather than an
IndexOutOfBoundsException
. This misleading exception caused me to spend a lot of time trying to find the problem.Repro using NUnit: