خرید بک لینک

Vote count: 0

I have a numpy array with a nested dtype:

dt = np.dtype([('e', '<f8'), ('n', '<i8'), ('pos', '<f8', (3,))])
arr = np.zeros(5, dtype=dt)

array([(0.0, 0, [0.0, 0.0, 0.0]), (0.0, 0, [0.0, 0.0, 0.0]),
       (0.0, 0, [0.0, 0.0, 0.0]), (0.0, 0, [0.0, 0.0, 0.0]),
       (0.0, 0, [0.0, 0.0, 0.0])],
      dtype=[('e', '<f8'), ('n', '<i8'), ('pos', '<f8', (3,))])

and I'm trying to fill the entire array with np.nan:

arr[:] = np.nan

However, this does not work as expected:

array([(nan, -9223372036854775808, [nan, nan, nan]),
       (nan, -9223372036854775808, [nan, nan, nan]),
       (nan, -9223372036854775808, [nan, nan, nan]),
       (nan, -9223372036854775808, [nan, nan, nan]),
       (nan, -9223372036854775808, [nan, nan, nan])],
      dtype=[('e', '<f8'), ('n', '<i8'), ('pos', '<f8', (3,))])

The second column here is obviously not nan.

Any idea how I can work around this issue?

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 21 خرداد 1395 ساعت: 22:22

صفحه بندی