Skip to content

< and isless #311

@jverzani

Description

@jverzani

What should be the definition of < or for that matter isless?

Right now, < is redundantly defined, as isless is defined. But it isn't clear they are correct.

The docstrings have:

  • <: Less-than comparison operator. Falls back to isless. Because of the behavior of floating-point NaN values, this operator implements a partial order. New types with a canonical partial order should implement this function .
  • isless: Test whether x is less than y, according to a fixed total order (defined together with isequal). on-numeric types with a total order should implement this function. If isless(x, y) is defined, then so is isless(y, x) and isequal(x, y), and exactly one of those three yields true.
  • isunordered: Return true if x is a value that is not orderable according to <, such as NaN or missing.

It seems that the definition of isless(x,y) = isless(N(x), N(y)) is incorrect. One could argue this defintion of < isn't. Perhaps we should have isunordered default to isreal(x). (But it seems isreal should check with is_constant and not is_a_Number.

Symbolics defines x < y to be a deferred symbolic comparison. In SymPy their is Eq to define such comparisons and < is defined for numbers, not variables. Being consistent with SymPy would leave < as is and removing isless.

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