You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Boiled it down to this:
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:
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?
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.
The text was updated successfully, but these errors were encountered:
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.
Boiled it down to this:
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 usingList.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:
Dynamo/test/Libraries/CoreNodesTests/ListTests.cs
Line 364 in dec6240
What's interesting, looking at the source, is that the
Max()
method, whichList.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
Dynamo/src/Libraries/CoreNodes/Math.cs
Line 398 in 852ae53
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.The text was updated successfully, but these errors were encountered: