Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.26 KB | None | 0 0
  1. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b')
  2. array([[[0, 4],
  3. [2, 6]],
  4. [[1, 5],
  5. [3, 7]]], dtype=int8)
  6. >>> ctypes.string_at(np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b').ctypes.data, 8) # .data.tobytes() doesn't work properly
  7. b'\x00\x04\x02\x06\x01\x05\x03\x07'
  8. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b').__array_interface__
  9. {'data': (23426096, False), 'strides': None, 'descr': [('', '|i1')], 'typestr': '|i1', 'shape': (2, 2, 2), 'version': 3}
  10. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b').flags
  11. C_CONTIGUOUS : True
  12. F_CONTIGUOUS : False
  13. OWNDATA : True
  14. WRITEABLE : True
  15. ALIGNED : True
  16. WRITEBACKIFCOPY : False
  17. UPDATEIFCOPY : False
  18.  
  19. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F')
  20. array([[[0, 4],
  21. [2, 6]],
  22. [[1, 5],
  23. [3, 7]]], dtype=int8)
  24. >>> ctypes.string_at(np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').ctypes.data, 8)
  25. b'\x00\x01\x02\x03\x04\x05\x06\x07'
  26. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').__array_interface__
  27. {'data': (23304720, False), 'strides': (1, 2, 4), 'descr': [('', '|i1')], 'typestr': '|i1', 'shape': (2, 2, 2), 'version': 3}
  28. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').flags
  29. C_CONTIGUOUS : False
  30. F_CONTIGUOUS : True # `order` does not configure it directly; it is just computed from the current shape and strides
  31. OWNDATA : True
  32. WRITEABLE : True
  33. ALIGNED : True
  34. WRITEBACKIFCOPY : False
  35. UPDATEIFCOPY : False
  36.  
  37. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').T
  38. array([[[0, 1],
  39. [2, 3]],
  40.  
  41. [[4, 5],
  42. [6, 7]]], dtype=int8)
  43. >>> ctypes.string_at(np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').T.ctypes.data, 8)
  44. b'\x00\x01\x02\x03\x04\x05\x06\x07'
  45. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').T.__array_interface__
  46. {'data': (23426096, False), 'strides': None, 'descr': [('', '|i1')], 'typestr': '|i1', 'shape': (2, 2, 2), 'version': 3}
  47. >>> np.array([[[0, 4], [2, 6]], [[1, 5], [3, 7]]], dtype='b', order='F').T.flags
  48. C_CONTIGUOUS : True
  49. F_CONTIGUOUS : False
  50. OWNDATA : False
  51. WRITEABLE : True
  52. ALIGNED : True
  53. WRITEBACKIFCOPY : False
  54. UPDATEIFCOPY : False
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement