-
Notifications
You must be signed in to change notification settings - Fork 11
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
locale.setlocale raising exception #66
Comments
Hi, Thanks for reporting this! Question: what happens if you run this code prior to importing ZOSPy: import locale
locale.setlocale(locale.LC_ALL, "") Do you then still get an exception on import (I am afraid you will)? I looked up why we implemented the locale options in It is possible to not reset the locale to the original locale after determining the decimal separators etc., but then we may permanently change the locale for the full script in which ZOSPy is used, and that is something I prefer not to do. |
I partly understand that Zemax is using commas in the GUI on German localizied Systems. But for programming I think it would be OK not to interfere with the locale at all.
And Python uses dots in output. Optic Studio itself is putting commas into text output on german localized systems, but it only accepts dots in text input (i.e. source files) |
Hi, Thanks for checking! ZOSPy uses the decimal and thousands separators to parse the text output of analyses. Many OpticStudio analyses do not provide access to their results through the ZOS-API, so you need to use the text output (you can check the Zernike Standard Coefficients analysis for an example). Knowing the decimal separator is very relevant for that purpose. In the past we used regexes that allowed for both a dot and a comma as decimal separator, but this turned out to be unreliable in some cases. If you want to know more about this, please take a look at the other issues / pull requests in this repository. Another question: what happens if you replace this line in the original Line 26 in b9cef91
with loc = locale.setlocale(locale.LC_ALL) Do you still get a |
Yes, that makes the error on importing disappear. That seems to be correct. But Zernike Standard Coefficients analysis is not working.
--Test was run on 2024-03-07 As far as I can see, |
I see, the Zernike Standard Coefficients is an older analysis that was written in the early stages of ZOSPy. It doesn't use the localized decimal separator yet. GitHub has a search function (your IDE has one, too) so it is quite easy to search for uses of symbols. If you use that search function you will see that some newer analyses (in You just identified another issue, which is related to date notation. I didn't encounter this date notation earlier and suppose @LucVV also missed this case. Anyways, this is exactly the reason why we are re-implementing the analysis parsers from scratch. I agree with one of your previous comments that all analysis results should be available through the API. Unfortunately, Zemax / Ansys doesn't seem to be working on this or even considering this, so it is still useful to have parsers in ZOSPy. Thanks for testing my suggestion, good to see it works. We are currently working on a solution. |
I propose we go for |
A fix to this problem has just been released with ZOSPy 1.2.1. |
Problem
cannot import ZOSPy 1.2.0 as is.
It is raising a
locale.Error: unsupported locale setting
What version of ZOSPy are you running?
1.2.0
What version of OpticStudio are you running?
2023 R1.03
Which operating system do you use?
Windows 10
In which environment do you use ZOSPy?
In which connection modes does the problem occur?
Example code
Output
Additional information
No response
The text was updated successfully, but these errors were encountered: