Skip to content

Support the abs() function for getting absolute values #2544

@evansd

Description

@evansd

If you want to find out whether two events are within 14 days of each other without caring which comes first then you ought to be able to write:

abs((event_1.date - event_2.date).days) <= 14

Rather than having to write:

((event_1.date - event_2.date).days <= 14) & ((event_1.date - event_2.date).days >= -14)

In fact, once we close this related issue, you really ought to be able to write:

abs(event_1.date - event_2.date) <= days(14)

Implementing this is a matter of adding a Fuction.Abs operation to the query model and in the query language supporting the __abs__ magic method on numeric series. Adding appropriate spec tests should drive out the rest of the implementation.

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