I was working through the Essential Algorithms and Data Structures for grasshopper and had a question about some unexpected behavior re: split tree mask syntax.
Under section 3.6.2 Split trees, it says "Use square brackets to enclose the mask for the elements (leaves). Can be omitted if select all items or use []" However, Split Tree is emitting different output depending on whether or not I include or omit []. as seen in the attached grasshopper file:
This would lead me to believe that [*] is not, in fact, optional if you want to be able to merge everything back together later via Combine Data. Is this behavior expected or is the documentation incorrect?
You misunderstand. The square brackets can be omitted if no specification to item selection is being made. Asterisk can only be used to specify any number of integer in a path. (Really, it’s a wildcard)
I guess what I’m not understanding is the difference between {0 to 2} as a mask vs {0 to 2}[*]. Could somebody please explain the difference between the two masks?
It was my understanding that the square bracket notation was for indicies of elements rather than paths, so I don’t understand why the number of branches selected by the mask are different - in the former case, only the branches that contain at least 1 non-null value are selected, while in the latter case, all branches are selected, even if they contain only nulls.
to be honest I was not aware of this subtle difference! and it looks interesting as it seems like it allows you to use different methods to reinstate the original data tree back, depending on your needs:
by not using square brackets (case on top) the tree is literally split in two, so you need to use Merge to rebuild it back
while by specifying [*] you get a result similar to a Sift, where for each element if you get the element itself in an input you’ll get a Null placeholder on the other one
I’d maybe call this a beneficial added functionality that maybe was not introduced yet when the text you are studying on was written?
my assumption was very much NOT the case, as that was written by none other than Rajaa Issa
I think the explanatory table at the very beginning of the Split Tree chapter could be improved a lot it should show something like:
the possibility of using squared brackets inside curly brackets (in which case the filter inside squared bracket referes to paths)
the possibility of using squared brackets after curly brackets (in which case the filter after curly brackets refers to items)
state that in all the cases where squared brackets are used after curly brackets, then the positive/negative outputs will be filled with Nulls to easily be combined back together with Combine Data (like the output of a Sift component)
It would seem excluding the square brackets or including them without anything written in between them is a shortcut for branch selection, while specifying index selection creates a null tree with the values matching the mask replaced.
I wrote something before, but it was incorrect. I dunno. Split Tree is a hot mess. I find that there isn’t anything you can do with it that you couldn’t with the baser components of the Tree panel.