-
Notifications
You must be signed in to change notification settings - Fork 267
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🐛 bug report] XML parsing of float values seems to respect current locale #499
Comments
Hi @jungbluthb, I could reproduce the issue on my machine by adding the following at the start of std::locale l1("de_DE.UTF-8");
std::locale::global(l1); And then running:
Could you please check if adding the following fixes the issue? const std::locale &l1 = std::locale::classic();
std::locale::global(l1); (Note that this won't affect scenes loaded from Python, we'll need to find a better place to set the locale in all cases if we decide to adopt this fix). |
Hello @merlinND, thank you for your reply. Unfortunately it seems that the problem is caused by my development environment (conda venv with
I can only reproduce using your hint from above. I think I have to check my environment or stick to python dictionaries for scene creation. Sorry for the confusion. |
Interesting! |
Let's leave this one open. It would be good to replace the parsing routines with something guaranteed to be locale-independent. |
Summary
If I try to run the inverse rendering example from the documentation (https://mitsuba2.readthedocs.io/en/latest/src/inverse_rendering/advanced.html), I run into issues during scene loading. It seems like the parser for float values respects my current locale (de.DE) and therefore isn't able to parse the give floating point numbers which are using a point as decimal separator.
System configuration
scalar_rgb
scalar_spectral
packet_rgb
gpu_autodiff_rgb
Description
During testing I run into issues while loading scenes from xml-files provided in ressources. The float-values defined in the files use a dot as decimal separator. This leads to runtime errors during parsing:
RuntimeError: [xml.cpp:223] Error while loading "res/mitsuba2/test_mitsuba2_inverse_rendering_01.xml" (at line 37, col 4): could not parse floating point value "28.8415".
As far as I can see xml.cpp uses "stof" for conversion which seems to respect the current locale. In my opinion this should not happen, since the xml scene description has a fixed format which does not seem to depend on the current system locale. I can circumvent this issue by rewriting all floats to the expontial notation (e.g. 10e-1), but doing this for all floats is quit tedious and error prone. Maybe someone could fix this or point me into the right direction, if I am missing something on my side. Thank you in advance.
Steps to reproduce
scene = load_file('~/mitsuba2/resources/data/docs/scenes/shape_ply_bunny.xml')
The text was updated successfully, but these errors were encountered: