From b475a05763bae585588a62cf2ded7e5aa15ff89a Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 15:40:20 +0200 Subject: [PATCH 01/53] add first commits 2 --- nodes/list_basic/modifier.py | 91 ++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 nodes/list_basic/modifier.py diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py new file mode 100644 index 000000000..c4666caeb --- /dev/null +++ b/nodes/list_basic/modifier.py @@ -0,0 +1,91 @@ +# ##### BEGIN GPL LICENSE BLOCK ##### +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +# ##### END GPL LICENSE BLOCK ##### + +from itertools import accumulate + +import bpy +from bpy.props import EnumProperty, IntProperty, BoolProperty + +from sverchok.node_tree import SverchCustomTreeNode +from sverchok.data_structure import updateNode, SvSetSocketAnyType, SvGetSocketAnyType + + +node_item_list = [ + ("Set", lambda i: set(i)), + ("Ordered Set", ), + ("Sequential Set", ), + ("Unique Consecutives", ), + ("Accumulating Sum", lambda a: list(accumulate(a))), + ("Intersection", lambda a, b: set(a) & set(b)), + ("Union", lambda a, b: set(a) | set(b)), + ("Difference", lambda a, b: set(a) - set(b)), + ("Symmetric Diff", lambda a, b: set(a) ^ set(b)) +] + +func_dict = {k: v for k, v in node_item_list} + +class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): + ''' List Modifier''' + bl_idname = 'ListModifierNode' + bl_label = 'List Modifier' + bl_icon = 'OUTLINER_OB_EMPTY' + + mode_items = [(name, name, "", idx) for idx, (name, _) in enumerate(node_item_list) + + func_ = EnumProperty( + name="Modes", + description="Mode Choices", + default="AVR", items=mode_items, + update=updateNode + ) + + listify = BoolProperty( + default=True, + description='Output lists or proper sets', + ) + + + def draw_buttons(self, context, layout): + layout.prop(self, "func_") + + def sv_init(self, context): + self.inputs.new('StringsSocket', "Data1") + self.inputs.new('StringsSocket', "Data2") + self.outputs.new('StringsSocket', "Result") + + def process(self): + + inputs = self.inputs + outputs = self.outputs + + # no logic applied yet + if outputs[0].is_linked: + if inputs['Data2'].is_linked: + data1 = inputs['Data1'].sv_get() + data2 = inputs['Data2'].sv_get() + func = func_dict[self.func_] + out = [func(data)] + outputs[0].sv_set([out]) + + +def register(): + bpy.utils.register_class(ListModifierNode) + + +def unregister(): + bpy.utils.unregister_class(ListModifierNode) -- GitLab From 18f0eab5b8e0f23d2844a708d8e0019e4ec341c3 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 15:54:53 +0200 Subject: [PATCH 02/53] add first commits 3 --- nodes/list_basic/modifier.py | 39 +++++++++++++++++++++--------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index c4666caeb..17ba97e41 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -26,18 +26,19 @@ from sverchok.data_structure import updateNode, SvSetSocketAnyType, SvGetSocketA node_item_list = [ - ("Set", lambda i: set(i)), - ("Ordered Set", ), - ("Sequential Set", ), - ("Unique Consecutives", ), - ("Accumulating Sum", lambda a: list(accumulate(a))), - ("Intersection", lambda a, b: set(a) & set(b)), - ("Union", lambda a, b: set(a) | set(b)), - ("Difference", lambda a, b: set(a) - set(b)), - ("Symmetric Diff", lambda a, b: set(a) ^ set(b)) + (1, "Set", lambda i: set(i)), + (1, "Ordered Set", ), + (1, "Sequential Set", ), + (1, "Unique Consecutives", ), + (1, "Accumulating Sum", lambda a: list(accumulate(a))), + (2, "Intersection", lambda a, b: set(a) & set(b)), + (2, "Union", lambda a, b: set(a) | set(b)), + (2, "Difference", lambda a, b: set(a) - set(b)), + (2, "Symmetric Diff", lambda a, b: set(a) ^ set(b)) ] -func_dict = {k: v for k, v in node_item_list} +func_dict = {k: v for _, k, v in node_item_list} +num_inputs = {k: v for v, k, _ in node_item_list} class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): ''' List Modifier''' @@ -45,7 +46,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): bl_label = 'List Modifier' bl_icon = 'OUTLINER_OB_EMPTY' - mode_items = [(name, name, "", idx) for idx, (name, _) in enumerate(node_item_list) + mode_items = [(name, name, "", idx) for idx, (_, name, _) in enumerate(node_item_list) func_ = EnumProperty( name="Modes", @@ -75,12 +76,18 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): # no logic applied yet if outputs[0].is_linked: - if inputs['Data2'].is_linked: - data1 = inputs['Data1'].sv_get() + + data1 = inputs['Data1'].sv_get() + func = func_dict[self.func_] + + if num_inputs[self.func_] == 1: + out = [func(data1)] + else: data2 = inputs['Data2'].sv_get() - func = func_dict[self.func_] - out = [func(data)] - outputs[0].sv_set([out]) + out = [func(data1, data2)] + + + outputs[0].sv_set([out]) def register(): -- GitLab From 3a04ddd47b596a6f99870721c38b5c81669c6ab1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 16:03:30 +0200 Subject: [PATCH 03/53] add more verbose but readable version --- nodes/list_basic/modifier.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 17ba97e41..94b15e75b 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -73,20 +73,19 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): inputs = self.inputs outputs = self.outputs + func = func_dict[self.func_] # no logic applied yet if outputs[0].is_linked: - data1 = inputs['Data1'].sv_get() - func = func_dict[self.func_] - if num_inputs[self.func_] == 1: + data1 = inputs['Data1'].sv_get() out = [func(data1)] else: + data1 = inputs['Data1'].sv_get() data2 = inputs['Data2'].sv_get() out = [func(data1, data2)] - outputs[0].sv_set([out]) -- GitLab From f70059877232036f5aef030c35d3c1c2af334e76 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 16:31:25 +0200 Subject: [PATCH 04/53] add stub for normalize --- nodes/list_basic/modifier.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 94b15e75b..ede3993a2 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -25,11 +25,17 @@ from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode, SvSetSocketAnyType, SvGetSocketAnyType +def normalize(input): + # or numpy version.. + max_value = max(input) + return [n/max_value for n in input] + node_item_list = [ (1, "Set", lambda i: set(i)), (1, "Ordered Set", ), (1, "Sequential Set", ), (1, "Unique Consecutives", ), + (1, "Normalize", ), (1, "Accumulating Sum", lambda a: list(accumulate(a))), (2, "Intersection", lambda a, b: set(a) & set(b)), (2, "Union", lambda a, b: set(a) | set(b)), -- GitLab From 6845c5318de1442a2680d90019a3152f9a1af9d1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 17:18:53 +0200 Subject: [PATCH 05/53] add stubs for functions --- nodes/list_basic/modifier.py | 48 ++++++++++++++++++++++++++++++------ 1 file changed, 41 insertions(+), 7 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index ede3993a2..956dcdc9b 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -25,17 +25,42 @@ from sverchok.node_tree import SverchCustomTreeNode from sverchok.data_structure import updateNode, SvSetSocketAnyType, SvGetSocketAnyType -def normalize(input): +def normalize(a): # or numpy version.. - max_value = max(input) - return [n/max_value for n in input] + max_value = max(a) + return [n/max_value for n in a] + +def ordered_set(a): + seen = set() + b = [] + for x in a: + if not x in seen: + b.append(x) + seen.add(x) + return b + +# def sequential_set(a): +# prev = '' +# for x in a: +# if not x == prev: +# b.append(x) +# prev = x +# return b + +# def unique_consecutives(a): +# prev = '' +# for x in a: +# if not x == prev: +# b.append(x) +# prev = x +# return b node_item_list = [ (1, "Set", lambda i: set(i)), - (1, "Ordered Set", ), - (1, "Sequential Set", ), - (1, "Unique Consecutives", ), - (1, "Normalize", ), + (1, "Ordered Set by input", ordered_set), + (1, "Sequential Set", sequential_set), + (1, "Unique Consecutives", unique_consecutives), + (1, "Normalize", normalize), (1, "Accumulating Sum", lambda a: list(accumulate(a))), (2, "Intersection", lambda a, b: set(a) & set(b)), (2, "Union", lambda a, b: set(a) | set(b)), @@ -82,6 +107,15 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): func = func_dict[self.func_] # no logic applied yet + # data = self.inputs[0].sv_get() + # def f(d): + # if isinstance(d[0], (int, float)): + # return operation(d) + # else: + # return [f(x) for x in d] + # out = f(data) + # self.outputs[0].sv_set(data) + if outputs[0].is_linked: if num_inputs[self.func_] == 1: -- GitLab From c5921fdd2ce08bcc954364f8160058fa224d7fea Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 17:26:44 +0200 Subject: [PATCH 06/53] add commented out functions --- nodes/list_basic/modifier.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 956dcdc9b..e13f1e53e 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -22,7 +22,7 @@ import bpy from bpy.props import EnumProperty, IntProperty, BoolProperty from sverchok.node_tree import SverchCustomTreeNode -from sverchok.data_structure import updateNode, SvSetSocketAnyType, SvGetSocketAnyType +from sverchok.data_structure import updateNode def normalize(a): @@ -88,8 +88,8 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): listify = BoolProperty( default=True, - description='Output lists or proper sets', - ) + description='Output lists or proper sets' + ) def draw_buttons(self, context, layout): -- GitLab From 952370ba6256634a00bc712744ce37bf7da3fc3b Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 17:54:33 +0200 Subject: [PATCH 07/53] add code to stub funcs - untested --- nodes/list_basic/modifier.py | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index e13f1e53e..86da8745f 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -39,27 +39,27 @@ def ordered_set(a): seen.add(x) return b -# def sequential_set(a): -# prev = '' -# for x in a: -# if not x == prev: -# b.append(x) -# prev = x -# return b - -# def unique_consecutives(a): -# prev = '' -# for x in a: -# if not x == prev: -# b.append(x) -# prev = x -# return b +def sequential_set(a): + return list(sorted(list(set(a)))) + +def sequential_set_reversed(a): + return list(reversed(sorted(list(set(a))))) + +def unique_consecutives(a): + prev = '' + for x in a: + if not x == prev: + b.append(x) + prev = x + return b + node_item_list = [ (1, "Set", lambda i: set(i)), (1, "Ordered Set by input", ordered_set), - (1, "Sequential Set", sequential_set), (1, "Unique Consecutives", unique_consecutives), + (1, "Sequential Set", sequential_set), + (1, "Sequential Set Rev", sequential_set_reversed), (1, "Normalize", normalize), (1, "Accumulating Sum", lambda a: list(accumulate(a))), (2, "Intersection", lambda a, b: set(a) & set(b)), @@ -68,9 +68,11 @@ node_item_list = [ (2, "Symmetric Diff", lambda a, b: set(a) ^ set(b)) ] + func_dict = {k: v for _, k, v in node_item_list} num_inputs = {k: v for v, k, _ in node_item_list} + class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): ''' List Modifier''' bl_idname = 'ListModifierNode' -- GitLab From 25127967cba08cc297d00a3a817b50a68012816d Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 18:04:08 +0200 Subject: [PATCH 08/53] add code to proces func --- nodes/list_basic/modifier.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 86da8745f..21ab215d0 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -53,19 +53,26 @@ def unique_consecutives(a): prev = x return b +SET = 'Set' +INTX = 'Intersection' +UNION = 'Union' +DIFF = 'Difference' +SYMDIFF = 'Symmetric Diff' +SET_OPS = [SET, INTX, UNION, DIFF, SYMDIFF] + node_item_list = [ - (1, "Set", lambda i: set(i)), + (1, SET, lambda i: set(i)), (1, "Ordered Set by input", ordered_set), (1, "Unique Consecutives", unique_consecutives), (1, "Sequential Set", sequential_set), (1, "Sequential Set Rev", sequential_set_reversed), (1, "Normalize", normalize), (1, "Accumulating Sum", lambda a: list(accumulate(a))), - (2, "Intersection", lambda a, b: set(a) & set(b)), - (2, "Union", lambda a, b: set(a) | set(b)), - (2, "Difference", lambda a, b: set(a) - set(b)), - (2, "Symmetric Diff", lambda a, b: set(a) ^ set(b)) + (2, INTX, lambda a, b: set(a) & set(b)), + (2, UNION, lambda a, b: set(a) | set(b)), + (2, DIFF, lambda a, b: set(a) - set(b)), + (2, SYMDIFF, lambda a, b: set(a) ^ set(b)) ] @@ -108,6 +115,9 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): outputs = self.outputs func = func_dict[self.func_] + # if func_ in SET_OPS and self.listify: + # maybe define a function to return list only. + # no logic applied yet # data = self.inputs[0].sv_get() # def f(d): -- GitLab From 955fc808599bd1640ff6d0b5582df9834cc788d7 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 19:59:41 +0200 Subject: [PATCH 09/53] add less verbose versions of sequential set --- nodes/list_basic/modifier.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 21ab215d0..d6716181c 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -39,12 +39,6 @@ def ordered_set(a): seen.add(x) return b -def sequential_set(a): - return list(sorted(list(set(a)))) - -def sequential_set_reversed(a): - return list(reversed(sorted(list(set(a))))) - def unique_consecutives(a): prev = '' for x in a: @@ -65,8 +59,8 @@ node_item_list = [ (1, SET, lambda i: set(i)), (1, "Ordered Set by input", ordered_set), (1, "Unique Consecutives", unique_consecutives), - (1, "Sequential Set", sequential_set), - (1, "Sequential Set Rev", sequential_set_reversed), + (1, "Sequential Set", lambda a: sorted(set(a))), + (1, "Sequential Set Rev", sorted(set(a), reverse=True)), (1, "Normalize", normalize), (1, "Accumulating Sum", lambda a: list(accumulate(a))), (2, INTX, lambda a, b: set(a) & set(b)), -- GitLab From d80c7d23c10127117ff34461311d381de5f398bd Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 20:00:38 +0200 Subject: [PATCH 10/53] add forgotten lambda syntax --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index d6716181c..c1cd6687a 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -60,7 +60,7 @@ node_item_list = [ (1, "Ordered Set by input", ordered_set), (1, "Unique Consecutives", unique_consecutives), (1, "Sequential Set", lambda a: sorted(set(a))), - (1, "Sequential Set Rev", sorted(set(a), reverse=True)), + (1, "Sequential Set Rev", lambda a: sorted(set(a), reverse=True)), (1, "Normalize", normalize), (1, "Accumulating Sum", lambda a: list(accumulate(a))), (2, INTX, lambda a, b: set(a) & set(b)), -- GitLab From 8f7b24f23337940e5a113779f837b4045a8d8536 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 20:01:48 +0200 Subject: [PATCH 11/53] add consisten lambda param names --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index c1cd6687a..1ec5bafbd 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -56,7 +56,7 @@ SET_OPS = [SET, INTX, UNION, DIFF, SYMDIFF] node_item_list = [ - (1, SET, lambda i: set(i)), + (1, SET, lambda a: set(a)), (1, "Ordered Set by input", ordered_set), (1, "Unique Consecutives", unique_consecutives), (1, "Sequential Set", lambda a: sorted(set(a))), -- GitLab From 92bfcec9b628bb95dc53be4e77abeffae430ac52 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 20:03:05 +0200 Subject: [PATCH 12/53] add valid default --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 1ec5bafbd..ff77459de 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -85,7 +85,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): func_ = EnumProperty( name="Modes", description="Mode Choices", - default="AVR", items=mode_items, + default=SET, items=mode_items, update=updateNode ) -- GitLab From b2709362b533a7c86844222ca778811b035a2849 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 20:21:39 +0200 Subject: [PATCH 13/53] add bigger range, non enumerated indexing --- nodes/list_basic/modifier.py | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index ff77459de..8dec0ae86 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -54,24 +54,24 @@ DIFF = 'Difference' SYMDIFF = 'Symmetric Diff' SET_OPS = [SET, INTX, UNION, DIFF, SYMDIFF] - +# using a purposely broad indexing value range incase other functinos get into this.. node_item_list = [ - (1, SET, lambda a: set(a)), - (1, "Ordered Set by input", ordered_set), - (1, "Unique Consecutives", unique_consecutives), - (1, "Sequential Set", lambda a: sorted(set(a))), - (1, "Sequential Set Rev", lambda a: sorted(set(a), reverse=True)), - (1, "Normalize", normalize), - (1, "Accumulating Sum", lambda a: list(accumulate(a))), - (2, INTX, lambda a, b: set(a) & set(b)), - (2, UNION, lambda a, b: set(a) | set(b)), - (2, DIFF, lambda a, b: set(a) - set(b)), - (2, SYMDIFF, lambda a, b: set(a) ^ set(b)) + (1, 1, SET, lambda a: set(a)), + (1, 10, "Ordered Set by input", ordered_set), + (1, 20, "Unique Consecutives", unique_consecutives), + (1, 30, "Sequential Set", lambda a: sorted(set(a))), + (1, 40, "Sequential Set Rev", lambda a: sorted(set(a), reverse=True)), + (1, 50, "Normalize", normalize), + (1, 60, "Accumulating Sum", lambda a: list(accumulate(a))), + (2, 70, INTX, lambda a, b: set(a) & set(b)), + (2, 80, UNION, lambda a, b: set(a) | set(b)), + (2, 90, DIFF, lambda a, b: set(a) - set(b)), + (2, 100, SYMDIFF, lambda a, b: set(a) ^ set(b)) ] -func_dict = {k: v for _, k, v in node_item_list} -num_inputs = {k: v for v, k, _ in node_item_list} +func_dict = {k: v for _, _, k, v in node_item_list} +num_inputs = {k: v for v, _, k, _ in node_item_list} class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): @@ -80,7 +80,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): bl_label = 'List Modifier' bl_icon = 'OUTLINER_OB_EMPTY' - mode_items = [(name, name, "", idx) for idx, (_, name, _) in enumerate(node_item_list) + mode_items = [(name, name, "", idx) for _, idx, name, _ in node_item_list] func_ = EnumProperty( name="Modes", -- GitLab From 80402ffe2d535312de18861ce12d0b4bca22abf1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 14 Sep 2016 20:23:05 +0200 Subject: [PATCH 14/53] add missing list statement --- nodes/list_basic/modifier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 8dec0ae86..de29a363e 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -41,6 +41,7 @@ def ordered_set(a): def unique_consecutives(a): prev = '' + b = [] for x in a: if not x == prev: b.append(x) -- GitLab From db32e83b2e946de2dc1d35ecbd80f2bb41148d4d Mon Sep 17 00:00:00 2001 From: zeffii Date: Thu, 15 Sep 2016 10:52:59 +0200 Subject: [PATCH 15/53] add on the file func modified version -- maybe bad practice --- nodes/list_basic/modifier.py | 55 ++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 27 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index de29a363e..a0ce2a0d0 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -70,7 +70,6 @@ node_item_list = [ (2, 100, SYMDIFF, lambda a, b: set(a) ^ set(b)) ] - func_dict = {k: v for _, _, k, v in node_item_list} num_inputs = {k: v for v, _, k, _ in node_item_list} @@ -98,6 +97,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): def draw_buttons(self, context, layout): layout.prop(self, "func_") + layout.prop(self, "listify") def sv_init(self, context): self.inputs.new('StringsSocket', "Data1") @@ -108,32 +108,33 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): inputs = self.inputs outputs = self.outputs - func = func_dict[self.func_] - - # if func_ in SET_OPS and self.listify: - # maybe define a function to return list only. - - # no logic applied yet - # data = self.inputs[0].sv_get() - # def f(d): - # if isinstance(d[0], (int, float)): - # return operation(d) - # else: - # return [f(x) for x in d] - # out = f(data) - # self.outputs[0].sv_set(data) - - if outputs[0].is_linked: - - if num_inputs[self.func_] == 1: - data1 = inputs['Data1'].sv_get() - out = [func(data1)] - else: - data1 = inputs['Data1'].sv_get() - data2 = inputs['Data2'].sv_get() - out = [func(data1, data2)] - - outputs[0].sv_set([out]) + operation = func_dict[self.func_] + + if not outputs[0].is_linked: + return + + if self.func_ in SET_OPS and self.listify: + def f(d): + if isinstance(d[0], (int, float)): + return list(operation(d)) + else: + return [f(x) for x in d] + else: + def f(d): + if isinstance(d[0], (int, float)): + return operation(d) + else: + return [f(x) for x in d] + + if num_inputs[self.func_] == 1: + data1 = inputs['Data1'].sv_get() + out = [f(data1)] + else: + data1 = inputs['Data1'].sv_get() + data2 = inputs['Data2'].sv_get() + out = [f(data1, data2)] + + outputs[0].sv_set([out]) def register(): -- GitLab From 20713cb1b85ebf5737adcafa15027a4924f7e09e Mon Sep 17 00:00:00 2001 From: zeffii Date: Thu, 15 Sep 2016 16:19:40 +0200 Subject: [PATCH 16/53] add list modifier to spacebar menu --- menu.py | 11 ++++++++--- nodes/__init__.py | 1 + nodes/list_basic/modifier.py | 2 +- ui/nodeview_space_menu.py | 1 + 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/menu.py b/menu.py index 88fb3b912..d638f9b2d 100644 --- a/menu.py +++ b/menu.py @@ -125,11 +125,15 @@ def make_node_cats(): ["SvMaskJoinNode", "List Mask Join (in)"], ] + node_cats["List Mutators"] = [ + ["ListModifierNode", "List Modifier"] + ] + node_cats["List main"] = [ ["ListJoinNode", "List Join"], ["ZipNode", "List Zip"], ["ListLevelsNode", "List Del Levels"], - ["ListLengthNode", "List Length"], + ["ListLengthNode", "List Length"], ["ListSumNodeMK2", "List Sum"], ["ListMatchNode", "List Match"], ["ListFuncNode", "List Math"], @@ -316,8 +320,9 @@ def juggle_and_join(node_cats): node_cats['Beta Nodes'].extend(alpha) # put masks into list main - masks = node_cats.pop("List Masks") - node_cats["List main"].extend(masks) + for ltype in ["List Masks", "List Mutators"]: + node_refs = node_cats.pop(ltype) + node_cats["List main"].extend(node_refs) # add extended gens to Gens menu gen_ext = node_cats.pop("Extended Generators") diff --git a/nodes/__init__.py b/nodes/__init__.py index 67052ccc7..9a08a185b 100644 --- a/nodes/__init__.py +++ b/nodes/__init__.py @@ -102,6 +102,7 @@ nodes_dict = { 'converter', 'decompose', 'func', + 'modifier', 'join', 'length', 'levels', diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index a0ce2a0d0..7ccd9d8dc 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -96,7 +96,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): def draw_buttons(self, context, layout): - layout.prop(self, "func_") + layout.prop(self, "func_", text='') layout.prop(self, "listify") def sv_init(self, context): diff --git a/ui/nodeview_space_menu.py b/ui/nodeview_space_menu.py index 9271b13dc..253fba976 100644 --- a/ui/nodeview_space_menu.py +++ b/ui/nodeview_space_menu.py @@ -167,6 +167,7 @@ class NODEVIEW_MT_AddListOps(bpy.types.Menu): layout.menu("NODEVIEW_MT_AddListmain") layout.menu("NODEVIEW_MT_AddListstruct") layout_draw_categories(self.layout, node_cats["List Masks"]) + layout_draw_categories(self.layout, node_cats["List Mutators"]) classes = [ -- GitLab From 998655c5feef8bd494246cf546527923d54281b8 Mon Sep 17 00:00:00 2001 From: zeffii Date: Thu, 15 Sep 2016 19:50:01 +0200 Subject: [PATCH 17/53] rename ui element listify -> output as list --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 7ccd9d8dc..1780452a0 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -97,7 +97,7 @@ class ListModifierNode(bpy.types.Node, SverchCustomTreeNode): def draw_buttons(self, context, layout): layout.prop(self, "func_", text='') - layout.prop(self, "listify") + layout.prop(self, "listify", text='output as list') def sv_init(self, context): self.inputs.new('StringsSocket', "Data1") -- GitLab From a3c83674cebc1c324e1c6652e4a4d00676dde6df Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 19 Sep 2016 14:26:20 +0200 Subject: [PATCH 18/53] add mask subset [(a in B) for a in A] --- nodes/list_basic/modifier.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index b633094c0..d2ad3c87b 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -30,6 +30,7 @@ def normalize(a): max_value = max(a) return [n/max_value for n in a] + def ordered_set(a): seen = set() b = [] @@ -39,6 +40,7 @@ def ordered_set(a): seen.add(x) return b + def unique_consecutives(a): prev = '' b = [] @@ -48,6 +50,11 @@ def unique_consecutives(a): prev = x return b + +def mask_subset(a, b): + return [(_ in b) for _ in a] + + SET = 'Set' INTX = 'Intersection' UNION = 'Union' @@ -57,13 +64,14 @@ SET_OPS = [SET, INTX, UNION, DIFF, SYMDIFF] # using a purposely broad indexing value range incase other functinos get into this.. node_item_list = [ - (1, 1, SET, lambda a: set(a)), + (1, 1, SET, set), (1, 10, "Ordered Set by input", ordered_set), (1, 20, "Unique Consecutives", unique_consecutives), (1, 30, "Sequential Set", lambda a: sorted(set(a))), (1, 40, "Sequential Set Rev", lambda a: sorted(set(a), reverse=True)), (1, 50, "Normalize", normalize), (1, 60, "Accumulating Sum", lambda a: list(accumulate(a))), + (2, 69, "Mask subset (A in B)", mask_subset), (2, 70, INTX, lambda a, b: set(a) & set(b)), (2, 80, UNION, lambda a, b: set(a) | set(b)), (2, 90, DIFF, lambda a, b: set(a) - set(b)), -- GitLab From 5b017b08e61df97e066e4ee9baf5b3238372dba1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 19 Sep 2016 15:43:38 +0200 Subject: [PATCH 19/53] add few icons to space_menu --- nodes/basic_debug/3dview_props.py | 2 +- nodes/list_basic/modifier.py | 2 +- ui/nodeview_space_menu.py | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/nodes/basic_debug/3dview_props.py b/nodes/basic_debug/3dview_props.py index 6b9d66b4f..24cb7cdb4 100644 --- a/nodes/basic_debug/3dview_props.py +++ b/nodes/basic_debug/3dview_props.py @@ -26,7 +26,7 @@ class Sv3DviewPropsNode(bpy.types.Node, SverchCustomTreeNode): ''' Sv 3Dview Props Node ''' bl_idname = 'Sv3DviewPropsNode' bl_label = '3dview Props' - bl_icon = 'OUTLINER_OB_EMPTY' + bl_icon = 'SETTINGS' def draw_buttons(self, context, layout): context = bpy.context diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index d2ad3c87b..f933e8c6c 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -86,7 +86,7 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): ''' List Modifier''' bl_idname = 'SvListModifierNode' bl_label = 'List Modifier' - bl_icon = 'OUTLINER_OB_EMPTY' + bl_icon = 'MODIFIER' mode_items = [(name, name, "", idx) for _, idx, name, _ in node_item_list] diff --git a/ui/nodeview_space_menu.py b/ui/nodeview_space_menu.py index ca4bffb42..a405d41eb 100644 --- a/ui/nodeview_space_menu.py +++ b/ui/nodeview_space_menu.py @@ -106,7 +106,7 @@ class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu): layout = self.layout layout.operator_context = 'INVOKE_REGION_WIN' - s = layout.operator("node.add_search", text="Search", icon='VIEWZOOM') + s = layout.operator("node.add_search", text="Search", icon='OUTLINER_DATA_FONT') s.use_transform = True show_icons = menu_prefs.get('show_icons') @@ -115,7 +115,7 @@ class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu): if show_icons: layout.menu("NODEVIEW_MT_AddGenerators", icon='OBJECT_DATAMODE') layout.menu("NODEVIEW_MT_AddTransforms", icon='MANIPUL') - layout.menu("NODEVIEW_MT_AddAnalyzers", icon='BORDERMOVE') + layout.menu("NODEVIEW_MT_AddAnalyzers", icon='VIEWZOOM') layout.menu("NODEVIEW_MT_AddModifiers", icon='MODIFIER') else: layout.menu("NODEVIEW_MT_AddGenerators") @@ -128,9 +128,9 @@ class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu): layout.menu("NODEVIEW_MT_AddVector") layout.menu("NODEVIEW_MT_AddMatrix") layout.menu("NODEVIEW_MT_AddLogic") - layout.menu("NODEVIEW_MT_AddListOps") + layout.menu("NODEVIEW_MT_AddListOps", icon='NLA') layout.separator() - layout.menu("NODEVIEW_MT_AddViz") + layout.menu("NODEVIEW_MT_AddViz", icon='RESTRICT_VIEW_OFF') layout.menu("NODEVIEW_MT_AddText") layout.menu("NODEVIEW_MT_AddScene") layout.menu("NODEVIEW_MT_AddLayout") -- GitLab From 41fd05cb07d1f5f6f51d385936d96f8ce5c4e83d Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 19 Sep 2016 15:59:51 +0200 Subject: [PATCH 20/53] add dynamic icon function for main menu --- ui/nodeview_space_menu.py | 33 +++++++++++++-------------------- 1 file changed, 13 insertions(+), 20 deletions(-) diff --git a/ui/nodeview_space_menu.py b/ui/nodeview_space_menu.py index a405d41eb..bf3172d61 100644 --- a/ui/nodeview_space_menu.py +++ b/ui/nodeview_space_menu.py @@ -30,9 +30,7 @@ import sverchok from sverchok.menu import make_node_cats node_cats = make_node_cats() - addon_name = sverchok.__name__ - menu_prefs = {} @@ -111,37 +109,32 @@ class NODEVIEW_MT_Dynamic_Menu(bpy.types.Menu): show_icons = menu_prefs.get('show_icons') + def icon(display_icon): + '''returns empty dict if show_icons is False, else the icon passed''' + return {'icon': display_icon for i in [1] if show_icons} + layout.separator() - if show_icons: - layout.menu("NODEVIEW_MT_AddGenerators", icon='OBJECT_DATAMODE') - layout.menu("NODEVIEW_MT_AddTransforms", icon='MANIPUL') - layout.menu("NODEVIEW_MT_AddAnalyzers", icon='VIEWZOOM') - layout.menu("NODEVIEW_MT_AddModifiers", icon='MODIFIER') - else: - layout.menu("NODEVIEW_MT_AddGenerators") - layout.menu("NODEVIEW_MT_AddTransforms") - layout.menu("NODEVIEW_MT_AddAnalyzers") - layout.menu("NODEVIEW_MT_AddModifiers") + + layout.menu("NODEVIEW_MT_AddGenerators", **icon('OBJECT_DATAMODE')) + layout.menu("NODEVIEW_MT_AddTransforms", **icon('MANIPUL')) + layout.menu("NODEVIEW_MT_AddAnalyzers", **icon('VIEWZOOM')) + layout.menu("NODEVIEW_MT_AddModifiers", **icon('MODIFIER')) layout.separator() layout.menu("NODEVIEW_MT_AddNumber") layout.menu("NODEVIEW_MT_AddVector") layout.menu("NODEVIEW_MT_AddMatrix") layout.menu("NODEVIEW_MT_AddLogic") - layout.menu("NODEVIEW_MT_AddListOps", icon='NLA') + layout.menu("NODEVIEW_MT_AddListOps", **icon('NLA')) layout.separator() - layout.menu("NODEVIEW_MT_AddViz", icon='RESTRICT_VIEW_OFF') + layout.menu("NODEVIEW_MT_AddViz", **icon('RESTRICT_VIEW_OFF')) layout.menu("NODEVIEW_MT_AddText") layout.menu("NODEVIEW_MT_AddScene") layout.menu("NODEVIEW_MT_AddLayout") layout.separator() layout.menu("NODEVIEW_MT_AddNetwork") - if show_icons: - layout.menu("NODEVIEW_MT_AddBetas", icon='OUTLINER_DATA_POSE') - layout.menu("NODEVIEW_MT_AddAlphas", icon='ERROR') - else: - layout.menu("NODEVIEW_MT_AddBetas") - layout.menu("NODEVIEW_MT_AddAlphas") + layout.menu("NODEVIEW_MT_AddBetas", **icon('OUTLINER_DATA_POSE')) + layout.menu("NODEVIEW_MT_AddAlphas", **icon('ERROR')) class NODEVIEW_MT_AddGenerators(bpy.types.Menu): -- GitLab From 90bfe41f80347e73d12c7d352e65255fc74f7d21 Mon Sep 17 00:00:00 2001 From: zeffii Date: Mon, 19 Sep 2016 16:22:35 +0200 Subject: [PATCH 21/53] add dynamic showicon code --- ui/nodeview_space_menu.py | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/ui/nodeview_space_menu.py b/ui/nodeview_space_menu.py index bf3172d61..66b69a8a3 100644 --- a/ui/nodeview_space_menu.py +++ b/ui/nodeview_space_menu.py @@ -44,6 +44,20 @@ def get_icon_switch(): def layout_draw_categories(layout, node_details): show_icons = menu_prefs.get('show_icons') + def icon(display_icon): + '''returns empty dict if show_icons is False, else the icon passed''' + return {'icon': display_icon for i in [1] if show_icons and display_icon} + + def get_icon(node_ref): + # some nodes don't declare a bl_icon, but most do so try/except is fine. + try: + _icon = getattr(node_ref, 'bl_icon') + if _icon == 'OUTLINER_OB_EMPTY': + _icon = None + except: + _icon = None + return _icon + add_n_grab = 'node.add_node' for node_info in node_details: @@ -54,20 +68,8 @@ def layout_draw_categories(layout, node_details): bl_idname = node_info[0] node_ref = getattr(bpy.types, bl_idname) - if show_icons: - - # some nodes don't declare a bl_icon, but most do so try/except is fine. - try: - icon = getattr(node_ref, 'bl_icon') - except: - icon = None - - if icon and (not icon == 'OUTLINER_OB_EMPTY'): - layout_params = dict(text=node_ref.bl_label, icon=icon) - else: - layout_params = dict(text=node_ref.bl_label) - else: - layout_params = dict(text=node_ref.bl_label) + display_icon = get_icon(node_ref) + layout_params = dict(text=node_ref.bl_label, **icon(display_icon)) node_op = layout.operator(add_n_grab, **layout_params) node_op.type = bl_idname -- GitLab From b5f213ca328636062ee81f0ce742eedcaa8965c1 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 12:10:51 +0200 Subject: [PATCH 22/53] add all function combination --- nodes/list_basic/modifier.py | 50 ++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index f933e8c6c..fddadc7f6 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -82,6 +82,39 @@ func_dict = {k: v for _, _, k, v in node_item_list} num_inputs = {k: v for v, _, k, _ in node_item_list} +def get_f(self, operation): + input_count = num_inputs[self.func_] + makes_lists = self.listify + + if input_count == 1: + if self.func_ in SET_OPS and makes_lists: + def f(d): + if isinstance(d[0], (int, float)): + return list(operation(d)) + else: + return [f(x) for x in d] + else: + def f(d): + if isinstance(d[0], (int, float)): + return operation(d) + else: + return [f(x) for x in d] + else: + if self.func_ in SET_OPS and makes_lists: + def f(a, b): + if isinstance(a[0], (int, float)): + return list(operation(a, b)) + else: + return [f(*_) for _ in zip(a, b)] + else: + def f(a, b): + if isinstance(a[0], (int, float)): + return operation(a, b) + else: + return [f(*_) for _ in zip(a, b)] + + return f + class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): ''' List Modifier''' bl_idname = 'SvListModifierNode' @@ -121,26 +154,15 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): if not outputs[0].is_linked: return - if self.func_ in SET_OPS and self.listify: - def f(d): - if isinstance(d[0], (int, float)): - return list(operation(d)) - else: - return [f(x) for x in d] - else: - def f(d): - if isinstance(d[0], (int, float)): - return operation(d) - else: - return [f(x) for x in d] + f = get_f(self, operation) if num_inputs[self.func_] == 1: data1 = inputs['Data1'].sv_get() - out = [f(data1)] + out = f(data1) else: data1 = inputs['Data1'].sv_get() data2 = inputs['Data2'].sv_get() - out = [f(data1, data2)] + out = f(data1, data2) outputs[0].sv_set(out) -- GitLab From d7152c1c35e44d38d842e8362646c08a3f96a944 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 12:18:53 +0200 Subject: [PATCH 23/53] add update func to listify toggle --- nodes/list_basic/modifier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index fddadc7f6..863792c6d 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -132,7 +132,8 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): listify = BoolProperty( default=True, - description='Output lists or proper sets' + description='Output lists or proper sets', + update=updateNode ) -- GitLab From 6504fb3c054b5746666c4ce8c41ef7b0b2b002a5 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 12:27:45 +0200 Subject: [PATCH 24/53] add explicit mention of unary --- nodes/list_basic/modifier.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 863792c6d..5ebff1df8 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -82,11 +82,10 @@ func_dict = {k: v for _, _, k, v in node_item_list} num_inputs = {k: v for v, _, k, _ in node_item_list} -def get_f(self, operation): - input_count = num_inputs[self.func_] +def get_f(self, operation, unary): makes_lists = self.listify - if input_count == 1: + if unary: if self.func_ in SET_OPS and makes_lists: def f(d): if isinstance(d[0], (int, float)): @@ -151,13 +150,14 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): inputs = self.inputs outputs = self.outputs operation = func_dict[self.func_] + unary = (num_inputs[self.func_] == 1) if not outputs[0].is_linked: return - f = get_f(self, operation) + f = get_f(self, operation, unary) - if num_inputs[self.func_] == 1: + if unary: data1 = inputs['Data1'].sv_get() out = f(data1) else: -- GitLab From 357218cf82aab60e9b449d27dc7f4ce5694eb6c7 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 12:36:07 +0200 Subject: [PATCH 25/53] remove whitespace --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 5ebff1df8..ac198954d 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -82,7 +82,7 @@ func_dict = {k: v for _, _, k, v in node_item_list} num_inputs = {k: v for v, _, k, _ in node_item_list} -def get_f(self, operation, unary): +def get_f(self, operation, unary): makes_lists = self.listify if unary: -- GitLab From 67a42c3da4c05cf3fbfbaa00854c6657ffc184bc Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 12:38:03 +0200 Subject: [PATCH 26/53] reorder no ops --- nodes/list_basic/modifier.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index ac198954d..f065124f1 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -146,15 +146,14 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): self.outputs.new('StringsSocket', "Result") def process(self): - inputs = self.inputs outputs = self.outputs - operation = func_dict[self.func_] - unary = (num_inputs[self.func_] == 1) if not outputs[0].is_linked: return + operation = func_dict[self.func_] + unary = (num_inputs[self.func_] == 1) f = get_f(self, operation, unary) if unary: -- GitLab From a789337137366cfe5f7ed27cd9f1300472b5165a Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 13:57:16 +0200 Subject: [PATCH 27/53] add simple bl_label setter --- nodes/list_basic/modifier.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index f065124f1..4c1545d90 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -144,11 +144,15 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): self.inputs.new('StringsSocket', "Data1") self.inputs.new('StringsSocket', "Data2") self.outputs.new('StringsSocket', "Result") + self.bl_label = 'Set' def process(self): inputs = self.inputs outputs = self.outputs + if not (self.bl_label == self.func_): + self.bl_label = self.func_ + if not outputs[0].is_linked: return -- GitLab From b4d358e9429bf0a2e24d0990b1b2c4cfb543c7eb Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 13:59:12 +0200 Subject: [PATCH 28/53] fix typo comment --- nodes/list_basic/modifier.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 4c1545d90..3190926ed 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -62,7 +62,7 @@ DIFF = 'Difference' SYMDIFF = 'Symmetric Diff' SET_OPS = [SET, INTX, UNION, DIFF, SYMDIFF] -# using a purposely broad indexing value range incase other functinos get into this.. +# using a purposely broad indexing value range incase other functions get into this.. node_item_list = [ (1, 1, SET, set), (1, 10, "Ordered Set by input", ordered_set), -- GitLab From 30b845567486ffc65d1b547d9586c1198e8c8544 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 14:19:29 +0200 Subject: [PATCH 29/53] use draw_label instead --- nodes/list_basic/modifier.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 3190926ed..4cee30a06 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -144,15 +144,15 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): self.inputs.new('StringsSocket', "Data1") self.inputs.new('StringsSocket', "Data2") self.outputs.new('StringsSocket', "Result") - self.bl_label = 'Set' + # self.bl_label = 'Set' + + def draw_label(self): + return self.func_ def process(self): inputs = self.inputs outputs = self.outputs - if not (self.bl_label == self.func_): - self.bl_label = self.func_ - if not outputs[0].is_linked: return -- GitLab From 64083217a625aa3c4b2229e2ae64ffe6aed474a4 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 14:20:31 +0200 Subject: [PATCH 30/53] nix comment --- nodes/list_basic/modifier.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 4cee30a06..436c4555e 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -144,7 +144,6 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): self.inputs.new('StringsSocket', "Data1") self.inputs.new('StringsSocket', "Data2") self.outputs.new('StringsSocket', "Result") - # self.bl_label = 'Set' def draw_label(self): return self.func_ -- GitLab From 3875747f116a7420e1062208488da797c0d4e2df Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 14:49:33 +0200 Subject: [PATCH 31/53] add indifference to data1/2 socket input --- nodes/list_basic/modifier.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 436c4555e..2e2f5e1db 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -160,7 +160,12 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): f = get_f(self, operation, unary) if unary: - data1 = inputs['Data1'].sv_get() + if inputs['Data1'].is_linked: + data1 = inputs['Data1'].sv_get() + elif inputs['Data2'].is_linked: + data1 = inputs['Data2'].sv_get() + else: + return out = f(data1) else: data1 = inputs['Data1'].sv_get() -- GitLab From 60bd6e8cb179b58c238cee25a9a6e2b6b9e170aa Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 15:09:12 +0200 Subject: [PATCH 32/53] remove false comment and unused import --- menu.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu.py b/menu.py index 2715364f8..cd796d966 100644 --- a/menu.py +++ b/menu.py @@ -18,7 +18,6 @@ # ##### END GPL LICENSE BLOCK ##### import os -import pprint from os.path import dirname from collections import OrderedDict @@ -62,7 +61,6 @@ def make_node_cats(): # final append node_cats[category] = temp_list - # pprint.pprint(node_cats) return node_cats -- GitLab From 875ff63cd9da81be39cda70b1db37ebd8d399cda Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 15:14:37 +0200 Subject: [PATCH 33/53] add clarification to index.md --- index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.md b/index.md index 8c9b29217..6ea3943a5 100644 --- a/index.md +++ b/index.md @@ -1,4 +1,4 @@ -> +> *This file is parsed by menu.py* > The following strict rules apply to editing this file: > > - do not use tabs, anywhere -- GitLab From 6006a66a8f2fa1d6667f33f26ab0c22c34674eb8 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 15:16:11 +0200 Subject: [PATCH 34/53] fix markdown in md --- index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/index.md b/index.md index 6ea3943a5..dfe1a8d16 100644 --- a/index.md +++ b/index.md @@ -1,4 +1,5 @@ -> *This file is parsed by menu.py* +> ### This file is parsed by menu.py +> > The following strict rules apply to editing this file: > > - do not use tabs, anywhere -- GitLab From c84f719560b228822a9330b0a1a3022973a3281c Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 16:58:28 +0200 Subject: [PATCH 35/53] add list_modifier.rst --- docs/nodes/list_main/list_main.rst | 1 + docs/nodes/list_main/list_modifier.rst | 155 +++++++++++++++++++++++++ 2 files changed, 156 insertions(+) create mode 100644 docs/nodes/list_main/list_modifier.rst diff --git a/docs/nodes/list_main/list_main.rst b/docs/nodes/list_main/list_main.rst index 5c3507c02..491e7fbcb 100644 --- a/docs/nodes/list_main/list_main.rst +++ b/docs/nodes/list_main/list_main.rst @@ -15,3 +15,4 @@ List Main list_mask_in list_match list_math + list_modifier diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst new file mode 100644 index 000000000..95cdbf35d --- /dev/null +++ b/docs/nodes/list_main/list_modifier.rst @@ -0,0 +1,155 @@ +List Modifier +~~~~~~~~~~~~~ + +This node offers an assortment of list modification functions. The node +has both Unary and Binary modes. + +- In Unary mode the input socket is the linked one +- if data1 isn’t linked then data2 is used as the input if it is linked +- if both are linked data1 is used. + +Behaviour +~~~~~~~~~ + ++----------+----------+---------------+ +| Modes | inputs | Behaviour | +| | | Description | ++==========+==========+===============+ +| Set | unary | turns the | +| | | valid input | +| | | into a set | +| | | ``input = [0, | +| | | 0,0,1,1,1,3,3 | +| | | ,3,5,5,5,6,7, | +| | | 8,4,4,4,6,6,6 | +| | | ,7,7,7,8]`` | +| | | \ ``output = | +| | | [set(input)]` | +| | | ` | ++----------+----------+---------------+ +| Ordered | unary | only unique | +| Set by | | numbers but | +| input | | ordered by | +| | | the original | +| | | input | +| | | sequence | +| | | ``input = [0, | +| | | 0,0,1,1,1,3,3 | +| | | ,3,5,5,5,6,7, | +| | | 8,4,4,4,6,6,6 | +| | | ,7,7,7,8]`` | +| | | ``output = [0 | +| | | ,1,3,5,6,7,8, | +| | | 4]`` | ++----------+----------+---------------+ +| Unique | unary | no | +| Consecut | | consecutive | +| ives | | repeats | +| | | ``input = [0, | +| | | 0,0,1,1,1,3,3 | +| | | ,3,5,5,5,6,7, | +| | | 8,4,4,4,6,6,6 | +| | | ,7,7,7,8]`` | +| | | ``output = [0 | +| | | ,1,3,5,6,7,8, | +| | | 4,6,7,8]`` | ++----------+----------+---------------+ +| Sequenti | unary | unique input | +| al | | values, order | +| Set | | by their | +| | | value | +| | | ``input = [0, | +| | | 0,0,1,1,1,3,3 | +| | | ,3,5,5,5,6,7, | +| | | 8,4,4,4,6,6,6 | +| | | ,7,7,7,8]`` | +| | | ``output = [0 | +| | | ,1,3,4,5,6,7, | +| | | 8]`` | ++----------+----------+---------------+ +| Sequenti | unary | unique input | +| al | | values, order | +| Set Rev | | by their | +| | | value, | +| | | reversed | +| | | ``input = [0, | +| | | 0,0,1,1,1,3,3 | +| | | ,3,5,5,5,6,7, | +| | | 8,4,4,4,6,6,6 | +| | | ,7,7,7,8]`` | +| | | ``output = [8 | +| | | ,7,6,5,4,3,1, | +| | | 0]`` | ++----------+----------+---------------+ +| Normaliz | unary | scales down | +| e | | the values in | +| | | the list to | +| | | the range | +| | | ``-1.0 .... 1 | +| | | .0`` | ++----------+----------+---------------+ +| Accumula | unary | see | +| ting | | ``itertools.a | +| Sum | | ccumulate`` | +| | | ``input = lis | +| | | t(accumulate( | +| | | range(10)))`` | +| | | ``output = [0 | +| | | , 1, 3, 6, 10 | +| | | , 15, 21, 28, | +| | | 36, 45]`` | ++----------+----------+---------------+ +| Mask | binary | generates a | +| Subset | | mask to | +| | | indicate for | +| | | each value in | +| | | A whether it | +| | | appears in B | +| | | \ ``A = [0,1, | +| | | 2,3,4,5,6,7]` | +| | | ` | +| | | ``B = [2,3,4, | +| | | 5]`` | +| | | ``output = [F | +| | | alse, False, | +| | | True, True, T | +| | | rue, True, Fa | +| | | lse, False]`` | ++----------+----------+---------------+ +| Intersec | binary | returns the | +| tion | | set of items | +| | | that appear | +| | | in both A and | +| | | B |image| | ++----------+----------+---------------+ +| Union | binary | returns the | +| | | set of items | +| | | A joined with | +| | | B \ |image| | ++----------+----------+---------------+ +| Differen | binary | returns the | +| ce | | set of items | +| | | from A that | +| | | don’t appear | +| | | in B |image| | ++----------+----------+---------------+ +| Symmetri | binary | returns the | +| c | | set of | +| Diff | | elements of A | +| | | and B that | +| | | don’t appear | +| | | in Both | +| | | |image| | ++----------+----------+---------------+ + +*output as list* + +The boolean switch to *output as list* will be on by default, +essentially it will wrap the output as a list because true sets don’t +have a defined order (which we do need most of the time). + +.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662881/733c219c-7f1c-11e6-85fc-fcfc1ea7768d.png +.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662921/a24aac7e-7f1c-11e6-80c1-684e513607a2.png +.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18663232/ec821d80-7f1d-11e6-83bc-3fd64ff037b4.png +.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662983/f252aeba-7f1c-11e6-963b-e2b7d7111e17.png + -- GitLab From c8db907d60a23ef4ff51907b2335d32a6bab7138 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:36:02 +0200 Subject: [PATCH 36/53] adjust content of list_modifier.rst --- docs/nodes/list_main/list_modifier.rst | 179 +++++++------------------ 1 file changed, 47 insertions(+), 132 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 95cdbf35d..22fdf070c 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -11,136 +11,52 @@ has both Unary and Binary modes. Behaviour ~~~~~~~~~ -+----------+----------+---------------+ -| Modes | inputs | Behaviour | -| | | Description | -+==========+==========+===============+ -| Set | unary | turns the | -| | | valid input | -| | | into a set | -| | | ``input = [0, | -| | | 0,0,1,1,1,3,3 | -| | | ,3,5,5,5,6,7, | -| | | 8,4,4,4,6,6,6 | -| | | ,7,7,7,8]`` | -| | | \ ``output = | -| | | [set(input)]` | -| | | ` | -+----------+----------+---------------+ -| Ordered | unary | only unique | -| Set by | | numbers but | -| input | | ordered by | -| | | the original | -| | | input | -| | | sequence | -| | | ``input = [0, | -| | | 0,0,1,1,1,3,3 | -| | | ,3,5,5,5,6,7, | -| | | 8,4,4,4,6,6,6 | -| | | ,7,7,7,8]`` | -| | | ``output = [0 | -| | | ,1,3,5,6,7,8, | -| | | 4]`` | -+----------+----------+---------------+ -| Unique | unary | no | -| Consecut | | consecutive | -| ives | | repeats | -| | | ``input = [0, | -| | | 0,0,1,1,1,3,3 | -| | | ,3,5,5,5,6,7, | -| | | 8,4,4,4,6,6,6 | -| | | ,7,7,7,8]`` | -| | | ``output = [0 | -| | | ,1,3,5,6,7,8, | -| | | 4,6,7,8]`` | -+----------+----------+---------------+ -| Sequenti | unary | unique input | -| al | | values, order | -| Set | | by their | -| | | value | -| | | ``input = [0, | -| | | 0,0,1,1,1,3,3 | -| | | ,3,5,5,5,6,7, | -| | | 8,4,4,4,6,6,6 | -| | | ,7,7,7,8]`` | -| | | ``output = [0 | -| | | ,1,3,4,5,6,7, | -| | | 8]`` | -+----------+----------+---------------+ -| Sequenti | unary | unique input | -| al | | values, order | -| Set Rev | | by their | -| | | value, | -| | | reversed | -| | | ``input = [0, | -| | | 0,0,1,1,1,3,3 | -| | | ,3,5,5,5,6,7, | -| | | 8,4,4,4,6,6,6 | -| | | ,7,7,7,8]`` | -| | | ``output = [8 | -| | | ,7,6,5,4,3,1, | -| | | 0]`` | -+----------+----------+---------------+ -| Normaliz | unary | scales down | -| e | | the values in | -| | | the list to | -| | | the range | -| | | ``-1.0 .... 1 | -| | | .0`` | -+----------+----------+---------------+ -| Accumula | unary | see | -| ting | | ``itertools.a | -| Sum | | ccumulate`` | -| | | ``input = lis | -| | | t(accumulate( | -| | | range(10)))`` | -| | | ``output = [0 | -| | | , 1, 3, 6, 10 | -| | | , 15, 21, 28, | -| | | 36, 45]`` | -+----------+----------+---------------+ -| Mask | binary | generates a | -| Subset | | mask to | -| | | indicate for | -| | | each value in | -| | | A whether it | -| | | appears in B | -| | | \ ``A = [0,1, | -| | | 2,3,4,5,6,7]` | -| | | ` | -| | | ``B = [2,3,4, | -| | | 5]`` | -| | | ``output = [F | -| | | alse, False, | -| | | True, True, T | -| | | rue, True, Fa | -| | | lse, False]`` | -+----------+----------+---------------+ -| Intersec | binary | returns the | -| tion | | set of items | -| | | that appear | -| | | in both A and | -| | | B |image| | -+----------+----------+---------------+ -| Union | binary | returns the | -| | | set of items | -| | | A joined with | -| | | B \ |image| | -+----------+----------+---------------+ -| Differen | binary | returns the | -| ce | | set of items | -| | | from A that | -| | | don’t appear | -| | | in B |image| | -+----------+----------+---------------+ -| Symmetri | binary | returns the | -| c | | set of | -| Diff | | elements of A | -| | | and B that | -| | | don’t appear | -| | | in Both | -| | | |image| | -+----------+----------+---------------+ ++----------------------+----------+--------------------------------------------------------------------------+ +| Modes | inputs | Behaviour Description | ++======================+==========+==========================================================================+ +| Set | unary | turns the valid input into a set | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [set(input)]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [0,1,3,5,6,7,8,4]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Unique Consecutives | unary | no consecutive repeats | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [0,1,3,5,6,7,8,4,6,7,8]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Sequential Set | unary | unique input values, ordered by their value | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [0,1,3,4,5,6,7,8]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Sequential Set Rev | unary | unique input values, ordered by their value, reversed | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [8,7,6,5,4,3,1,0]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Normalize | unary | scales down the values in the list to the range ``-1.0 .. 1.0`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Accumulating Sum | unary | see ``itertools.accumulate`` | +| | | ``input = list(accumulate(range(10)))`` | +| | | ``output = [0,1,3,6,10,15,21,28,36,45]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Mask Subset | binary | generates a mask to indicate for each value in A whether it appears in B | +| | | ``A = [0,1,2,3,4,5,6,7]`` | +| | | ``B = [2,3,4,5]`` | +| | | ``output = [False, False, True, True, True, True, False, False]`` | ++----------------------+----------+--------------------------------------------------------------------------+ +| Intersection | binary | returns the set of items that appear in both A and B | +| | | |image| | ++----------------------+----------+--------------------------------------------------------------------------+ +| Union | binary | returns the set of items A joined with B | +| | | |image| | ++----------------------+----------+--------------------------------------------------------------------------+ +| Difference | binary | returns the set of items from A that don’t appear in B | +| | | |image| | ++----------------------+----------+--------------------------------------------------------------------------+ +| Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both | +| | | |image| | ++----------------------+----------+--------------------------------------------------------------------------+ *output as list* @@ -151,5 +67,4 @@ have a defined order (which we do need most of the time). .. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662881/733c219c-7f1c-11e6-85fc-fcfc1ea7768d.png .. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662921/a24aac7e-7f1c-11e6-80c1-684e513607a2.png .. |image| image:: https://cloud.githubusercontent.com/assets/619340/18663232/ec821d80-7f1d-11e6-83bc-3fd64ff037b4.png -.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662983/f252aeba-7f1c-11e6-963b-e2b7d7111e17.png - +.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662983/f252aeba-7f1c-11e6-963b-e2b7d7111e17.png \ No newline at end of file -- GitLab From b9fb560a41ccdd19ca1e7fa9fb428836bad54297 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:37:05 +0200 Subject: [PATCH 37/53] adjust content of list_modifier.rst --- docs/nodes/list_main/list_modifier.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 22fdf070c..1b033f377 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -45,16 +45,16 @@ Behaviour | | | ``B = [2,3,4,5]`` | | | | ``output = [False, False, True, True, True, True, False, False]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Intersection | binary | returns the set of items that appear in both A and B | +| Intersection | binary | returns the set of items that appear in both A and B \ | | | | |image| | +----------------------+----------+--------------------------------------------------------------------------+ -| Union | binary | returns the set of items A joined with B | +| Union | binary | returns the set of items A joined with B \ | | | | |image| | +----------------------+----------+--------------------------------------------------------------------------+ -| Difference | binary | returns the set of items from A that don’t appear in B | +| Difference | binary | returns the set of items from A that don’t appear in B \ | | | | |image| | +----------------------+----------+--------------------------------------------------------------------------+ -| Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both | +| Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both \ | | | | |image| | +----------------------+----------+--------------------------------------------------------------------------+ -- GitLab From 474d728812eb75e03aeca709c06a078b3f0d35b0 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:43:00 +0200 Subject: [PATCH 38/53] adjust content of list_modifier.rst --- docs/nodes/list_main/list_modifier.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 1b033f377..a63bd23fd 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -46,7 +46,9 @@ Behaviour | | | ``output = [False, False, True, True, True, True, False, False]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Intersection | binary | returns the set of items that appear in both A and B \ | +| | | | | | | |image| | +| | | | +----------------------+----------+--------------------------------------------------------------------------+ | Union | binary | returns the set of items A joined with B \ | | | | |image| | -- GitLab From 9c6213f2646a9d1c9094e5b7d6cfe033d8efb57a Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:44:32 +0200 Subject: [PATCH 39/53] adjust content of list_modifier.rst 2 --- docs/nodes/list_main/list_modifier.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index a63bd23fd..31a3c57e2 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -15,7 +15,8 @@ Behaviour | Modes | inputs | Behaviour Description | +======================+==========+==========================================================================+ | Set | unary | turns the valid input into a set | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` \ | | | | ``output = [set(input)]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | @@ -51,13 +52,19 @@ Behaviour | | | | +----------------------+----------+--------------------------------------------------------------------------+ | Union | binary | returns the set of items A joined with B \ | +| | | | | | | |image| | +| | | | +----------------------+----------+--------------------------------------------------------------------------+ | Difference | binary | returns the set of items from A that don’t appear in B \ | +| | | | | | | |image| | +| | | | +----------------------+----------+--------------------------------------------------------------------------+ | Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both \ | +| | | | | | | |image| | +| | | | +----------------------+----------+--------------------------------------------------------------------------+ *output as list* -- GitLab From 7efa43438b3a743c54d743fe2aab3c6e69ead318 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:46:02 +0200 Subject: [PATCH 40/53] adjust content of list_modifier.rst 2 --- docs/nodes/list_main/list_modifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 31a3c57e2..51d38c99d 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -16,7 +16,7 @@ Behaviour +======================+==========+==========================================================================+ | Set | unary | turns the valid input into a set | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` \ | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | | | | ``output = [set(input)]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | -- GitLab From a0472ab8f8551f3cd177d5bc0c441b2ca23bf63a Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:49:49 +0200 Subject: [PATCH 41/53] adjust content of list_modifier.rst 3 --- docs/nodes/list_main/list_modifier.rst | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 51d38c99d..1a778ca0b 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -1,3 +1,8 @@ +.. |br| raw:: html + +
+ + List Modifier ~~~~~~~~~~~~~ @@ -14,13 +19,12 @@ Behaviour +----------------------+----------+--------------------------------------------------------------------------+ | Modes | inputs | Behaviour Description | +======================+==========+==========================================================================+ -| Set | unary | turns the valid input into a set | -| | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | -| | | ``output = [set(input)]`` | +| Set | unary | turns the valid input into a set |br| | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` |br| | +| | | ``output = [set(input)]`` |br| | +----------------------+----------+--------------------------------------------------------------------------+ -| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence |br| | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` |br| | | | | ``output = [0,1,3,5,6,7,8,4]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Unique Consecutives | unary | no consecutive repeats | -- GitLab From 73040db1b1a8a8427b080e624efe02411b64762d Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:51:11 +0200 Subject: [PATCH 42/53] adjust content of list_modifier.rst 4 --- docs/nodes/list_main/list_modifier.rst | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 1a778ca0b..1cb9e42ac 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -1,8 +1,3 @@ -.. |br| raw:: html - -
- - List Modifier ~~~~~~~~~~~~~ @@ -19,12 +14,12 @@ Behaviour +----------------------+----------+--------------------------------------------------------------------------+ | Modes | inputs | Behaviour Description | +======================+==========+==========================================================================+ -| Set | unary | turns the valid input into a set |br| | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` |br| | -| | | ``output = [set(input)]`` |br| | +| Set | unary | turns the valid input into a set | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | ``output = [set(input)]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence |br| | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` |br| | +| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | +| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | | | | ``output = [0,1,3,5,6,7,8,4]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Unique Consecutives | unary | no consecutive repeats | -- GitLab From 9984c62585b4a25af8f997ce4aae836721409d19 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 17:54:57 +0200 Subject: [PATCH 43/53] adjust content of list_modifier.rst 4 --- docs/nodes/list_main/list_modifier.rst | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 1cb9e42ac..ca1cb1caf 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -15,34 +15,49 @@ Behaviour | Modes | inputs | Behaviour Description | +======================+==========+==========================================================================+ | Set | unary | turns the valid input into a set | +| | | | | | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | | | | ``output = [set(input)]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | +| | | | | | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | | | | ``output = [0,1,3,5,6,7,8,4]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Unique Consecutives | unary | no consecutive repeats | +| | | | | | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | | | | ``output = [0,1,3,5,6,7,8,4,6,7,8]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Sequential Set | unary | unique input values, ordered by their value | +| | | | | | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | | | | ``output = [0,1,3,4,5,6,7,8]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Sequential Set Rev | unary | unique input values, ordered by their value, reversed | +| | | | | | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | | | | | ``output = [8,7,6,5,4,3,1,0]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Normalize | unary | scales down the values in the list to the range ``-1.0 .. 1.0`` | +----------------------+----------+--------------------------------------------------------------------------+ | Accumulating Sum | unary | see ``itertools.accumulate`` | +| | | | | | | ``input = list(accumulate(range(10)))`` | +| | | | | | | ``output = [0,1,3,6,10,15,21,28,36,45]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Mask Subset | binary | generates a mask to indicate for each value in A whether it appears in B | +| | | | | | | ``A = [0,1,2,3,4,5,6,7]`` | +| | | | | | | ``B = [2,3,4,5]`` | +| | | | | | | ``output = [False, False, True, True, True, True, False, False]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Intersection | binary | returns the set of items that appear in both A and B \ | -- GitLab From 6546d59f21ad758ce7161df38de7a39fd7f4a12b Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:05:00 +0200 Subject: [PATCH 44/53] adjust content of list_modifier.rst 4 --- docs/nodes/list_main/list_modifier.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index ca1cb1caf..bbb68c7ac 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -14,11 +14,11 @@ Behaviour +----------------------+----------+--------------------------------------------------------------------------+ | Modes | inputs | Behaviour Description | +======================+==========+==========================================================================+ -| Set | unary | turns the valid input into a set | +| Set | unary | turns the valid input into a set :: | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8] | +| | | output = [set(input)] | | | | | -| | | ``output = [set(input)]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | | | | | -- GitLab From da22947a8fac1d182e45176d10a817331ccfe0bf Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:09:59 +0200 Subject: [PATCH 45/53] adjust content of list_modifier.rst 4 --- docs/nodes/list_main/list_modifier.rst | 46 +++++++++++++------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index bbb68c7ac..fc02c9391 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -20,62 +20,62 @@ Behaviour | | | output = [set(input)] | | | | | +----------------------+----------+--------------------------------------------------------------------------+ -| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence | +| Ordered Set by input | unary | only unique numbers but ordered by the original input sequence :: | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8] | +| | | output = [0,1,3,5,6,7,8,4] | | | | | -| | | ``output = [0,1,3,5,6,7,8,4]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Unique Consecutives | unary | no consecutive repeats | +| Unique Consecutives | unary | no consecutive repeats :: | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8] | +| | | output = [0,1,3,5,6,7,8,4,6,7,8] | | | | | -| | | ``output = [0,1,3,5,6,7,8,4,6,7,8]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Sequential Set | unary | unique input values, ordered by their value | +| Sequential Set | unary | unique input values, ordered by their value :: | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8] | +| | | output = [0,1,3,4,5,6,7,8] | | | | | -| | | ``output = [0,1,3,4,5,6,7,8]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Sequential Set Rev | unary | unique input values, ordered by their value, reversed | +| Sequential Set Rev | unary | unique input values, ordered by their value, reversed :: | | | | | -| | | ``input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8]`` | +| | | input = [0,0,0,1,1,1,3,3,3,5,5,5,6,7,8,4,4,4,6,6,6,7,7,7,8] | +| | | output = [8,7,6,5,4,3,1,0] | | | | | -| | | ``output = [8,7,6,5,4,3,1,0]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Normalize | unary | scales down the values in the list to the range ``-1.0 .. 1.0`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Accumulating Sum | unary | see ``itertools.accumulate`` | +| Accumulating Sum | unary | see ``itertools.accumulate`` :: | | | | | -| | | ``input = list(accumulate(range(10)))`` | +| | | input = list(accumulate(range(10))) | +| | | output = [0,1,3,6,10,15,21,28,36,45] | | | | | -| | | ``output = [0,1,3,6,10,15,21,28,36,45]`` | +----------------------+----------+--------------------------------------------------------------------------+ | Mask Subset | binary | generates a mask to indicate for each value in A whether it appears in B | +| | | :: | | | | | -| | | ``A = [0,1,2,3,4,5,6,7]`` | -| | | | -| | | ``B = [2,3,4,5]`` | +| | | A = [0,1,2,3,4,5,6,7] | +| | | B = [2,3,4,5] | +| | | output = [False, False, True, True, True, True, False, False] | | | | | -| | | ``output = [False, False, True, True, True, True, False, False]`` | +----------------------+----------+--------------------------------------------------------------------------+ -| Intersection | binary | returns the set of items that appear in both A and B \ | +| Intersection | binary | returns the set of items that appear in both A and B | | | | | | | | |image| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ -| Union | binary | returns the set of items A joined with B \ | +| Union | binary | returns the set of items A joined with B | | | | | | | | |image| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ -| Difference | binary | returns the set of items from A that don’t appear in B \ | +| Difference | binary | returns the set of items from A that don’t appear in B | | | | | | | | |image| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ -| Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both \ | +| Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both | | | | | | | | |image| | | | | | -- GitLab From 3a94b6bcfbf364993ba9298dcebabd2baee5b8fa Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:12:38 +0200 Subject: [PATCH 46/53] adjust content of list_modifier.rst 5 --- docs/nodes/list_main/list_modifier.rst | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index fc02c9391..4393bdb05 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -1,12 +1,10 @@ List Modifier ~~~~~~~~~~~~~ -This node offers an assortment of list modification functions. The node -has both Unary and Binary modes. +This node offers an assortment of list modification functions. The node has both Unary and Binary modes. -- In Unary mode the input socket is the linked one -- if data1 isn’t linked then data2 is used as the input if it is linked -- if both are linked data1 is used. +- In Unary mode it will use the input of either sockets, it will use data1 first, then check data2 +- If both are linked data1 is used. Behaviour ~~~~~~~~~ -- GitLab From 0bb00360b021abc00807bd70239699addafa0c0f Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:14:35 +0200 Subject: [PATCH 47/53] adjust content of list_modifier.rst 5 --- docs/nodes/list_main/list_modifier.rst | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 4393bdb05..cc3854ee8 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -60,22 +60,22 @@ Behaviour +----------------------+----------+--------------------------------------------------------------------------+ | Intersection | binary | returns the set of items that appear in both A and B | | | | | -| | | |image| | +| | | |image1| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ | Union | binary | returns the set of items A joined with B | | | | | -| | | |image| | +| | | |image2| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ | Difference | binary | returns the set of items from A that don’t appear in B | | | | | -| | | |image| | +| | | |image3| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ | Symmetric Diff | binary | returns the set of elements of A and B that don’t appear in Both | | | | | -| | | |image| | +| | | |image4| | | | | | +----------------------+----------+--------------------------------------------------------------------------+ @@ -85,7 +85,7 @@ The boolean switch to *output as list* will be on by default, essentially it will wrap the output as a list because true sets don’t have a defined order (which we do need most of the time). -.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662881/733c219c-7f1c-11e6-85fc-fcfc1ea7768d.png -.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662921/a24aac7e-7f1c-11e6-80c1-684e513607a2.png -.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18663232/ec821d80-7f1d-11e6-83bc-3fd64ff037b4.png -.. |image| image:: https://cloud.githubusercontent.com/assets/619340/18662983/f252aeba-7f1c-11e6-963b-e2b7d7111e17.png \ No newline at end of file +.. |image1| image:: https://cloud.githubusercontent.com/assets/619340/18662881/733c219c-7f1c-11e6-85fc-fcfc1ea7768d.png +.. |image2| image:: https://cloud.githubusercontent.com/assets/619340/18662921/a24aac7e-7f1c-11e6-80c1-684e513607a2.png +.. |image3| image:: https://cloud.githubusercontent.com/assets/619340/18663232/ec821d80-7f1d-11e6-83bc-3fd64ff037b4.png +.. |image4| image:: https://cloud.githubusercontent.com/assets/619340/18662983/f252aeba-7f1c-11e6-963b-e2b7d7111e17.png \ No newline at end of file -- GitLab From a3b60788568ed356460df3c9b15c843813497b6f Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:29:21 +0200 Subject: [PATCH 48/53] adjust content of list_modifier.rst 6 --- docs/nodes/list_main/list_modifier.rst | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index cc3854ee8..582ad9e3e 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -85,6 +85,15 @@ The boolean switch to *output as list* will be on by default, essentially it will wrap the output as a list because true sets don’t have a defined order (which we do need most of the time). +Example +------- + +See the pullrequest for details : https://github.com/nortikin/sverchok/pull/884 + +also see the original thread : https://github.com/nortikin/sverchok/issues/865 + + + .. |image1| image:: https://cloud.githubusercontent.com/assets/619340/18662881/733c219c-7f1c-11e6-85fc-fcfc1ea7768d.png .. |image2| image:: https://cloud.githubusercontent.com/assets/619340/18662921/a24aac7e-7f1c-11e6-80c1-684e513607a2.png .. |image3| image:: https://cloud.githubusercontent.com/assets/619340/18663232/ec821d80-7f1d-11e6-83bc-3fd64ff037b4.png -- GitLab From 11c4420b5b573468b02aed8def2b5bf232c5d657 Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:31:07 +0200 Subject: [PATCH 49/53] adjust content of list_modifier.rst 7 --- docs/nodes/list_main/list_modifier.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index 582ad9e3e..dae53f297 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -5,6 +5,7 @@ This node offers an assortment of list modification functions. The node has both - In Unary mode it will use the input of either sockets, it will use data1 first, then check data2 - If both are linked data1 is used. +- The node will draw the name of the current mode into the node header, useful for minized nodes. Behaviour ~~~~~~~~~ -- GitLab From bcc78cdc96b9988bc2b64fb82f197158f27455ef Mon Sep 17 00:00:00 2001 From: zeffii Date: Tue, 20 Sep 2016 18:46:37 +0200 Subject: [PATCH 50/53] fix typo in rst --- docs/nodes/list_main/list_modifier.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/nodes/list_main/list_modifier.rst b/docs/nodes/list_main/list_modifier.rst index dae53f297..d381b74a2 100644 --- a/docs/nodes/list_main/list_modifier.rst +++ b/docs/nodes/list_main/list_modifier.rst @@ -5,7 +5,7 @@ This node offers an assortment of list modification functions. The node has both - In Unary mode it will use the input of either sockets, it will use data1 first, then check data2 - If both are linked data1 is used. -- The node will draw the name of the current mode into the node header, useful for minized nodes. +- The node will draw the name of the current mode into the node header, useful for minimized nodes. Behaviour ~~~~~~~~~ -- GitLab From 8417013dc292f95a05345139427477353e799bdd Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 21 Sep 2016 11:08:38 +0200 Subject: [PATCH 51/53] sanitize get_f --- nodes/list_basic/modifier.py | 56 ++++++++++++++---------------------- 1 file changed, 22 insertions(+), 34 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 2e2f5e1db..a1214177a 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -82,38 +82,6 @@ func_dict = {k: v for _, _, k, v in node_item_list} num_inputs = {k: v for v, _, k, _ in node_item_list} -def get_f(self, operation, unary): - makes_lists = self.listify - - if unary: - if self.func_ in SET_OPS and makes_lists: - def f(d): - if isinstance(d[0], (int, float)): - return list(operation(d)) - else: - return [f(x) for x in d] - else: - def f(d): - if isinstance(d[0], (int, float)): - return operation(d) - else: - return [f(x) for x in d] - else: - if self.func_ in SET_OPS and makes_lists: - def f(a, b): - if isinstance(a[0], (int, float)): - return list(operation(a, b)) - else: - return [f(*_) for _ in zip(a, b)] - else: - def f(a, b): - if isinstance(a[0], (int, float)): - return operation(a, b) - else: - return [f(*_) for _ in zip(a, b)] - - return f - class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): ''' List Modifier''' bl_idname = 'SvListModifierNode' @@ -155,9 +123,8 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): if not outputs[0].is_linked: return - operation = func_dict[self.func_] unary = (num_inputs[self.func_] == 1) - f = get_f(self, operation, unary) + f = self.get_f(unary) if unary: if inputs['Data1'].is_linked: @@ -174,6 +141,27 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): outputs[0].sv_set(out) + def get_f(self, unary): + operation = func_dict[self.func_] + + do_post = (self.func_ in SET_OPS) and self.listify + post_process = list if do_post else lambda x: x # identity function + + if unary: + def f(d): + if isinstance(d[0], (int, float)): + return post_process(operation(d)) + else: + return [f(x) for x in d] + else: + def f(a, b): + if isinstance(a[0], (int, float)): + return post_process(operation(a, b)) + else: + return [f(*_) for _ in zip(a, b)] + + return f + def register(): bpy.utils.register_class(SvListModifierNode) -- GitLab From 75fa478d2d86c1528dc64c271684f8e787a39a18 Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 21 Sep 2016 12:04:54 +0200 Subject: [PATCH 52/53] add match_long_repeat stub --- nodes/list_basic/modifier.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index a1214177a..4a1c4438b 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -138,6 +138,8 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): data1 = inputs['Data1'].sv_get() data2 = inputs['Data2'].sv_get() out = f(data1, data2) + # param = match_long_repeat([data1, data2]) + # out = f(*param) outputs[0].sv_set(out) -- GitLab From c6e4c6e0399bc49cb0d8606f71cefc77f0c0bc5f Mon Sep 17 00:00:00 2001 From: zeffii Date: Wed, 21 Sep 2016 12:08:08 +0200 Subject: [PATCH 53/53] add match_long_repeat stub 2 --- nodes/list_basic/modifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nodes/list_basic/modifier.py b/nodes/list_basic/modifier.py index 4a1c4438b..0a1af8e07 100644 --- a/nodes/list_basic/modifier.py +++ b/nodes/list_basic/modifier.py @@ -138,8 +138,8 @@ class SvListModifierNode(bpy.types.Node, SverchCustomTreeNode): data1 = inputs['Data1'].sv_get() data2 = inputs['Data2'].sv_get() out = f(data1, data2) - # param = match_long_repeat([data1, data2]) - # out = f(*param) + # params = match_long_repeat([data1, data2]) + # out = f(*params) outputs[0].sv_set(out) -- GitLab