|
| 1 | +"""Tests material library functions and pretty printing""" |
| 2 | + |
| 3 | +import tidy3d as td |
| 4 | + |
| 5 | + |
| 6 | +def test_material_library_summary(): |
| 7 | + """Test to make sure we can print the material library without error.""" |
| 8 | + print(td.material_library) |
| 9 | + |
| 10 | + |
| 11 | +def test_material_summary(): |
| 12 | + """Test the string method for each material in the material library.""" |
| 13 | + |
| 14 | + for _, material in td.material_library.items(): |
| 15 | + print(material) |
| 16 | + |
| 17 | + |
| 18 | +def test_variant_summary(): |
| 19 | + """Test the string method for each variant in the material library.""" |
| 20 | + |
| 21 | + for _, material in td.material_library.items(): |
| 22 | + # graphene in the material library is run differently than the other materials and |
| 23 | + # doesn't have the variant structure so we exclude any materials that are in this |
| 24 | + # format |
| 25 | + if hasattr(material, "variants"): |
| 26 | + for variant in material.variants: |
| 27 | + print(variant) |
| 28 | + |
| 29 | + |
| 30 | +def test_material_library_medium_repr(): |
| 31 | + """Test the new repr method does not error for material library variants.""" |
| 32 | + |
| 33 | + for material_key, material in td.material_library.items(): |
| 34 | + if hasattr(material, "variants"): |
| 35 | + for variant_key in material.variants: |
| 36 | + mat = td.material_library[material_key][variant_key] |
| 37 | + print(mat) |
| 38 | + print(repr(mat)) |
| 39 | + |
| 40 | + |
| 41 | +def test_medium_repr(): |
| 42 | + """Test the new repr method does not error for regular media with and without names.""" |
| 43 | + |
| 44 | + test_media = [ |
| 45 | + td.Medium(permittivity=1.5**2), |
| 46 | + td.Medium(permittivity=1.5**2, name="material"), |
| 47 | + td.material_library["SiO2"]["Horiba"].updated_copy(name=None), |
| 48 | + ] |
0 commit comments