-
Notifications
You must be signed in to change notification settings - Fork 2
Description
When attempting to run any of the 'Mode Field' plotting examples from the Coding Examples section of the documentation (e.g. https://pyfibermodes.readthedocs.io/en/latest/gallery/basic/plot_mode_field.html#). It seems that one of the elements of the fiber refractive index which is imported in 'fiber.py' is a numpy array with multiple dimensions. When hash is called with this as an argument there is a TypeError.
I get the following traceback:
TypeError Traceback (most recent call last)
Cell In[60], line 9
1 field = Field(
2 fiber=fiber,
3 mode=HE11,
4 limit=10e-6,
5 n_point=50
6 )
----> 9 figure = field.plot(plot_type=['Ex', 'Ey', 'Ez', 'Er', 'Ephi'])
11 figure.show()
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\field.py:1123, in Field.plot(self, plot_type, show, save_filename)
1121 for ax, field_string in zip(axes, plot_type):
1122 ax.set_aspect('equal')
-> 1123 field = getattr(self, field_string)()
1124 max_abs = abs(max(field.max(), field.min()))
1125 ax.pcolormesh(field, vmin=-max_abs, vmax=max_abs, cmap=blue_black_red)
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\field.py:226, in Field.Ex(self, phi, theta)
223 array[index] = e_field.rho * azimuthal_dependency[index]
224 else:
225 # For non-LP modes, calculate using transverse field and polarization
--> 226 polarization = self.Epol(phi, theta)
227 array = self.Et(phi, theta) * np.cos(polarization)
229 return array
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\field.py:551, in Field.Epol(self, phi, theta)
549 e_polarization = np.arctan2(e_y, e_x)
550 else:
--> 551 e_phi = self.Ephi(phi, theta)
552 e_r = self.Er(phi, theta)
553 e_polarization = np.arctan2(e_phi, e_r) + self.cylindrical_coordinates.phi
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\field.py:459, in Field.Ephi(self, phi, theta)
456 azimuthal_dependency = self.get_azimuthal_dependency(phi=phi, dependency_type='g')
458 for index in self.get_index_iterator(array):
--> 459 e_field, _ = self.fiber.get_radial_field(
460 mode=self.mode,
461 radius=self.cylindrical_coordinates.rho[index]
462 )
463 array[index] = e_field.phi * azimuthal_dependency[index]
465 return array
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\fiber.py:144, in Fiber.hash(self)
143 def hash(self):
--> 144 return hash(tuple(self.layers))
File ~\AppData\Local\anaconda3\Lib\site-packages\PyFiberModes\stepindex.py:54, in Geometry.hash(self)
45 def hash(self):
46 """
47 Computes a unique hash for the object based on its attributes.
48
(...)
52 Hash value for the object.
53 """
---> 54 return hash((self.radius_in, self.radius_out, tuple(self.index_list)))
TypeError: unhashable type: 'numpy.ndarray'