original_docstring: 
          Builds the dependency of the remaining metrics on the selected
          :param by_metric: a metric on which the dependence will be built
          :param flat: return format
          :return:
          
docstring: Builds the dependency of the remaining metrics on the selected
docstring_tokens: Builds the dependency of the remaining metrics on the selected
code: def relate(self, by_metric: str, flat=True):  # TODO: Can be slow. Need for test with big data.
          """
          Builds the dependency of the remaining metrics on the selected
          :param by_metric: a metric on which the dependence will be built
          :param flat: return format
          :return:
          """
          if by_metric not in self.metrics:
              raise KeyError('No such metric in data')
  
          related_data = defaultdict(StanDict)
  
          for ts in self:
              if by_metric in self[ts]:
                  for metric in self.metrics:
                      if metric != by_metric:
                          related_data[self[ts][by_metric]].setdefault(metric, []).append(self[ts][metric])
  
          for key in related_data:
              for metric in related_data[key]:
                  if related_data[key] is not None:
                      filtered = [val for val in related_data[key][metric] if val is not None]
                      if len(filtered) > 0:
                          related_data[key][metric] = sum(filtered) / len(filtered)
                      else:
                          related_data[key][metric] = None
  
          if flat:
              flt = StanFlatData()
              for key in sorted(related_data):
                  flt[by_metric].append(key)
                  for metric in related_data[key]:
                      flt[metric].append(related_data[key][metric])
              return flt
  
          return related_data
code_tokens: def relate ( self , by_metric : str , flat = True ) : if by_metric not in self . metrics : raise KeyError ( 'No such metric in data' ) related_data = defaultdict ( StanDict ) for ts in self : if by_metric in self [ ts ] : for metric in self . metrics : if metric != by_metric : related_data [ self [ ts ] [ by_metric ] ] . setdefault ( metric , [ ] ) . append ( self [ ts ] [ metric ] ) for key in related_data : for metric in related_data [ key ] : if related_data [ key ] is not None : filtered = [ val for val in related_data [ key ] [ metric ] if val is not None ] if len ( filtered ) > 0 : related_data [ key ] [ metric ] = sum ( filtered ) / len ( filtered ) else : related_data [ key ] [ metric ] = None if flat : flt = StanFlatData ( ) for key in sorted ( related_data ) : flt [ by_metric ] . append ( key ) for metric in related_data [ key ] : flt [ metric ] . append ( related_data [ key ] [ metric ] ) return flt return related_data
short_docstring: Builds the dependency of the remaining metrics on the selected
short_docstring_tokens: Builds the dependency of the remaining metrics on the selected
comment: # TODO: Can be slow. Need for test with big data.$SEP$"""
          Builds the dependency of the remaining metrics on the selected
          :param by_metric: a metric on which the dependence will be built
          :param flat: return format
          :return:
          """