class_docstr: Class to run pre-defined method execution scenarios for objects.
  
  Parameters
  ----------
  args : dict of dict, default = None
      dict of argument dicts to be used in methods
      names for keys need not equal names of methods these are used in
          but scripted method will look at key with same name as default
      must be passed to constructor, set in a child class
          or dynamically created in get_args
  default_method_sequence : list of str, default = None
      default sequence for methods to be called
      optional, if given, default method sequence to use in `run`
      if not provided, at least one of the sequence arguments must be passed in `run`
          or default_arg_sequence must be provided
  default_arg_sequence : list of str, default = None
      default sequence of keys for keyword argument dicts to be used
      names for keys need not equal names of methods
      if not provided, at least one of the sequence arguments must be passed in `run`
          or default_method_sequence must be provided
  
  Methods
  -------
  run(obj, args=None, default_method_sequence=None)
      Run a call(args) scenario on obj, and retrieve method outputs.
  is_applicable(obj)
      Check whether scenario is applicable to obj.
  get_args(key, obj)
      Dynamically create args for call defined by key and obj.
      Defaults to self.args[key] if not overridden.
docstr: Run a call(args) scenario on obj, and retrieve method outputs.
  
  Runs a sequence of commands
      res_1 = obj.method_1(**args_1)
      res_2 = obj.method_2(**args_2)
      etc, where method_i is method_sequence[i],
          and args_i is self.args[arg_sequence[i]]
  and returns results. Args are passed as deepcopy to avoid side effects.
  
  if method_i is __init__ (a constructor),
  obj is changed to obj.__init__(**args_i) from the next line on
  
  Parameters
  ----------
  obj : class or object with methods in method_sequence
  method_sequence : list of str, default = arg_sequence if passed
      if arg_sequence is also None, then default = self.default_method_sequence
      sequence of method names to be run
  arg_sequence : list of str, default = method_sequence if passed
      if method_sequence is also None, then default = self.default_arg_sequence
      sequence of keys for keyword argument dicts to be used
      names for keys need not equal names of methods
  return_all : bool, default = False
      whether all or only the last result should be returned
      if False, only the last result is returned
      if True, list of deepcopies of intermediate results is returned
  return_args : bool, default = False
      whether arguments should also be returned
      if False, there is no second return argument
      if True, "args_after_call" return argument is returned
  deepcopy_return : bool, default = False
      whether returns are deepcopied before returned
      if True, returns are deepcopies of return
      if False, returns are references/assignments, not deepcopies
          NOTE: if self is returned (e.g., in fit), and deepcopy_return=False
              method calls may continue to have side effects on that return
  
  Returns
  -------
  results : output of the last method call, if return_all = False
      list of deepcopies of all outputs, if return_all = True
  args_after_call : list of args after method call, only if return_args = True
      i-th element is deepcopy of args of i-th method call, after method call
          this is possibly subject to side effects by the method
docstr_tok: ["Run","a","call","(","args",")","scenario","on","obj",",","and","retrieve","method","outputs",".","Runs","a","sequence","of","commands","res_1","=","obj.method_1","(","*","*","args_1",")","res_2","=","obj.method_2","(","*","*","args_2",")","etc",",","where","method_i","is","method_sequence","[","i","]",",","and","args_i","is","self.args","[","arg_sequence","[","i","]","]","and","returns","results",".","Args","are","passed","as","deepcopy","to","avoid","side","effects",".","if","method_i","is","__init__","(","a","constructor",")",",","obj","is","changed","to","obj.__init__","(","*","*","args_i",")","from","the","next","line","on","Parameters","--","--","--","--","--","obj",":","class","or","object","with","methods","in","method_sequence","method_sequence",":","list","of","str",",","default","=","arg_sequence","if","passed","if","arg_sequence","is","also","None",",","then","default","=","self.default_method_sequence","sequence","of","method","names","to","be","run","arg_sequence",":","list","of","str",",","default","=","method_sequence","if","passed","if","method_sequence","is","also","None",",","then","default","=","self.default_arg_sequence","sequence","of","keys","for","keyword","argument","dicts","to","be","used","names","for","keys","need","not","equal","names","of","methods","return_all",":","bool",",","default","=","False","whether","all","or","only","the","last","result","should","be","returned","if","False",",","only","the","last","result","is","returned","if","True",",","list","of","deepcopies","of","intermediate","results","is","returned","return_args",":","bool",",","default","=","False","whether","arguments","should","also","be","returned","if","False",",","there","is","no","second","return","argument","if","True",",","``","args_after_call","''","return","argument","is","returned","deepcopy_return",":","bool",",","default","=","False","whether","returns","are","deepcopied","before","returned","if","True",",","returns","are","deepcopies","of","return","if","False",",","returns","are","references\/assignments",",","not","deepcopies","NOTE",":","if","self","is","returned","(","e.g.",",","in","fit",")",",","and","deepcopy_return=False","method","calls","may","continue","to","have","side","effects","on","that","return","Returns","--","--","--","-","results",":","output","of","the","last","method","call",",","if","return_all","=","False","list","of","deepcopies","of","all","outputs",",","if","return_all","=","True","args_after_call",":","list","of","args","after","method","call",",","only","if","return_args","=","True","i-th","element","is","deepcopy","of","args","of","i-th","method","call",",","after","method","call","this","is","possibly","subject","to","side","effects","by","the","method"]
code: def run(
      self,
      obj,
      method_sequence=None,
      arg_sequence=None,
      return_all=False,
      return_args=False,
      deepcopy_return=False,
  ):
      """Run a call(args) scenario on obj, and retrieve method outputs.
  
      Runs a sequence of commands
          res_1 = obj.method_1(**args_1)
          res_2 = obj.method_2(**args_2)
          etc, where method_i is method_sequence[i],
              and args_i is self.args[arg_sequence[i]]
      and returns results. Args are passed as deepcopy to avoid side effects.
  
      if method_i is __init__ (a constructor),
      obj is changed to obj.__init__(**args_i) from the next line on
  
      Parameters
      ----------
      obj : class or object with methods in method_sequence
      method_sequence : list of str, default = arg_sequence if passed
          if arg_sequence is also None, then default = self.default_method_sequence
          sequence of method names to be run
      arg_sequence : list of str, default = method_sequence if passed
          if method_sequence is also None, then default = self.default_arg_sequence
          sequence of keys for keyword argument dicts to be used
          names for keys need not equal names of methods
      return_all : bool, default = False
          whether all or only the last result should be returned
          if False, only the last result is returned
          if True, list of deepcopies of intermediate results is returned
      return_args : bool, default = False
          whether arguments should also be returned
          if False, there is no second return argument
          if True, "args_after_call" return argument is returned
      deepcopy_return : bool, default = False
          whether returns are deepcopied before returned
          if True, returns are deepcopies of return
          if False, returns are references/assignments, not deepcopies
              NOTE: if self is returned (e.g., in fit), and deepcopy_return=False
                  method calls may continue to have side effects on that return
  
      Returns
      -------
      results : output of the last method call, if return_all = False
          list of deepcopies of all outputs, if return_all = True
      args_after_call : list of args after method call, only if return_args = True
          i-th element is deepcopy of args of i-th method call, after method call
              this is possibly subject to side effects by the method
      """
      # if both None, fill with defaults if exist
      if method_sequence is None and arg_sequence is None:
          method_sequence = getattr(
              self, "default_method_sequence", None
          )
          arg_sequence = getattr(self, "default_arg_sequence", None)
  
      # if both are still None, raise an error
      if method_sequence is None and arg_sequence is None:
          raise ValueError(
              "at least one of method_sequence, arg_sequence must be not None "
              "if no defaults are set in the class"
          )
  
      # if only one is None, fill one with the other
      if method_sequence is None:
          method_sequence = _check_list_of_str(arg_sequence)
      else:
          method_sequence = _check_list_of_str(method_sequence)
      if arg_sequence is None:
          arg_sequence = _check_list_of_str(method_sequence)
      else:
          arg_sequence = _check_list_of_str(arg_sequence)
  
      # check that length of sequences is the same
      num_calls = len(arg_sequence)
      if not num_calls == len(method_sequence):
          raise ValueError(
              "arg_sequence and method_sequence must have same length"
          )
  
      # execute the commands in sequence, report result(s)
      results = []
      args_after_call = []
      for i in range(num_calls):
          methodname = method_sequence[i]
          args = deepcopy(self.get_args(key=arg_sequence[i], obj=obj))
  
          if methodname != "__init__":
              res = getattr(obj, methodname)(**args)
          # if constructor is called, run directly and replace obj
          else:
              if isclass(obj):
                  res = obj(**args)
              else:
                  res = type(obj)(**args)
              obj = res
  
          args_after_call += [args]
  
          if deepcopy_return:
              res = deepcopy(res)
  
          if return_all:
              results += [res]
          else:
              results = res
  
      if return_args:
          return results, args_after_call
      else:
          return results
  
file_path: sktime/sktime/utils/_testing/scenarios.py
imports: from copy import deepcopy
  from inspect import isclass
label_desc: Use image node_id 3 for calling the TestScenario obj's underlying member method code with example usage: obj.run(obj, method_sequence, arg_sequence, return_all, return_args, deepcopy_return) and returns: results,  args_after_call, results