Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken tutorial notebooks #34

Open
smartalecH opened this issue Oct 3, 2022 · 4 comments
Open

Broken tutorial notebooks #34

smartalecH opened this issue Oct 3, 2022 · 4 comments
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@smartalecH
Copy link
Collaborator

smartalecH commented Oct 3, 2022

monitors.ipynb:

ValueError                                Traceback (most recent call last)
Input In [2], in <cell line: 5>()
      1 eme.reset(full_reset=False)
      3 monitor = eme.add_monitor(axes="xz")
----> 5 eme.propagate()  # propagate at given wavelength
      7 plt.figure()
      8 monitor.visualize(component="n")

File ~/GitHub/emepy/emepy/eme.py:654, in EME.propagate(self, left_coeffs, right_coeffs)
    652 # Update monitors
    653 if self.state >= 6:
--> 654     self.field_propagate(left_coeffs, right_coeffs)
    656 return self.network

File ~/GitHub/emepy/emepy/eme.py:353, in EME.field_propagate(self, left_coeffs, right_coeffs)
    351 just_z_list = [i[1] for i in z_list]
    352 z_index = [i[0] for i in z_list]
--> 353 fields = self._layer_field_propagate_part2(
    354     layer_index,
    355     layer,
    356     left_coeffs[:],
    357     right_coeffs[:],
    358     cur_len * 1,
    359     just_z_list[:],
    360     m,
    361     S,
    362     checked_l_pins,
    363 )
    365 # Update the monitor
    366 for i, f in zip(z_index, fields):

File ~/GitHub/emepy/emepy/eme.py:1063, in EME._layer_field_propagate_part2(self, i, l, left_coeffs, right_coeffs, cur_len, z_list, m, S, checked_l_pins)
   1061 result_list = []
   1062 input_map = self._build_input_array(left_coeffs, right_coeffs, S, m)
-> 1063 coeffs_ = compute(S, input_map, 0)
   1064 coeff_left = np.zeros(len(l.modes), dtype=complex)
   1065 coeff_right = np.zeros(len(l.modes), dtype=complex)

File ~/GitHub/emepy/emepy/models.py:1047, in ModelTools.compute(model, pin_values, freq)
   1045         cfs[key_index[key]] = value
   1046 matrix = model.s_parameters(np.array([freq]))
-> 1047 output = np.matmul(matrix, cfs)[0]
   1048 return dict(zip(pin_names, output))

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 4 is different from 2)

taper.ipynb

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 eme.propagate(left_coeffs=[1])

File ~/GitHub/emepy/emepy/eme.py:654, in EME.propagate(self, left_coeffs, right_coeffs)
    652 # Update monitors
    653 if self.state >= 6:
--> 654     self.field_propagate(left_coeffs, right_coeffs)
    656 return self.network

File ~/GitHub/emepy/emepy/eme.py:353, in EME.field_propagate(self, left_coeffs, right_coeffs)
    351 just_z_list = [i[1] for i in z_list]
    352 z_index = [i[0] for i in z_list]
--> 353 fields = self._layer_field_propagate_part2(
    354     layer_index,
    355     layer,
    356     left_coeffs[:],
    357     right_coeffs[:],
    358     cur_len * 1,
    359     just_z_list[:],
    360     m,
    361     S,
    362     checked_l_pins,
    363 )
    365 # Update the monitor
    366 for i, f in zip(z_index, fields):

File ~/GitHub/emepy/emepy/eme.py:1063, in EME._layer_field_propagate_part2(self, i, l, left_coeffs, right_coeffs, cur_len, z_list, m, S, checked_l_pins)
   1061 result_list = []
   1062 input_map = self._build_input_array(left_coeffs, right_coeffs, S, m)
-> 1063 coeffs_ = compute(S, input_map, 0)
   1064 coeff_left = np.zeros(len(l.modes), dtype=complex)
   1065 coeff_right = np.zeros(len(l.modes), dtype=complex)

File ~/GitHub/emepy/emepy/models.py:1047, in ModelTools.compute(model, pin_values, freq)
   1045         cfs[key_index[key]] = value
   1046 matrix = model.s_parameters(np.array([freq]))
-> 1047 output = np.matmul(matrix, cfs)[0]
   1048 return dict(zip(pin_names, output))

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 8 is different from 2)

mmi.ipynb

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Input In [1], in <cell line: 164>()
    161 eme.add_layer(Layer(output_channel, num_modes_output, wavelength, output_length))
    163 # Add a monitor
--> 164 monitor = eme.add_monitor(axes="xyz", mesh_z=200)
    166 # Visualize the layout
    167 plt.figure()

File ~/GitHub/emepy/emepy/eme.py:449, in EME.add_monitor(self, axes, sources, mesh_z, z_range, location, components, exempt)
    444 components = ["Ex", "Ey", "Ez", "Hx", "Hy", "Hz", "n"] if components is None else components
    445 if exempt and (self.layers[0].mode_solver.PML and isinstance(self.layers[0].mode_solver, MSEMpy)):
    446     x = (
    447         len(
    448             self.layers[0].mode_solver.x[
--> 449                 self.layers[0].mode_solver.nlayers[1] : -self.layers[0].mode_solver.nlayers[0]
    450             ]
    451         )
    452         + 1
    453     )
    454     y = (
    455         len(
    456             self.layers[0].mode_solver.y[
   (...)
    460         + 1
    461     )
    462 else:

AttributeError: 'MSEMpy' object has no attribute 'nlayers'

bragg_grating.ipynb

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [5], in <cell line: 1>()
----> 1 eme.propagate(left_coeffs=[],right_coeffs=[])

File ~/GitHub/emepy/emepy/eme.py:654, in EME.propagate(self, left_coeffs, right_coeffs)
    652 # Update monitors
    653 if self.state >= 6:
--> 654     self.field_propagate(left_coeffs, right_coeffs)
    656 return self.network

File ~/GitHub/emepy/emepy/eme.py:353, in EME.field_propagate(self, left_coeffs, right_coeffs)
    351 just_z_list = [i[1] for i in z_list]
    352 z_index = [i[0] for i in z_list]
--> 353 fields = self._layer_field_propagate_part2(
    354     layer_index,
    355     layer,
    356     left_coeffs[:],
    357     right_coeffs[:],
    358     cur_len * 1,
    359     just_z_list[:],
    360     m,
    361     S,
    362     checked_l_pins,
    363 )
    365 # Update the monitor
    366 for i, f in zip(z_index, fields):

File ~/GitHub/emepy/emepy/eme.py:1063, in EME._layer_field_propagate_part2(self, i, l, left_coeffs, right_coeffs, cur_len, z_list, m, S, checked_l_pins)
   1061 result_list = []
   1062 input_map = self._build_input_array(left_coeffs, right_coeffs, S, m)
-> 1063 coeffs_ = compute(S, input_map, 0)
   1064 coeff_left = np.zeros(len(l.modes), dtype=complex)
   1065 coeff_right = np.zeros(len(l.modes), dtype=complex)

File ~/GitHub/emepy/emepy/models.py:1047, in ModelTools.compute(model, pin_values, freq)
   1045         cfs[key_index[key]] = value
   1046 matrix = model.s_parameters(np.array([freq]))
-> 1047 output = np.matmul(matrix, cfs)[0]
   1048 return dict(zip(pin_names, output))

ValueError: matmul: Input operand 1 has a mismatch in its core dimension 0, with gufunc signature (n?,k),(k,m?)->(n?,m?) (size 6 is different from 2)

(cc @hammy4815 )

@smartalecH smartalecH added bug Something isn't working documentation Improvements or additions to documentation labels Oct 3, 2022
@hammy4815
Copy link
Collaborator

@smartalecH ,

This is strange - they run fine on my machine. Let me run a fresh pip installation and test.

@hammy4815
Copy link
Collaborator

@smartalecH , mine still works on a fresh pip install. (new condo environment, installed as is on Mac). I'm guessing there is a version incompatibility, possibly from numpy. Which version of numpy are you running? It's unlikely any other dependency.

@smartalecH
Copy link
Collaborator Author

Which version of numpy are you running?

1.23.3

Odd, I'm also on an M1 mac. I'm "building" from a local clone.

@hammy4815
Copy link
Collaborator

hammy4815 commented Oct 4, 2022

@smartalecH ,

I tried again building from a fresh local clone, and numpy 1.23.3. I was not able to reproduce your issue, however. Have you tried a fresh conda environment, only installing this package and its dependencies?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants