Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quantity: add dunder methods #8

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion src/metrology_apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,27 @@ def value(self) -> V: ...
def unit(self) -> U: ...

### Dunder Methods

def __eq__[B](self: "Quantity[V, U]", other: "Quantity[op.CanEq[V, B], U]", /) -> B: ...
def __ne__[B](self: "Quantity[V, U]", other: "Quantity[op.CanEq[V, B], U]", /) -> B: ...
def __lt__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...
def __le__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...
def __gt__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...
def __ge__[B](self: "Quantity[V, U]", other: "Quantity[op.CanOrd[V, B], U]", /) -> B: ...

def __pos__[R](self: "Quantity[op.CanPos[R], U]") -> "Quantity[R, U]": ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When would R in __pos__ ever not be V? I can't think of any examples. 🧐

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

>>> +True
1

def __neg__[R](self: "Quantity[op.CanNeg[R], U]") -> "Quantity[R, U]": ...
def __abs__[R](self: "Quantity[op.CanAbs[R], U]") -> "Quantity[R, U]": ...

def __add__[R](self: "Quantity[V, U]", other: "Quantity[op.CanRAdd[V, R], U", /) -> "Quantity[R, U]": ...
def __radd__[R](self: "Quantity[V, U]", other: "Quantity[op.CanAdd[V, R], U]", /) -> "Quantity[R, U]": ...
def __sub__[R](self: "Quantity[V, U]", other: "Quantity[op.CanRSub[V, R], U]", /) -> "Quantity[R, U]": ...
def __rsub__[R](self: "Quantity[V, U]", other: "Quantity[op.CanSub[V, R], U]", /) -> "Quantity[R, U]": ...

def __mul__[R](self: "Quantity[V, U]", other: "Quantity[op.CanRMul[V, R], U]", /) -> "Quantity[R, U]": ...
def __rmul__[R](self: "Quantity[V, U]", other: "Quantity[op.CanMul[V, R], U]", /) -> "Quantity[R, U]": ...
def __truediv__[R](self: "Quantity[V, U]", other: "Quantity[op.CanRTruediv[V, R], U]", /) -> "Quantity[R, U]": ...
def __rtruediv__[R](self: "Quantity[V, U]", other: "Quantity[op.CanTruediv[V, R], U]", /) -> "Quantity[R, U]": ...

def __pow__[R](self: "Quantity[op.CanPow2[int | float, R], U]", other: int | float, /) -> "Quantity[R, U]": ...
def __rpow__[R](self: "Quantity[op.CanRPow2[int | float, R], U]", other: int | float, /) -> "Quantity[R, U]": ...