xarray_units.operator module#
- add(left: TDataArray, right: Any) TDataArray[source]#
Perform
left + rightconsidering units.When called from an accessor, it runs
accessed + right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- eq(left: TDataArray, right: Any) TDataArray[source]#
Perform
left == rightconsidering units.When called from an accessor, it runs
accessed == right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- floordiv(left: TDataArray, right: Any) TDataArray[source]#
Perform
left // rightconsidering units.When called from an accessor, it runs
accessed // right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- ge(left: TDataArray, right: Any) TDataArray[source]#
Perform
left >= rightconsidering units.When called from an accessor, it runs
accessed >= right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- gt(left: TDataArray, right: Any) TDataArray[source]#
Perform
left > rightconsidering units.When called from an accessor, it runs
accessed > right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- le(left: TDataArray, right: Any) TDataArray[source]#
Perform
left <= rightconsidering units.When called from an accessor, it runs
accessed <= right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- lt(left: TDataArray, right: Any) TDataArray[source]#
Perform
left < rightconsidering units.When called from an accessor, it runs
accessed < right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- matmul(left: TDataArray, right: Any) TDataArray[source]#
Perform
left @ rightconsidering units.When called from an accessor, it runs
accessed @ right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- mod(left: TDataArray, right: Any) TDataArray[source]#
Perform
left % rightconsidering units.When called from an accessor, it runs
accessed % right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- mul(left: TDataArray, right: Any) TDataArray[source]#
Perform
left * rightconsidering units.When called from an accessor, it runs
accessed * right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- ne(left: TDataArray, right: Any) TDataArray[source]#
Perform
left != rightconsidering units.When called from an accessor, it runs
accessed != right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- pow(left: TDataArray, right: Any) TDataArray[source]#
Perform
left ** rightconsidering units.When called from an accessor, it runs
accessed ** right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- sub(left: TDataArray, right: Any) TDataArray[source]#
Perform
left - rightconsidering units.When called from an accessor, it runs
accessed - right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- take(left: TDataArray, operator: Literal['mul', 'pow', 'matmul', 'truediv'] | Literal['add', 'sub', 'floordiv', 'mod', 'lt', 'le', 'eq', 'ne', 'ge', 'gt'], right: Any, /) TDataArray[source]#
Perform an operation between left and right data considering units.
- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
operator (Literal['mul', 'pow', 'matmul', 'truediv'] | ~typing.Literal['add', 'sub', 'floordiv', 'mod', 'lt', 'le', 'eq', 'ne', 'ge', 'gt']) – Name of the operator (e.g.
"add","gt").right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation. Units are the same as
leftin a numerical operation (e.g."add") or nothing in a relational operation (e.g."gt").- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray
- truediv(left: TDataArray, right: Any) TDataArray[source]#
Perform
left / rightconsidering units.When called from an accessor, it runs
accessed / right.- Parameters:
left (TDataArray) – DataArray with units on the left side of the operator.
right (Any) – Any data on the right side of the operator.
- Returns:
DataArray of the result of the operation.
- Raises:
UnitsConversionError – Raised if units cannot be converted.
UnitsNotFoundError – Raised if units are not found.
UnitsNotValidError – Raised if units are not valid.
- Return type:
TDataArray