Skip to content

Missing identity for logaddexp #4599

@chebee7i

Description

@chebee7i

Should logaddexp and logaddexp2 have identities defined for reduce?

In [1]: x = np.array([-1,-1,-1], dtype=float)

In [2]: np.logaddexp2.reduce(x)
Out[2]: 0.58496250072115619

In [3]: np.logaddexp2.reduce(x[:2])  # matches np.logaddexp2(*x[:2])
Out[3]: 0.0

In [4]: np.logaddexp2.reduce(x[:1])
Out[4]: -1.0

In [5]: np.logaddexp2.reduce(x[:0])
ValueError: zero-size array to reduction operation logaddexp2 which has no identity

I was expecting -inf when reducing an empty array.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions