tag:support.nodebox.net,2012-11-01:/discussions/nodebox-2-3/5421-failure-to-understand-sub-networksNodeBox: Discussion 2017-04-14T01:41:03Ztag:support.nodebox.net,2012-11-01:Comment/362628582015-03-13T22:44:15Z2015-03-13T22:44:15ZFailure to Understand sub-networks<div><p>Rory,</p>
<p>I'm really glad you asked this question. This is the the number
one most confusing, counterintuitive behavior in NodeBox I've
encountered, and the tutorial on subnetworks makes no mention of
it. I will share what I've puzzled out so far, but I hope someone
from the NodeBox staff will give a more clear answer.</p>
<p>Like you, my intuition is that simply encapsulating a group of
nodes into a subnetwork should not change its behavior, but about
25% of the time it does. This behavior is tied to another poorly
documented and well hidden feature: the port range setting inside
the metadata dialog. Here is a magic trick it took me many painful
weeks to discover...</p>
<p>I recreated your example: an import_csv node hooked to a lookup
node hooked to a slice node. The lookup node returns an 8-item list
and the slice reduces that to 4 items. So far so good.</p>
<p>I simply group the lookup and slice into a two-node subnetwork
and surprise! Now I have 8 rows again as if the slice is not even
there any more. Very strange.</p>
<p>Here is the magic trick. Select your crippled subnetwork and
click the Metadata button on top of the port pane. On the left you
will see that your node has a single input port: list; click
"list". A bunch of settings should now appear in the right half of
the dialog. The fifth from the top, "Range", is set to "Value".
Change it to "List" and Hit OK.</p>
<p>Voila! Problem solved.</p>
<p>For some reason (which I'm sure Frederik can explain), you need
to tell your new subnetwork to accept a list, not a value. This
seems odd to me given that the original Lookup node has, and still
has, its list node set to Value. In fact, if you change the
Lookup's list node to "List", before or after encapsulating it, it
will stop working altogether. You have to change the network node
metadata, not the nodes inside it. Why Value works for the Lookup
but not for the network I do not understand.</p>
<p>I have struggled with this but still do not fully grasp the
difference between List and Value, and when you need to change it.
A brief explanation of that would be a huge help to all of us
struggling apprentice NodeBoxxers.</p>
<p>John</p></div>johntag:support.nodebox.net,2012-11-01:Comment/362628582015-03-18T16:32:45Z2015-03-18T16:32:45ZFailure to Understand sub-networks<div><p>Hello all,<br>
when you send a list to a subnetwork the subnetwork will do it's
function for every item of that list. So it will generate always as
many items as it is getting. A list will be treated on a one per
one base, hence slicing it will return one item for every item
since you are slicing a one item list every time.<br>
Now if you do not want this, i.e. you want your list to be treated
as one item (containing a list of items for later slicing) you go
to the metadata settings of your csv file and set the output to
Value. Now your subnetwork will receive a Value (being a list!) and
hence will return any slicing as expected since it is slicing a
real list and not an item of a list. This way you can feed a
subnetwork eventually with many lists (all considered as 1 item)
and your subnetwork can treat them like that. I agree it may sound
confusing, I struggled with it too...<br>
It also means that if you need the content of your csv file for
other purposes you may have to import it a second time in another
node where you leave the output to List.<br>
regards,</p>
<p>Lucas</p></div>lucasnijstag:support.nodebox.net,2012-11-01:Comment/362628582015-03-19T07:43:01Z2015-03-19T07:43:01ZFailure to Understand sub-networks<div><p>Thanks John and Lucas,</p>
<p>This is very useful. I think the List and Value system needs to
be explained further, and how to control them needs to be clear. I
encounter a problem in lack of understanding not just in relation
to sub-networks, but also in relation to custom nodes. It is often
much simpler to write my own python code to do stuff with data etc.
rather than using a complex set of lookup nodes, and list indexing
etc. becomes tricky when the arguments the function receives seems
to change when grouped and so on.</p>
<p>Thanks for your help</p></div>Rory Creedontag:support.nodebox.net,2012-11-01:Comment/362628582015-03-19T09:36:08Z2015-03-19T09:36:10ZFailure to Understand sub-networks<div><p>Incidentally I just tried John's solution and it worked a charm.
I think Lucas' one must also be correct, but presumably if it can
be avoided then it should be, as using the same cvs data may then
be tricky.</p></div>Rory Creedontag:support.nodebox.net,2012-11-01:Comment/362628582015-06-08T06:48:10Z2015-06-08T06:48:10ZFailure to Understand sub-networks<div><p>Even after this discussion I still found subnetworks confusing
and have been tossing and turning ever since. I finally used a
simple example to explore and explain the way they work in some
detail.</p>
<p>See the follow up note to my June 7, 2015 post on "Drop First
Column" in the "Show Your Work" forum.</p></div>john