Imports

        
import numpy as np
import numpy_financial as npf
import perfplot
import pyxirr
        
    

Case 1

Input: numpy array
Output: numpy array

        
perfplot.show(
    setup=lambda n: np.random.rand(n) / 12,
    kernels=[
        lambda a: pyxirr.fv(a, 120, -100, -100),
        lambda a: npf.fv(a, 120, -100, -100),
    ],
    labels=["pyxirr", "npf"],
    n_range=[2**k for k in range(1, 20)],
    xlabel="len(a)",
    equality_check=np.allclose,
)
        
    

Case 2

Input: list
Output: list

        
perfplot.show(
    setup=lambda n: (np.random.rand(n) / 12).tolist(),
    kernels=[
        lambda a: pyxirr.fv(a, 120, -100, -100),
        lambda a: npf.fv(a, 120, -100, -100).tolist(),
    ],
    labels=["pyxirr", "npf"],
    n_range=[2**k for k in range(1, 20)],
    xlabel="len(a)",
    equality_check=np.allclose,
)
        
    

Case 3

Input: list
Output: list (pyxirr), numpy array (npf)

        
perfplot.show(
    setup=lambda n: (np.random.rand(n) / 12).tolist(),
    kernels=[
        lambda a: pyxirr.fv(a, 120, -100, -100),
        lambda a: npf.fv(a, 120, -100, -100),
    ],
    labels=["pyxirr", "npf"],
    n_range=[2**k for k in range(1, 20)],
    xlabel="len(a)",
    equality_check=np.allclose,
)