Skip to content

Should we have a npy totalOrder predicate for floating point/complex numbers? #29698

@charris

Description

@charris

There is a IEEE totalOrder predicate (IEEE 754-2008) that defines the sort order for IEEE floats. Rust implements it as total_cmp, C++20 implements it as std::strong_order. It is what you might expect, positive floats (sign bit == 0) are ordered as integers, negative floats (sign bit == 1) as negative integers. The effect is -0 sorts before +0 and positive nans to the end, negative nans to the beginning. NumPy sorts don't follow that convention, so I wonder if we should define a npy_totalOrder predicate somewhere. Maybe try to have a totalOrder predicate as a scientific python standard. I note that total_cmp looks like a slightly modified < and doesn't seem to offer any speed advantage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    33 - QuestionQuestion about NumPy usage or development

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions