[Numpy-discussion] NEP 32: Remove the financial functions from NumPy
warren.weckesser at gmail.com
Tue Sep 3 08:56:23 EDT 2019
Github issue 2880 ("Get financial functions out of main namespace",
https://github.com/numpy/numpy/issues/2880) has been open since 2013. In a
recent community meeting, it was suggested that we create a NEP to propose
the removal of the financial functions from NumPy. I have submitted "NEP
32: Remove the financial functions from NumPy" in a pull request at
https://github.com/numpy/numpy/pull/14399. A copy of the latest version of
the NEP is below.
According to the NEP process document, "Once the PR is in place, the NEP
should be announced on the mailing list for discussion (comments on the PR
itself should be restricted to minor editorial and technical fixes)." This
email is the announcement for NEP 32.
The NEP includes a brief summary of the history of the financial functions,
and has links to several relevant mailing list threads, dating back to when
the functions were added to NumPy in 2008. I recommend reviewing those
threads before commenting here.
NEP 32 — Remove the financial functions from NumPy
:Author: Warren Weckesser <warren.weckesser at gmail.com>
:Type: Standards Track
We propose deprecating and ultimately removing the financial functions _
from NumPy. The functions will be moved to an independent repository,
and provided to the community as a separate package with the name
Motivation and scope
The NumPy financial functions _ are the 10 functions ``fv``, ``ipmt``,
``irr``, ``mirr``, ``nper``, ``npv``, ``pmt``, ``ppmt``, ``pv`` and
The functions provide elementary financial calculations such as future
net present value, etc. These functions were added to NumPy in 2008 _.
In May, 2009, a request by Joe Harrington to add a function called ``xirr``
the financial functions triggered a long thread about these functions _.
One important point that came up in that thread is that a "real" financial
library must be able to handle real dates. The NumPy financial functions do
not work with actual dates or calendars. The preference for a more capable
library independent of NumPy was expressed several times in that thread.
In June, 2009, D. L. Goldsmith expressed concerns about the correctness of
implementations of some of the financial functions _. It was suggested
to move the financial functions out of NumPy to an independent package.
In a GitHub issue in 2013 _, Nathaniel Smith suggested moving the
functions from the top-level namespace to ``numpy.financial``. He also
suggested giving the functions better names. Responses at that time
the suggestion to deprecate them and move them from NumPy to a separate
package. This issue is still open.
Later in 2013 _, it was suggested on the mailing list that these
be removed from NumPy.
The arguments for the removal of these functions from NumPy:
* They are too specialized for NumPy.
* They are not actually useful for "real world" financial calculations,
they do not handle real dates and calendars.
* The definition of "correctness" for some of these functions seems to be a
matter of convention, and the current NumPy developers do not have the
background to judge their correctness.
* There has been little interest among past and present NumPy developers
in maintaining these functions.
The main arguments for keeping the functions in NumPy are:
* Removing these functions will be disruptive for some users. Current users
will have to add the new ``numpy_financial`` package to their
and then modify their code to use the new package.
* The functions provided, while not "industrial strength", are apparently
similar to functions provided by spreadsheets and some calculators.
them available in NumPy makes it easier for some developers to migrate
software to Python and NumPy.
It is clear from comments in the mailing list discussions and in the GitHub
issues that many current NumPy developers believe the benefits of removing
the functions outweigh the costs. For example, from _::
The financial functions should probably be part of a separate package
-- Charles Harris
If there's a better package we can point people to we could just
them and then remove them entirely... I'd be fine with that too...
-- Nathaniel Smith
+1 to deprecate them. If no other package exists, it can be created if
someone feels the need for that.
-- Ralf Gommers
I feel pretty strongly that we should deprecate these. If nobody on
core team is interested in maintaining them, then it is purely a drag on
development for NumPy.
-- Stephan Hoyer
And from the 2013 mailing list discussion, about removing the functions from
I am +1 as well, I don't think they should have been included in the
-- David Cournapeau
But not everyone was in favor of removal::
The fin routines are tiny and don't require much maintenance once
written. If we made an effort (putting up pages with examples of common
financial calculations and collecting those under a topical web page,
then linking to that page from various places and talking it up), I
would think they could attract users looking for a free way to play with
financial scenarios. [...]
So, I would say we keep them. If ours are not the best, we should bring
them up to snuff.
-- Joe Harrington
For an idea of the maintenance burden of the financial functions, one can
look for all the GitHub issues _ and pull requests _ that have the tag
One method for measuring the effect of removing these functions is to find
all the packages on GitHub that use them. Such a search can be performed
with the ``python-api-inspect`` service _. A search for all uses of the
NumPy financial functions finds just eight repositories. (See the comments
in _ for the actual SQL query.)
* Create a new Python package, ``numpy_financial``, to be maintained in the
top-level NumPy github organization. This repository will contain the
definitions and unit tests for the financial functions. The package will
be added to PyPI so it can be installed with ``pip``.
* Deprecate the financial functions in the ``numpy`` namespace, beginning in
NumPy version 1.18. Remove the financial functions from NumPy version
The removal of these functions breaks backward compatibility, as explained
earlier. The effects are mitigated by providing the ``numpy_financial``
The following alternatives were mentioned in _:
* *Maintain the functions as they are (i.e. do nothing).*
A review of the history makes clear that this is not the preference of
NumPy developers. A recurring comment is that the functions simply do not
belong in NumPy. When that sentiment is combined with the history of bug
reports and the ongoing questions about the correctness of the functions,
conclusion is that the cleanest solution is deprecation and removal.
* *Move the functions from the ``numpy`` namespace to ``numpy.financial``.*
This was the initial suggestion in _. Such a change does not address
maintenance issues, and doesn't change the misfit that many developers see
between these functions and NumPy. It causes disruption for the current
users of these functions without addressing what many developers see as
Links to past mailing list discussions, and to relevant GitHub issues and
requests, have already been given.
References and footnotes
..  Financial functions,
..  Numpy-discussion mailing list, "Simple financial functions for
..  Numpy-discussion mailing list, "add xirr to numpy financial
..  Numpy-discussion mailing list, "Definitions of pv, fv, nper, pmt,
..  Get financial functions out of main namespace,
..  Numpy-discussion mailing list, "Deprecation of financial routines",
..  ``component: numpy.lib.financial`` issues,
..  ``component: numpy.lib.financial`` pull request,
..  Quansight-Labs/python-api-inspect,
This document has been placed in the public domain.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion