def write_png(filename, data):
 data = np.asarray(data)
 if ((not (data.ndim == 3)) and (data.shape[(-1)] in (3, 4))):
  raise ValueError('data must be a 3D array with last dimension 3 or 4')
 with open(filename, 'wb') as f:
  f.write(_make_png(data))

def write_png ( filename , data ) : data = np . asarray ( data ) if ( ( not ( data . ndim == 3 ) ) and ( data . shape [ ( - 1 ) ] in ( 3 , 4 ) ) ) : raise ValueError ( 'data must be a 3D array with last dimension 3 or 4' ) with open ( filename , 'wb' ) as f : f . write ( _make_png ( data ) )
write a png file unlike imsave .