Hops - Data Trees, Arrays and 4d+ datatypes

Hi,

I’m looking to export data from Grasshopper via Hops, to use sklearn’s clustering functionality. This is all fairly straight forward for up to data structures up to 3 dimensions, as the HopsPoint can be used to handle the input.

However, I would like to be able to cluster data structure of 4 dimensions and above. The obvious way to do this would be to wrap the data in a datatree and convert it to a numpy array on the server-side, but there doesn’t look to be hops object that handles datatrees. Is there a solution? I’d like to keep the n-dimensions dynamic on the client side, so one input would be preferable.

I think you might have missed the “ParamAccess.tree” argument when declaring the input (?) I could be misunderstanding your question.

inputs=[
        hs.HopsNumber("nDimension", "nD", "as many number in branch", hs.HopsParamAccess.TREE),
    ],

You get your data as a list of lists if I remember correctly.

Thanks Antoine - just to follow up and close this out:

hs.HopsParamAccess.TREE returns a dictionary, with Branch Index:List representing the key:value pairs. To convert to an array you need to run:

x = list(x.values())

image

1 Like

Well, strictly a 2D list…