jannikmi / multivar_horner

python package implementing a multivariate Horner scheme for efficiently evaluating multivariate polynomials
https://multivar-horner.readthedocs.io/en/latest/
MIT License
27 stars 3 forks source link

Error in running code #22

Closed ChenDannyLi closed 3 years ago

ChenDannyLi commented 3 years ago

I tried to run one example in the documentation page, and it gave me a type error in one of the helper functions: TypeError("coefficients must be given as numpy.ndarray")

Code below:

import numpy as np

from multivar_horner.multivar_horner import HornerMultivarPolynomial

horner_polynomial = HornerMultivarPolynomial(coefficients, exponents)
coefficients = [5.0, 1.0, 2.0, 3.0]
exponents = [[0, 0, 0], [3, 1, 0], [2, 0, 1], [1, 1, 1]]
horner_polynomial = HornerMultivarPolynomial(
    coefficients, exponents, rectify_input=True
)
horner_polynomial = HornerMultivarPolynomial(coefficients, exponents, keep_tree=True)
jannikmi commented 3 years ago

Thanks, for reporting this. Yes, this is a little misleading. Either you have to additionally also pass rectify_input=True or have to pass numpy arrays of the correct data dtype as parameters. Hope this helps.