def slice2gridspec(key):
 if ((len(key) != 2) or (not isinstance(key[0], slice)) or (not isinstance(key[1], slice))):
  raise ValueError('only 2-D slices, please')
 x0 = key[1].start
 x1 = key[1].stop
 xstep = key[1].step
 if ((not isinstance(xstep, complex)) or (int(xstep.real) != xstep.real)):
  raise ValueError('only the [start:stop:numsteps*1j] form supported')
 xstep = int(xstep.imag)
 y0 = key[0].start
 y1 = key[0].stop
 ystep = key[0].step
 if ((not isinstance(ystep, complex)) or (int(ystep.real) != ystep.real)):
  raise ValueError('only the [start:stop:numsteps*1j] form supported')
 ystep = int(ystep.imag)
 return (x0, x1, xstep, y0, y1, ystep)

def slice2gridspec ( key ) : if ( ( len ( key ) != 2 ) or ( not isinstance ( key [ 0 ] , slice ) ) or ( not isinstance ( key [ 1 ] , slice ) ) ) : raise ValueError ( 'only 2-D slices, please' ) x0 = key [ 1 ] . start x1 = key [ 1 ] . stop xstep = key [ 1 ] . step if ( ( not isinstance ( xstep , complex ) ) or ( int ( xstep . real ) != xstep . real ) ) : raise ValueError ( 'only the [start:stop:numsteps*1j] form supported' ) xstep = int ( xstep . imag ) y0 = key [ 0 ] . start y1 = key [ 0 ] . stop ystep = key [ 0 ] . step if ( ( not isinstance ( ystep , complex ) ) or ( int ( ystep . real ) != ystep . real ) ) : raise ValueError ( 'only the [start:stop:numsteps*1j] form supported' ) ystep = int ( ystep . imag ) return ( x0 , x1 , xstep , y0 , y1 , ystep )
convert a 2-tuple of slices to start .