chore: black

This commit is contained in:
psychedelicious 2023-09-13 15:49:19 +10:00
parent 93c55ebcf2
commit ec0f6e7248

View File

@ -64,13 +64,21 @@ class RandomIntInvocation(BaseInvocation):
return IntegerOutput(value=np.random.randint(self.low, self.high)) return IntegerOutput(value=np.random.randint(self.low, self.high))
@invocation("float_to_int", title="Float To Integer", tags=["math", "round", "integer", "float", "convert"], category="math", version="1.0.0") @invocation(
"float_to_int",
title="Float To Integer",
tags=["math", "round", "integer", "float", "convert"],
category="math",
version="1.0.0",
)
class FloatToIntegerInvocation(BaseInvocation): class FloatToIntegerInvocation(BaseInvocation):
"""Rounds a float number to (a multiple of) an integer.""" """Rounds a float number to (a multiple of) an integer."""
value: float = InputField(default=0, description="The value to round") value: float = InputField(default=0, description="The value to round")
multiple: int = InputField(default=1, ge=1, title="Multiple of", description="The multiple to round to") multiple: int = InputField(default=1, ge=1, title="Multiple of", description="The multiple to round to")
method: Literal["Nearest", "Floor", "Ceiling", "Truncate"] = InputField(default="Nearest", description="The method to use for rounding") method: Literal["Nearest", "Floor", "Ceiling", "Truncate"] = InputField(
default="Nearest", description="The method to use for rounding"
)
def invoke(self, context: InvocationContext) -> IntegerOutput: def invoke(self, context: InvocationContext) -> IntegerOutput:
if self.method == "Nearest": if self.method == "Nearest":
@ -103,7 +111,7 @@ INTEGER_OPERATIONS = Literal[
"Modulus A%B", "Modulus A%B",
"Absolute Value of A", "Absolute Value of A",
"Minimum(A,B)", "Minimum(A,B)",
"Maximum(A,B)" "Maximum(A,B)",
] ]
@ -121,10 +129,10 @@ INTEGER_OPERATIONS = Literal[
"power", "power",
"absolute value", "absolute value",
"min", "min",
"max" "max",
], ],
category="math", category="math",
version="1.0.0" version="1.0.0",
) )
class IntegerMathInvocation(BaseInvocation): class IntegerMathInvocation(BaseInvocation):
"""Performs integer math.""" """Performs integer math."""
@ -173,28 +181,16 @@ FLOAT_OPERATIONS = Literal[
"Exponentiate A^B", "Exponentiate A^B",
"Absolute Value of A", "Absolute Value of A",
"Minimum(A,B)", "Minimum(A,B)",
"Maximum(A,B)" "Maximum(A,B)",
] ]
@invocation( @invocation(
"float_math", "float_math",
title="Float Math", title="Float Math",
tags=[ tags=["math", "float", "add", "subtract", "multiply", "divide", "power", "root", "absolute value", "min", "max"],
"math",
"float",
"add",
"subtract",
"multiply",
"divide",
"power",
"root",
"absolute value",
"min",
"max"
],
category="math", category="math",
version="1.0.0" version="1.0.0",
) )
class FloatMathInvocation(BaseInvocation): class FloatMathInvocation(BaseInvocation):
"""Performs floating point math.""" """Performs floating point math."""