original_docstring: Generates the code in python that creates the forecasts
  
          
docstring: Generates the code in python that creates the forecasts
docstring_tokens: Generates the code in python that creates the forecasts
code: def python(self, out=sys.stdout):
          """Generates the code in python that creates the forecasts
  
          """
          attributes = ["l", "b", "s", "phi", "value", "slope"]
          components = {}
          model_components = {}
          model_names = []
          out.write(utf8(USAGE_DOC % (self.resource_id,
                                      self.fields[self.objective_id]["name"])))
          output = ["COMPONENTS = \\"]
          for field_id, models in list(self.ets_models.items()):
              for model in models:
                  final_state = model.get("final_state", {})
                  attrs = {}
                  for attribute in attributes:
                      if attribute in model:
                          attrs.update({attribute: model[attribute]})
                      elif attribute in final_state:
                          attrs.update( \
                              {attribute: final_state[attribute]})
                  model_names.append(model["name"])
                  model_components[model["name"]] = attrs
              field_name = self.fields[field_id]["name"]
              if field_name not in components:
                  components[field_name] = model_components
          partial_output = io.StringIO()
          pprint.pprint(components, stream=partial_output)
          for line in partial_output.getvalue().split("\n"):
              output.append("%s%s" % (INDENT, line))
  
          out.write(utf8("\n".join(output)))
  
          model_names = list(set(model_names))
          if any(name in model_names for name in ["naive", "mean"]):
              out.write(utf8(TRIVIAL_MODEL))
          if any("," in name and name.split(",")[2] in ["A", "M"] for \
                 name in model_names):
              out.write(utf8(SEASONAL_CODE))
          trends = [name.split(",")[1] for name in model_names if "," in name]
          trends.extend([name for name in model_names if "," not in name])
          trends = set(trends)
          models_function = []
          for trend in trends:
              models_function.append("\"%s\": _%s_forecast" % (trend, trend))
              out.write(utf8(SUBMODELS_CODE[trend]))
          out.write(utf8("\n\nMODELS = \\\n"))
          out.write(utf8("%s%s%s" % \
              ("    {", ",\n     ".join(models_function), "}")))
  
          out.write(utf8(FORECAST_FUNCTION))
code_tokens: def python ( self , out = sys . stdout ) : attributes = [ "l" , "b" , "s" , "phi" , "value" , "slope" ] components = { } model_components = { } model_names = [ ] out . write ( utf8 ( USAGE_DOC % ( self . resource_id , self . fields [ self . objective_id ] [ "name" ] ) ) ) output = [ "COMPONENTS = \\" ] for field_id , models in list ( self . ets_models . items ( ) ) : for model in models : final_state = model . get ( "final_state" , { } ) attrs = { } for attribute in attributes : if attribute in model : attrs . update ( { attribute : model [ attribute ] } ) elif attribute in final_state : attrs . update ( { attribute : final_state [ attribute ] } ) model_names . append ( model [ "name" ] ) model_components [ model [ "name" ] ] = attrs field_name = self . fields [ field_id ] [ "name" ] if field_name not in components : components [ field_name ] = model_components partial_output = io . StringIO ( ) pprint . pprint ( components , stream = partial_output ) for line in partial_output . getvalue ( ) . split ( "\n" ) : output . append ( "%s%s" % ( INDENT , line ) ) out . write ( utf8 ( "\n" . join ( output ) ) ) model_names = list ( set ( model_names ) ) if any ( name in model_names for name in [ "naive" , "mean" ] ) : out . write ( utf8 ( TRIVIAL_MODEL ) ) if any ( "," in name and name . split ( "," ) [ 2 ] in [ "A" , "M" ] for name in model_names ) : out . write ( utf8 ( SEASONAL_CODE ) ) trends = [ name . split ( "," ) [ 1 ] for name in model_names if "," in name ] trends . extend ( [ name for name in model_names if "," not in name ] ) trends = set ( trends ) models_function = [ ] for trend in trends : models_function . append ( "\"%s\": _%s_forecast" % ( trend , trend ) ) out . write ( utf8 ( SUBMODELS_CODE [ trend ] ) ) out . write ( utf8 ( "\n\nMODELS = \\\n" ) ) out . write ( utf8 ( "%s%s%s" % ( "    {" , ",\n     " . join ( models_function ) , "}" ) ) ) out . write ( utf8 ( FORECAST_FUNCTION ) )
short_docstring: Generates the code in python that creates the forecasts
short_docstring_tokens: Generates the code in python that creates the forecasts
comment: """Generates the code in python that creates the forecasts
  
          """