docstr: Constructor of an objective function that takes as input a vector x of the non context variables
  and retunrs a value in which the context variables have been fixed.
docstr_tok: ["Constructor","of","an","objective","function","that","takes","as","input","a","vector","x","of","the","non","context","variables","and","retunrs","a","value","in","which","the","context","variables","have","been","fixed","."]
code: def __init__(self, x0, f, df=None, f_df=None, context_manager=None):
      """
      Constructor of an objective function that takes as input a vector x of the non context variables
      and retunrs a value in which the context variables have been fixed.
      """
      self.x0 = np.atleast_2d(x0)
      self.f = f
      self.df = df
      self.f_df = f_df
      self.context_manager = context_manager
  
      if not context_manager:
          self.x0_nocontext = x0
          self.f_nocontext = self.f
          self.df_nocontext = self.df
          self.f_df_nocontext = self.f_df
  
      else:
          self.x0_nocontext = self.x0[
              :, self.context_manager.noncontext_index
          ]
          self.f_nocontext = self.f_nc
          if self.f_df is None:
              self.df_nocontext = None
              self.f_df_nocontext = None
          else:
              self.df_nocontext = self.df_nc
              self.f_df_nocontext = self.f_df_nc
  
imports: import numpy
  from ..core.errors import InvalidVariableNameError
label_desc: Use image node_id 1 to create a new OptimizationWithContext object from inherited base classes: object with example: obj = OptimizationWithContext(x0, f, df, f_df, context_manager)