def _unpack_p0(p0, p0file, prior):
if p0file is not None:<EOL><INDENT>try:<EOL><INDENT>with open(p0file, "<STR_LIT:rb>") as f:<EOL><INDENT>p0 = pickle.load(f)<EOL><DEDENT><DEDENT>except (IOError, EOFError):<EOL><INDENT>if prior is None:<EOL><INDENT>raise IOError(<EOL>"<STR_LIT>" + p0file<EOL>)<EOL><DEDENT>else:<EOL><INDENT>p0 = None<EOL><DEDENT><DEDENT><DEDENT>if p0 is not None:<EOL><INDENT>if p0 is True:<EOL><INDENT>p0 = next(_gvar.raniter(prior))<EOL><DEDENT>if hasattr(p0, '<STR_LIT>'):<EOL><INDENT>p0 = _gvar.BufferDict(p0)<EOL>if p0.dtype != float:<EOL><INDENT>p0.buf = numpy.asarray(p0.buf, dtype=float)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>p0 = numpy.array(p0, float)<EOL><DEDENT><DEDENT>if prior is not None:<EOL><INDENT>pp = _reformat(prior, buf=[x.mean if x.mean != <NUM_LIT:0.0><EOL>else x.mean + <NUM_LIT:0.1> * x.sdev for x in prior.flat])<EOL>if p0 is None:<EOL><INDENT>p0 = pp<EOL><DEDENT>else:<EOL><INDENT>if pp.shape is not None:<EOL><INDENT>pp_shape = pp.shape<EOL>p0_shape = p0.shape<EOL>if len(pp_shape)!=len(p0_shape):<EOL><INDENT>raise ValueError(       <EOL>"<STR_LIT>"<EOL>% (str(p0_shape), str(pp_shape)))<EOL><DEDENT>idx = []<EOL>for npp, np0 in zip(pp_shape, p0_shape):<EOL><INDENT>idx.append(slice(<NUM_LIT:0>, min(npp, np0)))<EOL><DEDENT>idx = tuple(idx)    <EOL>pp[idx] = p0[idx]<EOL>p0 = pp<EOL><DEDENT>else:<EOL><INDENT>for k in pp:<EOL><INDENT>if k not in p0:<EOL><INDENT>continue<EOL><DEDENT>pp_shape = numpy.shape(pp[k])<EOL>p0_shape = numpy.shape(p0[k])<EOL>if len(pp_shape)!=len(p0_shape):<EOL><INDENT>raise ValueError("<STR_LIT>"<EOL>+str(k))<EOL><DEDENT>if pp_shape == p0_shape:<EOL><INDENT>pp[k] = p0[k]<EOL><DEDENT>else:<EOL><INDENT>pp_shape = pp[k].shape<EOL>p0_shape = p0[k].shape<EOL>if len(pp_shape)!=len(p0_shape):<EOL><INDENT>raise ValueError(       <EOL>"<STR_LIT>"+str(k))<EOL><DEDENT>idx = []<EOL>for npp, np0 in zip(pp_shape, p0_shape):<EOL><INDENT>idx.append(slice(<NUM_LIT:0>, min(npp, np0)))<EOL><DEDENT>idx = tuple(idx)    <EOL>pp[k][idx] = p0[k][idx]<EOL><DEDENT><DEDENT>p0 = pp<EOL><DEDENT><DEDENT><DEDENT>if p0 is None:<EOL><INDENT>raise ValueError("<STR_LIT>")<EOL><DEDENT>return p0<EOL>
Create proper p0.

    Try to read from a file. If that doesn't work, try using p0,
    and then, finally, the prior. If the p0 is from the file, it is
    checked against the prior to make sure that all elements have the
    right shape; if not the p0 elements are adjusted (using info from
    the prior) to be the correct shape. If p0 is a dictionary,
    keys in p0 that are not in prior are discarded. If p0 is True,
    then a random p0 is generated from the prior.