class_docstr: Graph represention of Pipeline Term dependencies that includes metadata
  about extra rows required to perform computations.
  
  Each node in the graph has an `extra_rows` attribute, indicating how many,
  if any, extra rows we should compute for the node.  Extra rows are most
  often needed when a term is an input to a rolling window computation.  For
  example, if we compute a 30 day moving average of price from day X to day
  Y, we need to load price data for the range from day (X - 29) to day Y.
  
  Parameters
  ----------
  terms : dict
      A dict mapping names to final output terms.
  all_dates : pd.DatetimeIndex
      An index of all known trading days for which ``terms`` will be
      computed.
  start_date : pd.Timestamp
      The first date for which output is requested for ``terms``.
  end_date : pd.Timestamp
      The last date for which output is requested for ``terms``.
  
  Attributes
  ----------
  outputs
  offset
  extra_rows
  
  Methods
  -------
  ordered()
      Return a topologically-sorted iterator over the terms in self.
class_docstr_tok: ["Graph","represention","of","Pipeline","Term","dependencies","that","includes","metadata","about","extra","rows","required","to","perform","computations",".","Each","node","in","the","graph","has","an","`","extra_rows","`","attribute",",","indicating","how","many",",","if","any",",","extra","rows","we","should","compute","for","the","node",".","Extra","rows","are","most","often","needed","when","a","term","is","an","input","to","a","rolling","window","computation",".","For","example",",","if","we","compute","a","30","day","moving","average","of","price","from","day","X","to","day","Y",",","we","need","to","load","price","data","for","the","range","from","day","(","X","-","29",")","to","day","Y.","Parameters","--","--","--","--","--","terms",":","dict","A","dict","mapping","names","to","final","output","terms",".","all_dates",":","pd.DatetimeIndex","An","index","of","all","known","trading","days","for","which","``","terms","``","will","be","computed",".","start_date",":","pd.Timestamp","The","first","date","for","which","output","is","requested","for","``","terms","``",".","end_date",":","pd.Timestamp","The","last","date","for","which","output","is","requested","for","``","terms","``",".","Attributes","--","--","--","--","--","outputs","offset","extra_rows","Methods","--","--","--","-","ordered","(",")","Return","a","topologically-sorted","iterator","over","the","terms","in","self","."]
docstr: For all pairs (term, input) such that `input` is an input to `term`,
  compute a mapping::
  
      (term, input) -> offset(term, input)
  
  where ``offset(term, input)`` is the number of rows that ``term``
  should truncate off the raw array produced for ``input`` before using
  it. We compute this value as follows::
  
      offset(term, input) = (extra_rows_computed(input)
                             - extra_rows_computed(term)
                             - requested_extra_rows(term, input))
  Examples
  --------
  
  Case 1
  ~~~~~~
  
  Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
  needs 3 extra rows of the same.  Factor A also requires 5 extra rows of
  USEquityPricing.high, which no other Factor uses.  We don't require any
  extra rows of Factor A or Factor B
  
  We load 5 extra rows of both `price` and `high` to ensure we can
  service Factor A, and the following offsets get computed::
  
      offset[Factor A, USEquityPricing.close] == (5 - 0) - 5 == 0
      offset[Factor A, USEquityPricing.high]  == (5 - 0) - 5 == 0
      offset[Factor B, USEquityPricing.close] == (5 - 0) - 3 == 2
      offset[Factor B, USEquityPricing.high] raises KeyError.
  
  Case 2
  ~~~~~~
  
  Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
  needs 3 extra rows of Factor A, and Factor B needs 2 extra rows of
  USEquityPricing.close.
  
  We load 8 extra rows of USEquityPricing.close (enough to load 5 extra
  rows of Factor A), and the following offsets get computed::
  
      offset[Factor A, USEquityPricing.close] == (8 - 3) - 5 == 0
      offset[Factor B, USEquityPricing.close] == (8 - 0) - 2 == 6
      offset[Factor B, Factor A]              == (3 - 0) - 3 == 0
  
  Notes
  -----
  `offset(term, input) >= 0` for all valid pairs, since `input` must be
  an input to `term` if the pair appears in the mapping.
  
  This value is useful because we load enough rows of each input to serve
  all possible dependencies.  However, for any given dependency, we only
  want to compute using the actual number of required extra rows for that
  dependency.  We can do so by truncating off the first `offset` rows of
  the loaded data for `input`.
  
  See Also
  --------
  catalyst.pipeline.graph.TermGraph.offset
  catalyst.pipeline.engine.SimplePipelineEngine._inputs_for_term
  catalyst.pipeline.engine.SimplePipelineEngine._mask_and_dates_for_term
docstr_tok: ["For","all","pairs","(","term",",","input",")","such","that","`","input","`","is","an","input","to","`","term","`",",","compute","a","mapping",":",":","(","term",",","input",")","-",">","offset","(","term",",","input",")","where","``","offset","(","term",",","input",")","``","is","the","number","of","rows","that","``","term","``","should","truncate","off","the","raw","array","produced","for","``","input","``","before","using","it",".","We","compute","this","value","as","follows",":",":","offset","(","term",",","input",")","=","(","extra_rows_computed","(","input",")","-","extra_rows_computed","(","term",")","-","requested_extra_rows","(","term",",","input",")",")","Examples","--","--","--","--","Case","1","~~~~~~","Factor","A","needs","5","extra","rows","of","USEquityPricing.close",",","and","Factor","B","needs","3","extra","rows","of","the","same",".","Factor","A","also","requires","5","extra","rows","of","USEquityPricing.high",",","which","no","other","Factor","uses",".","We","do","n't","require","any","extra","rows","of","Factor","A","or","Factor","B","We","load","5","extra","rows","of","both","`","price","`","and","`","high","`","to","ensure","we","can","service","Factor","A",",","and","the","following","offsets","get","computed",":",":","offset","[","Factor","A",",","USEquityPricing.close","]","==","(","5","-","0",")","-","5","==","0","offset","[","Factor","A",",","USEquityPricing.high","]","==","(","5","-","0",")","-","5","==","0","offset","[","Factor","B",",","USEquityPricing.close","]","==","(","5","-","0",")","-","3","==","2","offset","[","Factor","B",",","USEquityPricing.high","]","raises","KeyError",".","Case","2","~~~~~~","Factor","A","needs","5","extra","rows","of","USEquityPricing.close",",","and","Factor","B","needs","3","extra","rows","of","Factor","A",",","and","Factor","B","needs","2","extra","rows","of","USEquityPricing.close",".","We","load","8","extra","rows","of","USEquityPricing.close","(","enough","to","load","5","extra","rows","of","Factor","A",")",",","and","the","following","offsets","get","computed",":",":","offset","[","Factor","A",",","USEquityPricing.close","]","==","(","8","-","3",")","-","5","==","0","offset","[","Factor","B",",","USEquityPricing.close","]","==","(","8","-","0",")","-","2","==","6","offset","[","Factor","B",",","Factor","A","]","==","(","3","-","0",")","-","3","==","0","Notes","--","--","-","`","offset","(","term",",","input",")",">","=","0","`","for","all","valid","pairs",",","since","`","input","`","must","be","an","input","to","`","term","`","if","the","pair","appears","in","the","mapping",".","This","value","is","useful","because","we","load","enough","rows","of","each","input","to","serve","all","possible","dependencies",".","However",",","for","any","given","dependency",",","we","only","want","to","compute","using","the","actual","number","of","required","extra","rows","for","that","dependency",".","We","can","do","so","by","truncating","off","the","first","`","offset","`","rows","of","the","loaded","data","for","`","input","`",".","See","Also","--","--","--","--","catalyst.pipeline.graph.TermGraph.offset","catalyst.pipeline.engine.SimplePipelineEngine._inputs_for_term","catalyst.pipeline.engine.SimplePipelineEngine._mask_and_dates_for_term"]
code: def offset(self):
      """
      For all pairs (term, input) such that `input` is an input to `term`,
      compute a mapping::
  
          (term, input) -> offset(term, input)
  
      where ``offset(term, input)`` is the number of rows that ``term``
      should truncate off the raw array produced for ``input`` before using
      it. We compute this value as follows::
  
          offset(term, input) = (extra_rows_computed(input)
                                 - extra_rows_computed(term)
                                 - requested_extra_rows(term, input))
      Examples
      --------
  
      Case 1
      ~~~~~~
  
      Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
      needs 3 extra rows of the same.  Factor A also requires 5 extra rows of
      USEquityPricing.high, which no other Factor uses.  We don't require any
      extra rows of Factor A or Factor B
  
      We load 5 extra rows of both `price` and `high` to ensure we can
      service Factor A, and the following offsets get computed::
  
          offset[Factor A, USEquityPricing.close] == (5 - 0) - 5 == 0
          offset[Factor A, USEquityPricing.high]  == (5 - 0) - 5 == 0
          offset[Factor B, USEquityPricing.close] == (5 - 0) - 3 == 2
          offset[Factor B, USEquityPricing.high] raises KeyError.
  
      Case 2
      ~~~~~~
  
      Factor A needs 5 extra rows of USEquityPricing.close, and Factor B
      needs 3 extra rows of Factor A, and Factor B needs 2 extra rows of
      USEquityPricing.close.
  
      We load 8 extra rows of USEquityPricing.close (enough to load 5 extra
      rows of Factor A), and the following offsets get computed::
  
          offset[Factor A, USEquityPricing.close] == (8 - 3) - 5 == 0
          offset[Factor B, USEquityPricing.close] == (8 - 0) - 2 == 6
          offset[Factor B, Factor A]              == (3 - 0) - 3 == 0
  
      Notes
      -----
      `offset(term, input) >= 0` for all valid pairs, since `input` must be
      an input to `term` if the pair appears in the mapping.
  
      This value is useful because we load enough rows of each input to serve
      all possible dependencies.  However, for any given dependency, we only
      want to compute using the actual number of required extra rows for that
      dependency.  We can do so by truncating off the first `offset` rows of
      the loaded data for `input`.
  
      See Also
      --------
      catalyst.pipeline.graph.TermGraph.offset
      catalyst.pipeline.engine.SimplePipelineEngine._inputs_for_term
      catalyst.pipeline.engine.SimplePipelineEngine._mask_and_dates_for_term
      """
      extra = self.extra_rows
      return {
          # Another way of thinking about this is:
          # How much bigger is the array for ``dep`` compared to ``term``?
          # How much of that difference did I ask for.
          (term, dep): (extra[dep] - extra[term]) - requested_extra_rows
          for term in self.graph
          for dep, requested_extra_rows in term.dependencies.items()
      }
  
imports: from networkx import DiGraph, topological_sort
  from six import iteritems, itervalues
  from catalyst.utils.memoize import lazyval
  from catalyst.pipeline.visualize import display_graph
  from .term import LoadableTerm
label_desc: Use image node_id 3 for calling the ExecutionPlan obj's underlying member method code with example usage: obj.offset() and returns: unknown