docstr: Given a list of dividends whose ex_dates are all the next trading day,
  calculate and store the cash and/or stock payments to be paid on each
  dividend's pay date.
  
  Parameters
  ----------
  dividends: iterable of (asset, amount, pay_date) namedtuples
  
  stock_dividends: iterable of (asset, payment_asset, ratio, pay_date)
      namedtuples.
docstr_tok: ["Given","a","list","of","dividends","whose","ex_dates","are","all","the","next","trading","day",",","calculate","and","store","the","cash","and\/or","stock","payments","to","be","paid","on","each","dividend","'s","pay","date",".","Parameters","--","--","--","--","--","dividends",":","iterable","of","(","asset",",","amount",",","pay_date",")","namedtuples","stock_dividends",":","iterable","of","(","asset",",","payment_asset",",","ratio",",","pay_date",")","namedtuples","."]
code: def earn_dividends(self, dividends, stock_dividends):
      """
      Given a list of dividends whose ex_dates are all the next trading day,
      calculate and store the cash and/or stock payments to be paid on each
      dividend's pay date.
  
      Parameters
      ----------
      dividends: iterable of (asset, amount, pay_date) namedtuples
  
      stock_dividends: iterable of (asset, payment_asset, ratio, pay_date)
          namedtuples.
      """
      for dividend in dividends:
          # Store the earned dividends so that they can be paid on the
          # dividends' pay_dates.
          div_owed = self.positions[dividend.asset].earn_dividend(
              dividend
          )
          try:
              self._unpaid_dividends[dividend.pay_date].append(div_owed)
          except KeyError:
              self._unpaid_dividends[dividend.pay_date] = [div_owed]
  
      for stock_dividend in stock_dividends:
          div_owed = self.positions[
              stock_dividend.asset
          ].earn_stock_dividend(stock_dividend)
          try:
              self._unpaid_stock_dividends[
                  stock_dividend.pay_date
              ].append(div_owed)
          except KeyError:
              self._unpaid_stock_dividends[stock_dividend.pay_date] = [
                  div_owed
              ]
  
imports: from __future__ import division
  import logbook
  import numpy
  from collections import namedtuple
  from math import isnan
  from six import iteritems, itervalues
  from catalyst.finance.performance.position import Position
  from catalyst.finance.transaction import Transaction
  from catalyst.utils.input_validation import expect_types
  import catalyst.protocol
  from catalyst.assets import Future, Asset
  from .position import positiondict
  from catalyst.constants import LOG_LEVEL
label_desc: Use image node_id 6 for calling the PositionTracker obj's underlying member method code with example usage: obj.earn_dividends(dividends, stock_dividends) without return types