當前位置: 首頁>>代碼示例>>Python>>正文


Python numpy.pmt方法代碼示例

本文整理匯總了Python中numpy.pmt方法的典型用法代碼示例。如果您正苦於以下問題:Python numpy.pmt方法的具體用法?Python numpy.pmt怎麽用?Python numpy.pmt使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在numpy的用法示例。


在下文中一共展示了numpy.pmt方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_pmt_decimal

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def test_pmt_decimal(self):
        res = np.pmt(Decimal('0.08') / Decimal('12'), 5 * 12, 15000)
        tgt = Decimal('-304.1459143262052370338701494')
        assert_equal(res, tgt)
        # Test the edge case where rate == 0.0
        res = np.pmt(Decimal('0'), Decimal('60'), Decimal('15000'))
        tgt = -250
        assert_equal(res, tgt)
        # Test the case where we use broadcast and
        # the arguments passed in are arrays.
        res = np.pmt([[Decimal('0'), Decimal('0.8')], [Decimal('0.3'), Decimal('0.8')]],
                     [Decimal('12'), Decimal('3')], [Decimal('2000'), Decimal('20000')])
        tgt = np.array([[Decimal('-166.6666666666666666666666667'), Decimal('-19311.25827814569536423841060')],
                        [Decimal('-626.9081401700757748402586600'), Decimal('-19311.25827814569536423841060')]])

        # Cannot use the `assert_allclose` because it uses isfinite under the covers
        # which does not support the Decimal type
        # See issue: https://github.com/numpy/numpy/issues/9954
        assert_equal(res[0][0], tgt[0][0])
        assert_equal(res[0][1], tgt[0][1])
        assert_equal(res[1][0], tgt[1][0])
        assert_equal(res[1][1], tgt[1][1]) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:24,代碼來源:test_financial.py

示例2: levelize_costs

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def levelize_costs(self):
        if hasattr(self, 'is_levelized'):
            inflation = cfg.getParamAsFloat('inflation_rate')
            try:
                rate = self.cost_of_capital - inflation
            except:
                pdb.set_trace()
            if self.is_levelized == 0:
                self.values_level = - np.pmt(rate, self.book_life, 1, 0, 'end') * self.values
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
            elif self.is_levelized==1:
                self.values_level = self.values.copy()
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
                self.values = np.pv(rate, self.book_life, -1, 0, 'end') * self.values
            elif self.definition == 'relative':
                self.values_level = self.values.copy()
                util.convert_age(self, vintages=self.vintages, years=self.years, attr_from='values_level', attr_to='values_level', reverse=False)
            else:
                raise ValueError("no specification of whether the technology cost is levelized")

        else:
            raise ValueError('Supply Technology id %s needs to indicate whether costs are levelized ' %self.name) 
開發者ID:energyPATHWAYS,項目名稱:EnergyPATHWAYS,代碼行數:24,代碼來源:supply_technologies.py

示例3: test_pmt

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def test_pmt(self):
        res = np.pmt(0.08 / 12, 5 * 12, 15000)
        tgt = -304.145914
        assert_allclose(res, tgt)
        # Test the edge case where rate == 0.0
        res = np.pmt(0.0, 5 * 12, 15000)
        tgt = -250.0
        assert_allclose(res, tgt)
        # Test the case where we use broadcast and
        # the arguments passed in are arrays.
        res = np.pmt([[0.0, 0.8], [0.3, 0.8]], [12, 3], [2000, 20000])
        tgt = np.array([[-166.66667, -19311.258], [-626.90814, -19311.258]])
        assert_allclose(res, tgt) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:15,代碼來源:test_financial.py

示例4: _fv_dispatcher

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def _fv_dispatcher(rate, nper, pmt, pv, when=None):
    return (rate, nper, pmt, pv) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:4,代碼來源:financial.py

示例5: _nper_dispatcher

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def _nper_dispatcher(rate, pmt, pv, fv=None, when=None):
    return (rate, pmt, pv, fv) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:4,代碼來源:financial.py

示例6: _rbl

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def _rbl(rate, per, pmt, pv, when):
    """
    This function is here to simply have a different name for the 'fv'
    function to not interfere with the 'fv' keyword argument within the 'ipmt'
    function.  It is the 'remaining balance on loan' which might be useful as
    it's own function, but is easily calculated with the 'fv' function.
    """
    return fv(rate, (per - 1), pmt, pv, when) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:10,代碼來源:financial.py

示例7: _pv_dispatcher

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def _pv_dispatcher(rate, nper, pmt, fv=None, when=None):
    return (rate, nper, nper, pv, fv) 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:4,代碼來源:financial.py

示例8: _rate_dispatcher

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def _rate_dispatcher(nper, pmt, pv, fv, when=None, guess=None, tol=None,
                     maxiter=None):
    return (nper, pmt, pv, fv)


# Use Newton's iteration until the change is less than 1e-6
#  for all values or a maximum of 100 iterations is reached.
#  Newton's rule is
#  r_{n+1} = r_{n} - g(r_n)/g'(r_n)
#     where
#  g(r) is the formula
#  g'(r) is the derivative with respect to r. 
開發者ID:Frank-qlu,項目名稱:recruit,代碼行數:14,代碼來源:financial.py

示例9: ppmt

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def ppmt(rate, per, nper, pv, fv=0, when='end'):
    """
    Compute the payment against loan principal.

    Parameters
    ----------
    rate : array_like
        Rate of interest (per period)
    per : array_like, int
        Amount paid against the loan changes.  The `per` is the period of
        interest.
    nper : array_like
        Number of compounding periods
    pv : array_like
        Present value
    fv : array_like, optional
        Future value
    when : {{'begin', 1}, {'end', 0}}, {string, int}
        When payments are due ('begin' (1) or 'end' (0))

    See Also
    --------
    pmt, pv, ipmt

    """
    total = pmt(rate, nper, pv, fv, when)
    return total - ipmt(rate, per, nper, pv, fv, when) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:29,代碼來源:financial.py

示例10: test_pmt

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def test_pmt(self):
        res = np.pmt(0.08/12, 5*12, 15000)
        tgt = -304.145914
        assert_allclose(res, tgt)
        # Test the edge case where rate == 0.0
        res = np.pmt(0.0, 5*12, 15000)
        tgt = -250.0
        assert_allclose(res, tgt)
        # Test the case where we use broadcast and
        # the arguments passed in are arrays.
        res = np.pmt([[0.0, 0.8],[0.3, 0.8]],[12, 3],[2000, 20000])
        tgt = np.array([[-166.66667, -19311.258],[-626.90814, -19311.258]])
        assert_allclose(res, tgt) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:15,代碼來源:test_financial.py

示例11: ppmt

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def ppmt(rate, per, nper, pv, fv=0.0, when='end'):
    """
    Compute the payment against loan principal.

    Parameters
    ----------
    rate : array_like
        Rate of interest (per period)
    per : array_like, int
        Amount paid against the loan changes.  The `per` is the period of
        interest.
    nper : array_like
        Number of compounding periods
    pv : array_like
        Present value
    fv : array_like, optional
        Future value
    when : {{'begin', 1}, {'end', 0}}, {string, int}
        When payments are due ('begin' (1) or 'end' (0))

    See Also
    --------
    pmt, pv, ipmt

    """
    total = pmt(rate, nper, pv, fv, when)
    return total - ipmt(rate, per, nper, pv, fv, when) 
開發者ID:ryfeus,項目名稱:lambda-packs,代碼行數:29,代碼來源:financial.py

示例12: test_pmt

# 需要導入模塊: import numpy [as 別名]
# 或者: from numpy import pmt [as 別名]
def test_pmt(self):
        assert_almost_equal(np.pmt(0.08/12, 5*12, 15000),
                            -304.146, 3) 
開發者ID:ktraunmueller,項目名稱:Computable,代碼行數:5,代碼來源:test_financial.py


注:本文中的numpy.pmt方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。