def _ascii_encode(inarray, out=None):
 out_dtype = np.dtype(('S{0}'.format((inarray.dtype.itemsize // 4)), inarray.dtype.shape))
 if (out is not None):
  out = out.view(out_dtype)
 op_dtypes = [inarray.dtype, out_dtype]
 op_flags = [['readonly'], ['writeonly', 'allocate']]
 it = np.nditer([inarray, out], op_dtypes=op_dtypes, op_flags=op_flags, flags=['zerosize_ok'])
 try:
  for (initem, outitem) in it:
   outitem[...] = initem.item().encode('ascii')
 except UnicodeEncodeError as exc:
  index = np.unravel_index(it.iterindex, inarray.shape)
  raise _UnicodeArrayEncodeError(*(exc.args + (index,)))
 return it.operands[1]

def _ascii_encode ( inarray , out = None ) : out_dtype = np . dtype ( ( 'S{0}' . format ( ( inarray . dtype . itemsize // 4 ) ) , inarray . dtype . shape ) ) if ( out is not None ) : out = out . view ( out_dtype ) op_dtypes = [ inarray . dtype , out_dtype ] op_flags = [ [ 'readonly' ] , [ 'writeonly' , 'allocate' ] ] it = np . nditer ( [ inarray , out ] , op_dtypes = op_dtypes , op_flags = op_flags , flags = [ 'zerosize_ok' ] ) try : for ( initem , outitem ) in it : outitem [ ... ] = initem . item ( ) . encode ( 'ascii' ) except UnicodeEncodeError as exc : index = np . unravel_index ( it . iterindex , inarray . shape ) raise _UnicodeArrayEncodeError ( * ( exc . args + ( index , ) ) ) return it . operands [ 1 ]
takes a unicode array and fills the output string array with the ascii encodings of the elements of the input array .