votes up 0

Polynomial must be 1d only.

github stars 17141
Exception Class:

Raise code

            if variable is not None:
                self._variable = variable
        if r:
            c_or_r = poly(c_or_r)
        c_or_r = atleast_1d(c_or_r)
        if c_or_r.ndim > 1:
            raise ValueError("Polynomial must be 1d only.")
        c_or_r = trim_zeros(c_or_r, trim='f')
        if len(c_or_r) == 0:
            c_or_r = NX.array([0], dtype=c_or_r.dtype)
        self._coeffs = c_or_r
        if variable is None:
            variable = 'x'
        self._variable = variable

Ways to fix

votes up 2 votes down

numpy.poly1d expects a 1D array. An array with 2D or 3D was given.

How to reproduce the error:

import numpy as np
poly = np.poly1d([[1, 2]], True)

How to Fix:

import numpy as np

poly = np.poly1d([1, 2], True)
Jun 11, 2021 kellemnegasi answer
kellemnegasi 2.7k

Add a possible fix

Please authorize to post fix