I think the `x` is just noise there, especially if it's ignored (that is, `T[0](x*2)` doesn't do anything reasonable).
Chebyshev.literal(lambda T: 1*T[0] + 2*T[1] + 3*T[2]) Would work, but honestly I don't think that provides much clarity. I think the value here is mainly for "simple" polynomials. On Sun, 1 Jul 2018 at 23:42 Maxwell Aifer <mai...@haverford.edu> wrote: > Say we add a constructor to the polynomial base class that looks something > like this: > > > ------------------------------------------------------------------------------------------- > @classmethod > def literal(cls, f): > def basis_function_getter(self, deg): > coefs = [0]*deg + [1] > return lambda _: cls(coefs) > basis = type('',(object,),{'__getitem__': basis_function_getter})() > return f(basis, None) > > ------------------------------------------------------------------------------------------- > > > Then the repr for, say, a Chebyshev polynomial could look like this: > > >>> Chebyshev.literal(lambda T,x: 1*T[0](x) + 2*T[1](x) + 3*T[2](x)) > > Does this sound like a good idea to anyone? > > Max > > > On Sat, Jun 30, 2018 at 6:47 PM, Charles R Harris < > charlesr.har...@gmail.com> wrote: > >> >> >> On Sat, Jun 30, 2018 at 4:42 PM, Charles R Harris < >> charlesr.har...@gmail.com> wrote: >> >>> >>> >>> On Sat, Jun 30, 2018 at 3:41 PM, Eric Wieser < >>> wieser.eric+nu...@gmail.com> wrote: >>> >>>> Since the one of the arguments for the decreasing order seems to just >>>> be textual representation - do we want to tweak the repr to something like >>>> >>>> Polynomial(lambda x: 2*x**3 + 3*x**2 + x + 0) >>>> >>>> (And add a constructor that calls the lambda with Polynomial(1)) >>>> >>>> Eric >>>> >>> >>> IIRC there was a proposal for that. There is the possibility of adding >>> renderers for latex and html that could be used by Jupyter, and I think the >>> ordering was an option. >>> >> >> See https://github.com/numpy/numpy/issues/8893 for the proposal. BTW, if >> someone would like to work on this, go for it. >> >> Chuck >> >>> >>>> >>> >> >> _______________________________________________ >> NumPy-Discussion mailing list >> NumPy-Discussion@python.org >> https://mail.python.org/mailman/listinfo/numpy-discussion >> >> _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion