dantro.mixins.numeric module¶
This module implements mixin classes which provide numeric interfaces for containers
-
class
dantro.mixins.numeric.UnaryOperationsMixin[source]¶ Bases:
objectThis Mixin class implements the methods needed for unary operations.
It leaves out those that expect that return values are of a certain type, e.g. __complex__, __int__, …
-
class
dantro.mixins.numeric.NumbersMixin[source]¶ Bases:
dantro.mixins.numeric.UnaryOperationsMixinThis mixin implements the methods needed for calculating with numbers.
-
__floordiv__(other)[source]¶ Floor divide two objects
- Returns
A new object containing the floor divided data
-
__mod__(other)[source]¶ Calculate the modulo of two objects
- Returns
A new object containing the summed data
-
__divmod__(other)[source]¶ Calculate the floor division and modulo of two objects
- Returns
A new object containing the floor divided data and its modulo
-
__pow__(other)[source]¶ Calculate the self data to the power of other data
- Returns
A new object containing the result
-
__ipow__(other)[source]¶ Calculate the self data to the power of other data
- Returns
Self with modified data
-
__abs__()¶ Absolute value
- Returns
A new object with the absolute value of the elements
-
__ceil__()¶ Smallest integer
- Returns
A new object containing the smallest integer
-
__floor__()¶ Largest integer
- Returns
A new object containing the largest element
-
__invert__()¶ Inverse value
- Returns
A new object with the inverted values of the elements
-
__neg__()¶ Make negative
- Returns
A new object with negative elements
-
__pos__()¶ Make positive
- Returns
A new object with negative elements
-
__round__()¶ Rounds number to nearest integer
- Returns
A new object as rounded number to nearest integer
-
__trunc__()¶ Truncated to the nearest integer toward 0
- Returns
A new object containing the truncated element
-
-
class
dantro.mixins.numeric.ComparisonMixin[source]¶ Bases:
objectThis Mixin implements functions to compare objects
-
dantro.mixins.numeric.get_data(obj)[source]¶ Get the data of obj depending on whether it is part of dantro or not.
- Parameters
obj – The object to check
- Returns
- Either the .data attribute of a dantro-based object or otherwise the
object itself.