From 0f0366f1f31d22b3b48b4e9f94c62f20f3b29177 Mon Sep 17 00:00:00 2001 From: skunkworxdark Date: Wed, 13 Sep 2023 09:26:41 +0100 Subject: [PATCH] Update collections.py (#4513) * Update collections.py RangeOfSizeInvocation was not taking step into account when generating the end point of the range * - updated the node description to refelect this mod - added a gt=0 constraint to ensure only a positive size of the range - moved the + 1 to be on the size. To ensure the range is the requested size in cases where the step is negative - formatted with Black * Removed +1 from the range calculation --------- Co-authored-by: psychedelicious <4822129+psychedelicious@users.noreply.github.com> --- invokeai/app/invocations/collections.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/invokeai/app/invocations/collections.py b/invokeai/app/invocations/collections.py index 2814a9c3ca..702eb99831 100644 --- a/invokeai/app/invocations/collections.py +++ b/invokeai/app/invocations/collections.py @@ -38,14 +38,16 @@ class RangeInvocation(BaseInvocation): version="1.0.0", ) class RangeOfSizeInvocation(BaseInvocation): - """Creates a range from start to start + size with step""" + """Creates a range from start to start + (size * step) incremented by step""" start: int = InputField(default=0, description="The start of the range") - size: int = InputField(default=1, description="The number of values") + size: int = InputField(default=1, gt=0, description="The number of values") step: int = InputField(default=1, description="The step of the range") def invoke(self, context: InvocationContext) -> IntegerCollectionOutput: - return IntegerCollectionOutput(collection=list(range(self.start, self.start + self.size, self.step))) + return IntegerCollectionOutput( + collection=list(range(self.start, self.start + (self.step * self.size), self.step)) + ) @invocation(