Need insights understanding component output

Hi,

I’m fairly new to GH and I could use some help trying to understand what components do internally.
I thought I understood the main concepts like data trees, and what flattening / grafting / etc. so, but I have no explanation for results like this:

Could definitely use some pointers here :folded_hands:

unnamed.ghx (60.1 KB)

Hi Component Confusion,

Here is the best place to start with data trees..

I have read / watched a bunch of things about data trees already, but nothing that explains the output shown in my screenshot.

More concretely then:

  1. Why does the “Addition” component remove null values? And why not all of them? (Only trailing ones, it seems)
  2. Why does the output of the “Flatten” flag on the component not result in a simple list ({0}), but has this empty this empty {2;1;4;2} branch? Makes no sense to me.
  3. Why do the outputs of the “Flatten” flag and the “Flatten Tree” component differ? I would assume under the hood the same code is used? Or is it not?

at a glance it looks like data tree management.

Its always recommended that you post files, its quicker if we don’t have to recreate the file. Thanks

Added the file to the original post up top.

now you have me confused, why you adding text? The addition component does take various data types (vectors, ..) but text is not one of them.

It’s because only your top line in the panel starts with text (aaa), the others don’t:
unnamed.ghx (144.9 KB)

Just for illustration purposes (you can streamline it a bit more):


@component_confusion,
Maybe you skipped reading about inputs :winking_face_with_tongue:

Why strings? – Because I can :wink:
No red lines + no runtime errors tells me: it’s allowed.

I’m not trying to solve a real-world problem here (yet). – I want to understand GH’s internal logic in general (including quirks and edge cases), as I might need to implement custom components at some point that behave exactly like the native ones.

Most of the documentation that’s available is lacking / too simplistic IMHO; and with GH being closed source, observing the inputs and outputs of a black box is all we can do.

So it seems like the Addition component removes trailing null values from the output. Why does it do that? Unclear.

Also, if flattening is documented as “Flattens the entire structure into a single path” ( GH_Structure(T).Flatten Method ), then why am I able to produce results with more than one path? Unclear.

Are these just bugs or is this intended behavior?
If intended: Are there any resources I am not aware of where this is documented?


@René_Corella Anything in particular I should read w.r.t. inputs? Sounds like I may have overlooked something.

Grasshopper has been around a while, there is a lot of documentation as well as examples, but even in this late part of cycle there are plenty of quirks & edge cases you will need to ask the forum about.

Here’s something that will help on inputs, if you hover over them and get the tooltip the icon gives you the expected data type, in this case its a circle.

The addition components accept Generic Data, this allows for flexibility, but components with this input may have limitations.. like doing math functions on text.

If you want to get in early, GH2(alpha) is a complete re-write

The indication from @Japhy (hovering over things) will do?
I’m not good at explaining :stuck_out_tongue:
However, perhaps similarly (?), feeding your data containing text+numbers to a number component (expects numbers), you’ll ‘nullify’ in the ‘expected’ order without having to add:

Does it? Who knows—I wouldn’t be the one qualified to answer why/how the addition component (or any other component) decides to annul data relative (or not relative) to the order they come in. My reply was purely intuitive (also empirical, ha!) and I can see how your expectation(s) could have been as well. It’s great we can ask here!

Best,
RC

Adding strings together is not strange, but you could interpret this operation differently. What’s definitely strange is to expect that some values plus null is null. Null is not 0 or nothing. It means a (nullable) value or reference pointer is not set. It should throw an exception here, but GH1 was designed not to this. This has side-effects. Its opinionated, but you should not give too much meaning to this. It depends how the developer felt when it was written. Sometimes it will skip an operation or it returns an unexpected value or it return null again. There is no deeper logic in it