-
Notifications
You must be signed in to change notification settings - Fork 24
Open
Labels
Description
Currently, attempting to report a heterogeneous list gives a ParseException pyNetLogo attempts to the elements of a LogoList based on the type first element:
> netlogo.report('["hi" 8]')
java.text.ParseException: Java error in converting result: java.lang.ClassCastException: java.lang.Double cannot be cast to java.lang.String
at NetLogoLinkV61.NLResult.cast_logolist(NLResult.java:179)
at NetLogoLinkV61.NLResult.logoToType(NLResult.java:69)
at NetLogoLinkV61.NLResult.setResultValue(NLResult.java:15)
at NetLogoLinkV61.NetLogoLink.report(NetLogoLink.java:198)
Heterogeneous lists are quite useful, especially when associating results with parameters.
It should be possible to return heterogeneous lists by leaving the LogoList elements boxed and converting to an object array (instead of a value array), or surfacing the LogoList to jpype directly and converting on the Python side (though I don't know much about jpype). These options could have a performance hit depending on how jpype's memory sharing works, but they could be done as fallback options when returning a value array would fail.