Merge pull request #30 from set-soft/data_list_list
[Added] DataListListCreate node
This commit is contained in:
@@ -45,6 +45,36 @@ class DataListCreate(ComfyNodeABC):
|
||||
return (values[:-1],)
|
||||
|
||||
|
||||
class DataListListCreate(ComfyNodeABC):
|
||||
"""
|
||||
Creates a new Data List from items.
|
||||
|
||||
This node creates and returns a Data List. The list of items is dynamically
|
||||
extended based on the number of inputs provided.
|
||||
|
||||
Each input can be a list, so you'll get a list of lists.
|
||||
"""
|
||||
@classmethod
|
||||
def INPUT_TYPES(cls):
|
||||
return {
|
||||
"optional": ContainsDynamicDict({
|
||||
"item_0": (IO.ANY, {"_dynamic": "number", "widgetType": "STRING"}),
|
||||
})
|
||||
}
|
||||
|
||||
RETURN_TYPES = (IO.ANY,)
|
||||
RETURN_NAMES = ("list",)
|
||||
CATEGORY = "Basic/Data List"
|
||||
DESCRIPTION = cleandoc(__doc__ or "")
|
||||
FUNCTION = "create_list"
|
||||
OUTPUT_IS_LIST = (True,)
|
||||
INPUT_IS_LIST = True
|
||||
|
||||
def create_list(self, **kwargs: list[Any]) -> tuple[list]:
|
||||
values = list(kwargs.values())
|
||||
return (values[:-1],)
|
||||
|
||||
|
||||
class DataListCreateFromBoolean(ComfyNodeABC):
|
||||
"""
|
||||
Creates a new Data List from BOOLEAN items.
|
||||
@@ -1087,6 +1117,7 @@ class DataListToSet(ComfyNodeABC):
|
||||
|
||||
NODE_CLASS_MAPPINGS = {
|
||||
"Basic data handling: DataListCreate": DataListCreate,
|
||||
"Basic data handling: DataListListCreate": DataListListCreate,
|
||||
"Basic data handling: DataListCreateFromBoolean": DataListCreateFromBoolean,
|
||||
"Basic data handling: DataListCreateFromFloat": DataListCreateFromFloat,
|
||||
"Basic data handling: DataListCreateFromInt": DataListCreateFromInt,
|
||||
@@ -1124,6 +1155,7 @@ NODE_CLASS_MAPPINGS = {
|
||||
|
||||
NODE_DISPLAY_NAME_MAPPINGS = {
|
||||
"Basic data handling: DataListCreate": "create Data List",
|
||||
"Basic data handling: DataListListCreate": "create Data List of Lists",
|
||||
"Basic data handling: DataListCreateFromBoolean": "create Data List from BOOLEANs",
|
||||
"Basic data handling: DataListCreateFromFloat": "create Data List from FLOATs",
|
||||
"Basic data handling: DataListCreateFromInt": "create Data List from INTs",
|
||||
|
||||
@@ -20,6 +20,7 @@ from src.basic_data_handling.data_list_nodes import (
|
||||
DataListInsert,
|
||||
DataListLast,
|
||||
DataListLength,
|
||||
DataListListCreate,
|
||||
DataListMax,
|
||||
DataListMin,
|
||||
DataListPop,
|
||||
@@ -239,6 +240,20 @@ def test_create_from_string():
|
||||
assert node.create_list(_dynamic_number=0) == ([],)
|
||||
|
||||
|
||||
def test_list_create():
|
||||
node = DataListListCreate()
|
||||
# Testing with string values
|
||||
assert (node.create_list(item_0=["hello", "world"], item_1=["bye", "bye!"], _dynamic_number=2) ==
|
||||
([["hello", "world"], ["bye", "bye!"]],))
|
||||
|
||||
# Testing with mixed values
|
||||
assert (node.create_list(item_0=[123, 456], item_1=[True, False], _dynamic_number=2) ==
|
||||
([[123, 456], [True, False]],))
|
||||
|
||||
# Testing with empty list
|
||||
assert node.create_list(_dynamic_number=0) == ([],)
|
||||
|
||||
|
||||
def test_pop_random():
|
||||
node = DataListPopRandom()
|
||||
result_list, item = node.pop_random_element(list=[1])
|
||||
|
||||
Reference in New Issue
Block a user