Skip to content

Consider adding support for special numbers in almosteq() #799

@skirpichev

Description

@skirpichev

I.e. nan is not considered close to any other value, including nan`. infand-inf`` are only considered close to themselves. See also PEP 485.

If that will be accepted, we also could use math.isclose() to implement almosteq() for the fp backend. Probably this should be slightly faster.

Right now we have:

>>> from mpmath import inf, mp
>>> mp.almosteq(inf, inf)
False

c.f.

>>> from math import inf, isclose
>>> isclose(inf, inf)
True

Are there good reasons why almosteq() behave differently from the math.isclose()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementnew feature requests (or implementation)

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions