def slice2gridspec(key):
if ((len(key) != <NUM_LIT:2>) or<EOL>(not isinstance(key[<NUM_LIT:0>], slice)) or<EOL>(not isinstance(key[<NUM_LIT:1>], slice))):<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>x0 = key[<NUM_LIT:1>].start<EOL>x1 = key[<NUM_LIT:1>].stop<EOL>xstep = key[<NUM_LIT:1>].step<EOL>if not isinstance(xstep, complex) or int(xstep.real) != xstep.real:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>xstep = int(xstep.imag)<EOL>y0 = key[<NUM_LIT:0>].start<EOL>y1 = key[<NUM_LIT:0>].stop<EOL>ystep = key[<NUM_LIT:0>].step<EOL>if not isinstance(ystep, complex) or int(ystep.real) != ystep.real:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>ystep = int(ystep.imag)<EOL>return x0, x1, xstep, y0, y1, ystep<EOL>
Convert a 2-tuple of slices to start,stop,steps for x and y.

    key -- (slice(ystart,ystop,ystep), slice(xtart, xstop, xstep))

    For now, the only accepted step values are imaginary integers (interpreted
    in the same way numpy.mgrid, etc. do).