A new major release: ZOSPy v2!
This release contains a lot of changes under the hood, making ZOSPy more reliable and easier to extend.
For example, it is now easier to develop new analyses.
This release also removes a few deprecated functions.
As a result, some of the changes are not backwards compatible with older ZOSPy versions.
Backwards-incompatible changes
- Many functions use optional boolean arguments to enable or disable certain features. For example,
new_analysis
has asettings_first
argument that allows to change the analysis settings before running them. These arguments are now keyword-only.new_analysis(<AnalysisType>, True)
does not work anymore; usenew_analysis(<AnalysisType>, settings_first=True)
instead. Here's a list of the impacted functions:zospy.analyses.new.new_analysis
:settings_first
is now a keyword-only argument.zospy.api.apisupport.load_zosapi_nethelper
:preload
is now a keyword-only argument.zospy.api.apisupport.load_zosapi
:preload
is now a keyword-only argument.zospy.functions.lde.find_surface_by_comment
:case_sensitive
is now a keyword-only argument.zospy.functions.nce.find_object_by_comment
:case_sensitive
is now a keyword-only argument.zospy.utils.flatten_dict
:keep_unflattened
is now a keyword-only argument.zospy.zpcore.OpticStudioSystem.load
:saveifneeded
is now a keyword-only argument.zospy.zpcore.OpticStudioSystem.new
:saveifneeded
is now a keyword-only argument.zospy.zpcore.OpticStudioSystem.close
:saveifneeded
is now a keyword-only argument.zospy.zpcore.ZOS.__init__
: all parameters are now keyword-only arguments.
zospy.zpcore.ZOS.wakeup
,zospy.zpcore.ZOS.connect_as_extension
,zospy.zpcore.ZOS.create_new_application
andzospy.zpcore.ZOS.connect_as_standalone
have been removed. For more information, see New connection methodszospy.functions.nce.get_object_data
has been removed because it implements a conversion that is now done automatically byzospy.api.codecs.OpticStudioInterfaceEncoder
.- The API for analyses has changed. For more information, see New analysis interface
New connection methods
A new connection method ZOS.connect
has been introduced in ZOSPy 1.2.0.
All other connection methods (connect_as_extension
, create_new_application
and connect_as_standalone
) have been removed.
New analysis interface
The analysis interface has been rewritten and is now object oriented.
In general, an analysis that was previously run this way:
zp.analysis.category.some_analysis(oss, parameter_1=1, parameter_2="123")
now has to be run this way:
zp.analysis.category.SomeAnalysis(parameter_1=1, parameter_2="123").run(oss)
For more information about the new interface, see the documentation.
The old interface contained a lot of duplicate code, which has been solved in the new interface.
As a result, developing new analyses is a lot easier now.
Furthermore, the new interface provides a unified way to parse analysis text output.
Parsers are written in lark, and because ZOSPy provides predefined parsers for common constructs in the OpticStudio output, they can be quite concise. For example, this is the parser for the cardinal points analysis:
start: "\ufeff"? _NEWLINE? text _field+ text+ cardinal_points
cardinal_points: cardinal_points_header _NEWLINE cardinal_point+
!cardinal_points_header: ("Object Space" | "Image Space")~2 -> string_list
cardinal_point: /[\w -]+\w/ ":" _number _number _NEWLINE
%import .zospy (_field, _number, text, STRING)
%import common.NEWLINE -> _NEWLINE
%import common (LETTER, WORD, WS_INLINE)
%ignore WS_INLINE
Improved documentation
We have largely rewritten and extended the documentation. Check it out at zospy.readthedocs.io!
Improved development workflow
ZOSPy now uses Hatch for project management.
Hatch provides a unified interface for all development-related tasks, such as testing, formatting, building documentation, generating test reference data etc.
Furthermore, it can manage Python interpreters, so unit tests can be run for all Python versions without having to install all interpreters manually.
Read more in our contributing guidelines.
Contributors
- @jwmbeenakker @LucVV @crnh
- This release was in part funded by the Netherlands Organisation for Scientific Research (NWO) through the OPENOPTICS project.