Fixes test for histBuilder with locale ES_es
commit:13a3fd2 When using locale ES_es, double formatting uses a comma instead a decimal dot. So, an specific conversion has to be done
Good catch! What happens for methods with a single double arg and list args? e.g. hist.bottom(1.2) or plt.plot().add(Arrays.asList(1.3, 2)). Could you add test cases with ES_es locale for them and also your original fix?
If they are also impacted, they'd be fixed at once. In such case, prefer calling TypeConversion.INSTANCE.toSafeDouble on more abstract layer such as CompositeBuilder#addToArgs and CompositeBuilder#addToKwargs.
Good catch! What happens for methods with a single double arg and list args? e.g.
hist.bottom(1.2)orplt.plot().add(Arrays.asList(1.3, 2)). Could you add test cases withES_eslocale for them and also your original fix?If they are also impacted, they'd be fixed at once. In such case, prefer calling
TypeConversion.INSTANCE.toSafeDoubleon more abstract layer such asCompositeBuilder#addToArgsandCompositeBuilder#addToKwargs.
The problem seems to arise only when using String.format() with a double. When doing an List<Double>.toString() or double[].toString(), Java does it correctly
> $ jshell
| Welcome to JShell -- Version 11.0.4
| For an introduction type: /help intro
jshell> Locale currentLocale = Locale.getDefault();
currentLocale ==> es_ES
jshell> System.out.println(List.of(5.6, 7.8));
[5.6, 7.8]
jshell> System.out.println(Arrays.toString(new double[] {5.6, 7.8}));
[5.6, 7.8]
jshell> System.out.println("Double value is "+ 8.9);
Double value is 8.9
jshell> System.out.println(String.format("Double value is %.2f", 8.9));
Double value is 8,90
So I don't think it is necessary to do it in all string conversions, but only on those that use String.format()
So I don't think it is necessary to do it in all string conversions, but only on those that use String.format()
This is very interesting. I would like to avoid any other future change missing to call toSafeDouble. Then, what about adding the default locale ROOT which does not depend on the locale setting globally in matplotlib4j instead of having toSafeDouble?
PlotImpl(PythonConfig pythonConfig, boolean dryRun) {
this.pythonConfig = pythonConfig;
this.dryRun = dryRun;
Locale.setDefault(Locale.ROOT);
}
Yeah, of course! It is another option. I suppose it will work. I'll try it to see if we get the desired output