def load_divs(f, specs, Ks):
    specs = np.asarray(strict_map(normalize_div_name, specs))
    Ks = np.ravel(Ks)

    n_bags = next(itervalues(next(itervalues(f)))).shape[0]

    divs = np.empty((n_bags, n_bags, specs.size, Ks.size), dtype=np.float32)
    divs.fill(np.nan)

    for i, spec in enumerate(specs):
        try:
            group = f[spec]
        except __HOLE__:
            msg = "missing div func {} in {}"
            raise KeyError(msg.format(spec, f.filename))

        for j, K in enumerate(Ks):
            try:
                vals = group[str(K)]
            except KeyError:
                msg = "{} is missing K={} in {}"
                raise KeyError(msg.format(spec, K, f.filename))

            divs[:, :, i, j] = vals
    return divs
dataset/ETHPy150Open dougalsutherland/py-sdm/sdm/tests/test_divs.py/load_divs