MahmoudAbdelRahman / GH_CPython

CPython plugin for Rhino-Grasshopper
BSD 2-Clause "Simplified" License
175 stars 38 forks source link

Is it possible to input a numpy matrix? #33

Open XiaomingY opened 5 years ago

XiaomingY commented 5 years ago

Hi,

Is it possible to input a numpy matrix and use numpy.asmatrix to cast input as numpy matrix? What I am trying to do it use one CPython component to read a big binary file as matrix then use the second CPython component to get information out of the matrix. By using two component, i think I could avoid the slow process of reading the file every time a variable changes.

Another question is how to input a file path? Can you give an example? I tried a couple of ways but did not manage to get it to work. Many thanks.

MahmoudAbdelRahman commented 4 years ago

I suggest that you interchange numpy matrices between different components using numpy.dumps(the_np_array) and read it from the other component as numpy.loads(the_dumps_array)

https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.ndarray.dumps.html