Skip to content

ENH: let approx_fprime accept list #8128

Open

Description

@josef-pkt

it looks like adding type promotion np.promote_types(float, x.dtype)) broke numdiff for lists

(no explicit example because in an example a class called fprime with list params (only one value)

\statsmodels\statsmodels_py37_main\statsmodels\statsmodels\tools\numdiff.py in approx_fprime(x, f, epsilon, args, kwargs, centered)
    143     f0 = f(*((x,)+args), **kwargs)
    144     dim = np.atleast_1d(f0).shape  # it could be a scalar
--> 145     grad = np.zeros((n,) + dim, np.promote_types(float, x.dtype))
    146     ei = np.zeros((n,), float)
    147     if not centered:

AttributeError: 'list' object has no attribute 'dtype'

Activity

  1. bashtage commented on Feb 21, 2022

    @bashtage
    Member

    Doesn't look like a bug to me. approx_fprime expected x to be a ndarray.

  2. changed the title [-]BUG: approx_fprime broken with list[/-] [+]ENH: let approx_fprime accept list[/+] on Feb 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions