-
Notifications
You must be signed in to change notification settings - Fork 668
Description
Dynamo version
2.0.1.5055
Operating system
Windows 10
What did you do?
Took a list of numbers from a file (so as strings), sorted and converted to number, then tried to find the largest one using List.MaximumItem.
What did you expect to see?
The largest value in the list returned.
What did you see instead?
null, with a warning.
Tests reveal that if some numbers have a decimal separator and others don't, then the output from String.ToNumber is not uniform, which causes problems when using List.MaximumItem, which apparently cannot handle a list that includes e.g. Int and Double.
There is actually test code for this which I imagine should have picked this up:
| Assert.AreEqual(66, List.MaximumItem(new List<object> { 8.223, 4, 0.64, 66, 10.2 })); |
What's interesting, looking at the source, is that the Max() method, which List.MaximumItem uses, seems to cast its inputs to doubles. My C# is rusty but I'm feel like this should be working?
Dynamo/src/Libraries/CoreNodes/List.cs
Line 397 in 852ae53
| return list.Max<object, object>(DoubleConverter); |
Dynamo/src/Libraries/CoreNodes/Math.cs
Line 398 in 852ae53
| public static double Max(double value1, double value2) |
Looking into the DoubleConverter reveals that this was added to fix exactly this problem here #2041, which maybe it did, but perhaps got unfixed with an update..? I'm in over my head at this point, though.
