File tree Expand file tree Collapse file tree
tidy3d/components/material Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -128,6 +128,12 @@ def __getattr__(self, name: str):
128128 Extend that mapping as additional cross-medium shim behaviour becomes
129129 necessary.
130130 """
131+ # first check whether the attribute is present (e.g. cached properties, dunders...)
132+ try :
133+ return super ().__getattr__ (name )
134+ except AttributeError :
135+ pass
136+
131137 IGNORED_ATTRIBUTES = ["__deepcopy__" ]
132138 if name in IGNORED_ATTRIBUTES :
133139 return None
@@ -139,11 +145,18 @@ def __getattr__(self, name: str):
139145 }
140146
141147 if name in DELEGATED_ATTRIBUTES :
142- return getattr (DELEGATED_ATTRIBUTES [name ], name )
143- else :
144- raise ValueError (
145- f"MultiPhysicsMedium has no attribute called { name } . Did you mean to access the attribute of one of the optical, heat or charge media?"
146- )
148+ sub = DELEGATED_ATTRIBUTES [name ]
149+ if sub is None :
150+ raise AttributeError (
151+ f"Requested attribute { name !r} , but the optical medium is 'None' "
152+ " on this 'MultiPhysicsMedium' instance."
153+ )
154+ return getattr (sub , name )
155+
156+ raise AttributeError (
157+ f"MultiPhysicsMedium has no attribute called { name } . "
158+ "Did you mean to access the attribute of one of the optical, heat or charge media?"
159+ )
147160
148161 @property
149162 def heat_spec (self ):
You can’t perform that action at this time.
0 commit comments