Skip to content

Commit

Permalink
Minimal working code only
Browse files Browse the repository at this point in the history
  • Loading branch information
LouisDesdoigts committed Jul 24, 2023
1 parent 518ea52 commit 5cdc920
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions dLux/optics.py
Original file line number Diff line number Diff line change
Expand Up @@ -823,3 +823,34 @@ def propagate_mono(
if return_wf:
return wavefront
return wavefront.psf

def insert_layer(self, layer, index):
"""
Inserts a layer into the layers dictionary at the given index using the
list.insert method. Note this method may require the names of some
parameters to be
Parameters
----------
layer : OpticalLayer
The layer to insert into the layers dictionary.
index : int
The index to insert the layer at.
"""
layers_list = list(zip(self.layers.values(), self.layers.keys()))
layers_list.insert(index, layer)
new_layers = dlu.list_to_dictionary(layers_list, True, OpticalLayer())
return self.set("layers", new_layers)

def remove_layer(self, key):
"""
Removes a layer from the layers dictionary at the given index using the
list.pop method.
Parameters
----------
index : int
The index to remove the layer from.
"""
self.layers.pop(key)
return self

0 comments on commit 5cdc920

Please sign in to comment.