Hi all,

just another small API announcement, that I merged:

https://github.com/numpy/numpy/pull/16154

which adds `symbol="x"` to the polynomial classes.  Ross' more detailed
explanation is copied below.

Cheers,

Sebastian



New attribute ``symbol`` added to polynomial classes
----------------------------------------------------

The polynomial classes in the ``numpy.polynomial`` package have a new
``symbol`` attribute which is used to represent the indeterminate
of the polynomial.
This can be used to change the value of the variable when printing::

    >>> P_y = np.polynomial.Polynomial([1, 0, -1], symbol="y")
    >>> print(P_y)
    1.0 + 0.0·y¹ - 1.0·y²

Note that the polynomial classes only support 1D polynomials, so
operations
that involve polynomials with different symbols are disallowed when the
result would be multivariate::

    >>> P = np.polynomial.Polynomial([1, -1])  # default symbol is "x"
    >>> P_z = np.polynomial.Polynomial([1, 1], symbol="z")
    >>> P * P_z
    Traceback (most recent call last)
       ...
    ValueError: Polynomial symbols differ

The symbol can be any valid Python identifier. The default is
``symbol=x``, consistent with existing behavior.

Attachment: signature.asc
Description: This is a digitally signed message part

_______________________________________________
NumPy-Discussion mailing list -- numpy-discussion@python.org
To unsubscribe send an email to numpy-discussion-le...@python.org
https://mail.python.org/mailman3/lists/numpy-discussion.python.org/
Member address: arch...@mail-archive.com

Reply via email to