NDataSeries .FillFromEnumerable with Linq expression throws NotImplementException


https://www.nevron.com/Forum/Topic9568.aspx
Print Topic | Close Window

By Marcus Förster - 8 Years Ago
It looks like NDataSeries<T>.FillFromEnumerable calls Reset on its argument.
The IEnumerable object returned by System.Linq.Enumerable.Select (and possibly other Linq methods) does not implement Reset, and throws NotImplementedException.

To reproduce:
new NDataSeriesDouble().FillFromEnumerable(new double[] { 0, 1 }.Select(x => x));

Expected behavior: Fills the series with the values 0 and 1.
Observed behavior: Throws NotImplementedException.

By Nevron Support - 8 Years Ago
Hi Marcus,

Yes that's correct - it does call Reset internally just to make sure the enumerator starts from the first item. We have removed the Reset and this problem will not appear in future SP's. For the time being you can use the following code to workaround the
NDataSeriesDouble dataSeries = new NDataSeriesDouble();

IEnumerator enumerator = new double[] { 0, 1 }.Select(x => x).GetEnumerator();
while (enumerator.MoveNext())
{
dataSeries.Add(enumerator.Current);
}

Hope this helps - let us know if you meet any problems or have any questions.