Python numpy.rate() Examples
The following are 30 code examples for showing how to use numpy.rate(). These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example.
You may check out the related API usage on the sidebar.
You may also want to check out all available functions/classes of the module
numpy
, or try the search function
.
Example 1
Project: recruit Author: Frank-qlu File: test_financial.py License: Apache License 2.0 | 6 votes |
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])
Example 2
Project: vnpy_crypto Author: birforce File: test_financial.py License: MIT License | 6 votes |
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])
Example 3
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_financial.py License: MIT License | 6 votes |
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])
Example 4
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_financial.py License: MIT License | 6 votes |
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])
Example 5
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_financial.py License: Apache License 2.0 | 6 votes |
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])
Example 6
Project: pySINDy Author: luckystarufo File: test_financial.py License: MIT License | 6 votes |
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])
Example 7
Project: coffeegrindsize Author: jgagneastro File: test_financial.py License: MIT License | 6 votes |
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])
Example 8
Project: Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda Author: PacktPublishing File: test_financial.py License: MIT License | 6 votes |
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])
Example 9
Project: twitter-stock-recommendation Author: alvarobartt File: test_financial.py License: MIT License | 6 votes |
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])
Example 10
Project: recruit Author: Frank-qlu File: test_financial.py License: Apache License 2.0 | 5 votes |
def test_rate(self): assert_almost_equal( np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 11
Project: recruit Author: Frank-qlu File: test_financial.py License: Apache License 2.0 | 5 votes |
def test_rate_decimal(self): rate = np.rate(Decimal('10'), Decimal('0'), Decimal('-3500'), Decimal('10000')) assert_equal(Decimal('0.1106908537142689284704528100'), rate)
Example 12
Project: recruit Author: Frank-qlu File: test_financial.py License: Apache License 2.0 | 5 votes |
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)
Example 13
Project: lambda-packs Author: ryfeus File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal(np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 14
Project: lambda-packs Author: ryfeus File: test_financial.py License: MIT License | 5 votes |
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)
Example 15
Project: auto-alt-text-lambda-api Author: abhisuri97 File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal(np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 16
Project: auto-alt-text-lambda-api Author: abhisuri97 File: test_financial.py License: MIT License | 5 votes |
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)
Example 17
Project: vnpy_crypto Author: birforce File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal( np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 18
Project: vnpy_crypto Author: birforce File: test_financial.py License: MIT License | 5 votes |
def test_rate_decimal(self): rate = np.rate(Decimal('10'), Decimal('0'), Decimal('-3500'), Decimal('10000')) assert_equal(Decimal('0.1106908537142689284704528100'), rate)
Example 19
Project: vnpy_crypto Author: birforce File: test_financial.py License: MIT License | 5 votes |
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)
Example 20
Project: Computable Author: ktraunmueller File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal(np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 21
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal( np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 22
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_financial.py License: MIT License | 5 votes |
def test_rate_decimal(self): rate = np.rate(Decimal('10'), Decimal('0'), Decimal('-3500'), Decimal('10000')) assert_equal(Decimal('0.1106908537142689284704528100'), rate)
Example 23
Project: Mastering-Elasticsearch-7.0 Author: PacktPublishing File: test_financial.py License: MIT License | 5 votes |
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)
Example 24
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_financial.py License: MIT License | 5 votes |
def test_rate(self): assert_almost_equal( np.rate(10, 0, -3500, 10000), 0.1107, 4)
Example 25
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_financial.py License: MIT License | 5 votes |
def test_rate_decimal(self): rate = np.rate(Decimal('10'), Decimal('0'), Decimal('-3500'), Decimal('10000')) assert_equal(Decimal('0.1106908537142689284704528100'), rate)
Example 26
Project: GraphicDesignPatternByPython Author: Relph1119 File: test_financial.py License: MIT License | 5 votes |
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)
Example 27
Project: cashflows Author: jdvelasq File: tvmm.py License: MIT License | 5 votes |
def pvfv(pval=None, fval=None, nrate=None, nper=None, pyr=1, noprint=True): """Computes the missing argument (set to ``None``) in a model relating the present value, the future value, the number of compoundig periods and the nominal interest rate in a cashflow. Args: pval (float, list): Present value. fval (float, list): Future value. nrate (float, list): Nominal interest rate per year. nper (int, list): Number of compounding periods. pyr (int, list): number of periods per year. noprint (bool): prints enhanced output Returns: The value of the parameter set to ``None`` in the function call. **Details** The ``pvfv`` function computes and returns the missing value (``fval``, ``pval``, ``nper``, ``nrate``) in a model relating these variables. The time intervals between consecutive payments are assumed to be equial. For internal computations, the effective interest rate per period is calculated as ``nrate / pyr``. This function is used to simplify the call to the ``tvmm`` function. See the ``tvmm`` function for details. """ return tvmm(pval=pval, fval=fval, pmt=0, nrate=nrate, nper=nper, due=0, pyr=pyr, noprint=noprint)
Example 28
Project: cashflows Author: jdvelasq File: tvmm.py License: MIT License | 5 votes |
def pmtfv(pmt=None, fval=None, nrate=None, nper=None, pyr=1, noprint=True): """Computes the missing argument (set to ``None``) in a model relating the the future value, the periodic payment, the number of compounding periods and the nominal interest rate in a cashflow. Args: pmt (float, list): Periodic payment. fval (float, list): Future value. nrate (float, list): Nominal rate per year. nper (int, list): Number of compounding periods. pyr (int, list): number of periods per year. noprint (bool): prints enhanced output Returns: The value of the parameter set to None in the function call. **Details** The ``pmtfv`` function computes and returns the missing value (``pmt``, ``fval``, ``nper``, ``nrate``) in a model relating a finite sequence of payments made at the beginning or at the end of each period, a future value, and a nominal interest rate. The time intervals between consecutive payments are assumed to be equial. For internal computations, the effective interest rate per period is calculated as ``nrate / pyr``. This function is used to simplify the call to the ``tvmm`` function. See the ``tvmm`` function for details. """ return tvmm(pval=0, fval=fval, pmt=pmt, nrate=nrate, nper=nper, due=1, pyr=pyr, noprint=noprint)
Example 29
Project: cashflows Author: jdvelasq File: tvmm.py License: MIT License | 5 votes |
def pvpmt(pmt=None, pval=None, nrate=None, nper=None, pyr=1, noprint=True): """Computes the missing argument (set to ``None``) in a model relating the present value, the periodic payment, the number of compounding periods and the nominal interest rate in a cashflow. Args: pmt (float, list): Periodic payment. pval (float, list): Present value. nrate (float, list): Nominal interest rate per year. nper (int, list): Number of compounding periods. pyr (int, list): number of periods per year. noprint (bool): prints enhanced output Returns: The value of the parameter set to None in the function call. **Details** The ``pvpmt`` function computes and returns the missing value (``pmt``, ``pval``, ``nper``, ``nrate``) in a model relating a finite sequence of payments made at the beginning or at the end of each period, a present value, and a nominal interest rate. The time intervals between consecutive payments are assumed to be equial. For internal computations, the effective interest rate per period is calculated as ``nrate / pyr``. This function is used to simplify the call to the ``tvmm`` function. See the ``tvmm`` function for details. """ return tvmm(pval=pval, fval=0, pmt=pmt, nrate=nrate, nper=nper, due=0, pyr=pyr, noprint=noprint)
Example 30
Project: predictive-maintenance-using-machine-learning Author: awslabs File: test_financial.py License: Apache License 2.0 | 5 votes |
def test_rate(self): assert_almost_equal( np.rate(10, 0, -3500, 10000), 0.1107, 4)