cihologramas / pyoptools

Python tools for optical design
GNU General Public License v3.0
137 stars 46 forks source link

Unable to retrieve glass types with minus sign in name #107

Closed rdgraham closed 2 years ago

rdgraham commented 3 years ago

It is not possible to retrieve glass material types in the usual manner for two of the glass types available in the materials lib, these are misc_soda-lime and hikari_i-line. This is because they have a minus sign in the name which is not valid for python attribute access, will be parsed as a subtraction operator.

>>> material.misc_soda-lime['Rubin-clear']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'pyoptools.raytrace.mat_lib.material' has no attribute 'misc_soda'

A work around is to use the following: soda_lime_glass = getattr(material, 'misc_soda-lime')['Rubin-clear']

My suggestion would be to replace the minus signs with underscores.