SchedulerBase.cs Interpolate Index out of range
Closed this issue · 2 comments
I think sigmas[-1] is python's equivalent to the last element and hence supposed to be sigmas[range.Length-1]
``// If timesteps[i] is greater than the last element in range, use the last value in sigmas
else if (index == -range.Length - 1)
{
result[i] = sigmas[-1];
}
A second possible issue with the above mentioned snippet is the condition:
else if (index == -range.Length - 1)
For example, I observe that if range is an array length 1000 with values 0,1,2,...999 and timesteps is an array length 100 with values 0,10,20...999:
int index = Array.BinarySearch(range, timesteps[i]); where timesteps[i]=999, index=-1001 whilst I would have expected index=999 because this value is found in range at index 999.
I will review the pr and get this issue resolved. Thanks!
Why was the ticket closed? The error is still there! A negative index in arrays or lists does not work!
If you only want to get the last element of the array/list, you can also use the function Last
from Linq.
result[i] = sigmas.Last();