docs: def serialize_numpy(m, t):
      '''
      serialize_numpy(m, type) converts the numpy array m into a byte stream that can be read by the
      nben.util.Py4j Java class. The function assumes that the type of the array needn't be encoded
      in the bytearray itself. The bytearray will begin with an integer, the number of dimensions,
      followed by that number of integers (the dimension sizes themselves) then the bytes of the
      array, flattened.
      The argument type gives the type of the array to be transferred and must be 'i' for integer or
      'd' for double (or any other string accepted by array.array()).
      '''
      # Start with the header: <number of dimensions> <dim1-size> <dim2-size> ...
      header = array('i', [len(m.shape)] + list(m.shape))
      # Now, we can do the array itself, just flattened
      body = array(t, m.flatten().tolist())
      # Wrap bytes if necessary...
      if sys.byteorder != 'big':
          header.byteswap()
          body.byteswap()
      # And return the result:
      return bytearray(header.tostring() + body.tostring())