'Construct a piecewise polynomial in Bernstein basis
from a power basis polynomial.
Parameters
pp : PPoly
A piecewise polynomial in the power basis
extrapolate : bool or \'periodic\', optional
If bool, determines whether to extrapolate to out-of-bounds points
based on first and last intervals, or to return NaNs.
If \'periodic\', periodic extrapolation is used. Default is True.'

@classmethod
def from_power_basis(cls, pp, extrapolate=None):

    dx = np.diff(pp.x)
    k = (pp.c.shape[0] - 1)
    rest = ((None,) * (pp.c.ndim - 2))
    c = np.zeros_like(pp.c)
    for a in range((k + 1)):
        factor = ((pp.c[a] / comb(k, (k - a))) * (dx[((slice(None),) + rest)] ** (k - a)))
        for j in range((k - a), (k + 1)):
            c[j] += (factor * comb(j, (k - a)))
    if (extrapolate is None):
        extrapolate = pp.extrapolate
    return cls.construct_fast(c, pp.x, extrapolate, pp.axis)
