def discretize_to_pixelated_grating(cont_var: goos.Variable, height_fracs: np.ndarray, pixel_size: float, start_height_ind: int, end_height_ind: int, min_features: np.ndarray, max_features: np.ndarray = None, divisions: int = 5, use_edge_locs: bool = False, discr_min_features: np.ndarray = None, discr_max_features: np.ndarray = None, **kwargs): widths_or_edge_locs = goos.Variable(0) height_index = goos.Variable(0) grating = PixelatedGrating(widths_or_edge_locs, height_index, height_fracs, use_edge_locs=use_edge_locs, **kwargs) action = GratingL2D(cont_var, widths_or_edge_locs, height_index, pixel_size, height_fracs, start_height_ind, end_height_ind, min_features, max_features, divisions, use_edge_locs=use_edge_locs, discr_min_features=discr_min_features, discr_max_features=discr_max_features) goos.get_default_plan().add_action(action) height_index.freeze() return widths_or_edge_locs, height_index, grating
def scipy_minimize(objective: goos.Function, *args, **kwargs) -> ScipyOptimizer: optimizer = ScipyOptimizer(objective, *args, **kwargs) goos.get_default_plan().add_action(optimizer) return optimizer
def thaw(self): if self._is_param: raise ValueError("Cannot thaw a parameter.") goos.get_default_plan().add_action(ThawVariable(self))
def freeze(self): goos.get_default_plan().add_action(FreezeVariable(self))
def set(self, value): if isinstance(value, numbers.Number) or isinstance(value, np.ndarray): value = Constant(value) goos.get_default_plan().add_action(SetVariable(self, value))
def eval(self, inputs: List) -> flows.NumericFlow: return flows.NumericFlow(goos.get_default_plan().get_var_value(self))
def log_print(*args, **kwargs) -> LogPrint: action = LogPrint(*args, **kwargs) goos.get_default_plan().add_action(action) return action