polynomial TODOs and enhancements

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

polynomial TODOs and enhancements

Jeffrey Yancey
Hi everyone,

I spent some time going through the polynomial directory and found several locations where there were comments left suggestion potential improvements down the road, TODOs, and a line of commented out code. I wanted to share these here to gather a consensus on which, if any, of these tasks should be done. If some of these should not be done, do we want to remove the comments implying changes should be made, or kick the can down the road?

In `numpy/polynomial/_polybase.py, there is the following class method:

    @staticmethod
    def _repr_latex_scalar(x):
        # TODO: we're stuck with disabling math formatting until we handle
        # exponents in this function
        return r'\text{{{}}}'.format(x)

Further down, in `_repr_latex_` there is this comprehension, where the leading comment is no longer true, and the old conditional has been commented out:

        # filter out uninteresting coefficients
        filtered_coeffs = [
            (i, c)
            for i, c in enumerate(self.coef)
            # if not (c == 0)  # handle NaN
        ]

If this behavior is correct, shouldn’t we remove the leading comment and the commented out line, or at least leave an explanation as to why it is commented out and we wish it to remain.

Further down there is also a comment in the `__div__` function implying there may have been the intention of future modification:

    def __div__(self, other):
        # set to __floordiv__,  /, for now.
        return self.__floordiv__(other)

There is also a comment, “made more efficient by using powers of two in the usual way” in the various `pow` functions specified below:

chebyshev.py, line 862


hermite_e.py, line 679


hermite.py, line 630


laguerre.py, line 627


legendre.py, line 661


polynomial.py, line 471


I am happy to make any or all of the enhancements, modify the documentation, or review PRs. I appreciate advice or direction on any of these issues.


Jeffrey Yancey



_______________________________________________
NumPy-Discussion mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/numpy-discussion