gdsfactory / kfactory

gdsfactory with a klayout backend
https://gdsfactory.github.io/kfactory/
MIT License
31 stars 12 forks source link

support numpy values as inputs #223

Closed joamatab closed 11 months ago

joamatab commented 11 months ago

how can we support numpy arrays as cell inputs?

sebastian-goeldi commented 11 months ago

long story short: I don´t think we should just allow anything as input into the cell. convert it to something that is hashable. if you ask for numpy arrays, the next guy will ask for dataframes. How are you handling it in gdsfactory?

tl;dr give it something hashable or one of the types that are autoconverted ;)

joamatab commented 11 months ago

I see, it's a bit of an edge case, we wrote custom serializers in gdsfactory but it's a pain to maintain :)

sebastian-goeldi commented 11 months ago

yeah, I agree. The reason I also push back hard on this: if you ever pass numpy values to any klayout objects, they will complain with a cryptic error message

>>> import klayout.db as kdb
>>> import numpy as np
>>> 
>>> kdb.Trans(1,1)
r0 1,1
>>> kdb.Trans(np.int64(1),1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: No overload with matching arguments in Trans.__init__