Example #1
0
def experiments_table(
    all_experiments,
    headers,
    metric_headers,
    metric_names,
    param_headers,
    param_names,
    sort_by=None,
    sort_order=None,
    precision=DEFAULT_PRECISION,
    fill_value=FILL_VALUE,
    iso=False,
) -> "TabularData":
    from funcy import lconcat

    from dvc.compare import TabularData

    td = TabularData(lconcat(headers, metric_headers, param_headers),
                     fill_value=fill_value)
    for base_rev, experiments in all_experiments.items():
        rows = _collect_rows(
            base_rev,
            experiments,
            metric_names,
            param_names,
            sort_by=sort_by,
            sort_order=sort_order,
            precision=precision,
            fill_value=fill_value,
            iso=iso,
        )
        td.extend(rows)

    return td
Example #2
0
    def bundle_inputs(self, name=None):
        if name is None:
            name = cmn._fresh()

        size = sum(self.aigbv.imap.values())
        bdl = Bundle(name=name, size=size)
        inputs = fn.lconcat(*(self.aigbv.imap[i] for i in self.inputs))

        relabels = {old: new for old, new in zip(inputs, bdl)}
        circ = aigbv.rebundle_aig(self.aig['i', relabels])
        return attr.evolve(self, aigbv=circ)
Example #3
0
File: S93.py Project: sjava/weihu
def get_vlans_a(ip):
    try:
        child = telnet(ip)
        rslt = do_some(
            child, 'disp cu | in (port trunk allow|port hybrid tagged)')
        close(child)
    except (pexpect.EOF, pexpect.TIMEOUT) as e:
        return ('fail', None, ip)
    vlan_sgmt = re_all(r'(\d+) to (\d+)', rslt)
    vlans = re_all(r'(\d+)', re.sub(r'\d+ to \d+', '', rslt))
    vlan_sgmt = [(int(x[0]), int(x[1]) + 1) for x in vlan_sgmt]
    vlans = [(int(x), int(x) + 1) for x in vlans if x != '1']
    vlan_sgmt = lconcat(vlan_sgmt, vlans)
    _vlan = lambda s, e: range(s, e)
    vlans = reduce(lambda x, y: x | set(_vlan(*y)), vlan_sgmt, set())
    return ('success', list(vlans), ip)
Example #4
0
def experiments_table(
    all_experiments,
    metric_headers,
    metric_names,
    param_headers,
    param_names,
    sort_by=None,
    sort_order=None,
    precision=DEFAULT_PRECISION,
) -> "TabularData":
    from funcy import lconcat

    from dvc.compare import TabularData

    headers = [
        "Experiment",
        "rev",
        "typ",
        "Created",
        "parent",
        "State",
        "Executor",
    ]
    td = TabularData(lconcat(headers, metric_headers, param_headers),
                     fill_value=FILL_VALUE)
    for base_rev, experiments in all_experiments.items():
        rows = _collect_rows(
            base_rev,
            experiments,
            metric_names,
            param_names,
            sort_by=sort_by,
            sort_order=sort_order,
            precision=precision,
        )
        td.extend(rows)

    return td
Example #5
0
def main():
    gulim_font = ImageFont.truetype("fonts/gulim.ttf", 28)
    reko_font = ImageFont.truetype("fonts/reko.ttf", 28)

    # jap: 169 chars
    jap_ucodes = fp.go(
        F.lconcat(
            range(0x3041, 0x309f + 1),  # Hiragana
            range(0x30a0, 0x30ff + 1)),  # Katakana
        #range(0xff00, 0xffef+1), # Full-width roman characters and half-width katakana
        fp.lremove({
            0x3094, 0x3095, 0x3096, 0x3097, 0x3098, 0x3099, 0x309a, 0x309b,
            0x309c, 0x309d, 0x309e, 0x309f, 0x30a0, 0x30f7, 0x30f8, 0x30f9,
            0x30fa, 0x30fb, 0x30fc, 0x30fd, 0x30fe, 0x30ff
        }))
    # kor: 966 chars
    kor_ucodes = fp.go(fu.read_text("./freq_kor_words.txt"), F.distinct,
                       fp.remove({"\n", " "}), fp.tmap(ord))

    # Create imgs
    jap_gulim_imgs = char_imgs(gulim_font, jap_ucodes)
    jap_reko_imgs = char_imgs(reko_font, jap_ucodes)
    kor_gulim_imgs = char_imgs(gulim_font, kor_ucodes)
    kor_reko_imgs = char_imgs(reko_font, kor_ucodes)

    # Create dirs
    os.makedirs("datasets/jk_all/testA", exist_ok=True)
    os.makedirs("datasets/jk_all/testB", exist_ok=True)
    os.makedirs("datasets/jk_all/trainA", exist_ok=True)
    os.makedirs("datasets/jk_all/trainB", exist_ok=True)

    os.makedirs("datasets/jk_no_kg/testA", exist_ok=True)
    os.makedirs("datasets/jk_no_kg/testB", exist_ok=True)
    os.makedirs("datasets/jk_no_kg/trainA", exist_ok=True)
    os.makedirs("datasets/jk_no_kg/trainB", exist_ok=True)

    os.makedirs("datasets/jk_no_kr/testA", exist_ok=True)
    os.makedirs("datasets/jk_no_kr/testB", exist_ok=True)
    os.makedirs("datasets/jk_no_kr/trainA", exist_ok=True)
    os.makedirs("datasets/jk_no_kr/trainB", exist_ok=True)

    @F.autocurry
    def dst_path(base, split, type, ucode, ext=".png"):
        return str(Path(base, split, type + str(ucode) + ext))

    # Save imgs
    jk_all = dst_path("datasets/jk_all")
    jk_no_kg = dst_path("datasets/jk_no_kg")  # no kor gulim
    jk_no_kr = dst_path("datasets/jk_no_kr")  # no kor reko

    path_ucodes_imgs_tups = (
        (jk_all("testA", "g"), jap_ucodes, jap_gulim_imgs),
        (jk_all("testA", "g"), kor_ucodes, kor_gulim_imgs),
        (jk_all("testB", "r"), jap_ucodes, jap_reko_imgs),
        (jk_all("testB", "r"), kor_ucodes, kor_reko_imgs),
        (jk_all("trainA", "g"), jap_ucodes, jap_gulim_imgs),
        (jk_all("trainA", "g"), kor_ucodes, kor_gulim_imgs),
        (jk_all("trainB", "r"), jap_ucodes, jap_reko_imgs),
        (jk_all("trainB", "r"), kor_ucodes, kor_reko_imgs),
        (jk_no_kg("testA", "g"), jap_ucodes, jap_gulim_imgs),
        #(jk_no_kg("testA","g"), kor_ucodes, kor_gulim_imgs ),
        (jk_no_kg("testB", "r"), jap_ucodes, jap_reko_imgs),
        (jk_no_kg("testB", "r"), kor_ucodes, kor_reko_imgs),
        (jk_no_kg("trainA", "g"), jap_ucodes, jap_gulim_imgs),
        #(jk_no_kg("trainA","g"), kor_ucodes, kor_gulim_imgs),
        (jk_no_kg("trainB", "r"), jap_ucodes, jap_reko_imgs),
        (jk_no_kg("trainB", "r"), kor_ucodes, kor_reko_imgs),
        (jk_no_kr("testA", "g"), jap_ucodes, jap_gulim_imgs),
        (jk_no_kr("testA", "g"), kor_ucodes, kor_gulim_imgs),
        (jk_no_kr("testB", "r"), jap_ucodes, jap_reko_imgs),
        #(jk_no_kr("testB","r"), kor_ucodes, kor_reko_imgs  ),
        (jk_no_kr("trainA", "g"), jap_ucodes, jap_gulim_imgs),
        (jk_no_kr("trainA", "g"), kor_ucodes, kor_gulim_imgs),
        (jk_no_kr("trainB", "r"), jap_ucodes, jap_reko_imgs),
        #(jk_no_kr("trainB","r"), kor_ucodes, kor_reko_imgs ),
    )

    for path, ucodes, imgs in path_ucodes_imgs_tups:
        for ucode, img in zip(ucodes, imgs):
            cv2.imwrite(path(ucode), img)