You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I’m creating a 3d graphics app where there are a lot of datatypes.
This is a single class containing a lot of them.
class Part(NamedTuple):
id:int
#todo: refactor to names
points:jnp.ndarray = jnp.array((1,3),jnp.float16) # point3d
lines:jnp.ndarray=jnp.array((1,6),jnp.float16) # Line3d
faces:jnp.ndarray=jnp.array((1,13),jnp.float16)
nurbs:jnp.ndarray=jnp.array((1,9),jnp.float16)# --
curves:jnp.ndarray=jnp.array((1,9),jnp.float16)# Curve3d
It’s a lot of small ndarrays.
For example, lines, is an ndarray that has a shape of (1,6). So there will be (many) lines with 6 values, first three are a coordinate, second is a vector.
When I use them in code, and data gets more complicated, with such datatypes I would have to use formulas as (face.at[0:2]*line.at[3:6]+face.at[6])/[face.at[3:5]*line[0:2])
Which is not nice at all.
And okay, you might say that I can split the line tensor to be of shape [2,3]. but what about faceswhich has 13 values?
I would like to label the exact strips of data in tensors to avoid dozens of magic numbers. So, a 0-2 range would callable with point, 3-5 with vector, 6 with distance and so on. Is it possible to do?
Cheers.
: it's working from the assumption that ndarrays can't store NamedTuple, even though they consist of a homogenous type. At least, chatGPT has told me so. Is it so? If yes, how to workaround? Using lists? But that makes jax terribly slow then...
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Sup Jax, and JakeVdp,
I’m creating a 3d graphics app where there are a lot of datatypes.
This is a single class containing a lot of them.
It’s a lot of small ndarrays.
For example,
lines
, is an ndarray that has a shape of (1,6). So there will be (many) lines with 6 values, first three are a coordinate, second is a vector.When I use them in code, and data gets more complicated, with such datatypes I would have to use formulas as
(face.at[0:2]*line.at[3:6]+face.at[6])/[face.at[3:5]*line[0:2])
Which is not nice at all.
And okay, you might say that I can split the
line
tensor to be of shape [2,3]. but what aboutfaces
which has 13 values?I would like to label the exact strips of data in tensors to avoid dozens of magic numbers. So, a 0-2 range would callable with
point
, 3-5 withvector
, 6 withdistance
and so on. Is it possible to do?Cheers.
: it's working from the assumption that ndarrays can't store NamedTuple, even though they consist of a homogenous type. At least, chatGPT has told me so. Is it so? If yes, how to workaround? Using lists? But that makes jax terribly slow then...
Beta Was this translation helpful? Give feedback.
All reactions