Exemplo n.º 1
0
def test_compare_elements(basis1, basis2, element, expected):
    el1 = api.get_basis(basis1)['elements'][element]
    el2 = api.get_basis(basis2)['elements'][element]
    assert curate.compare_elements(el1, el2, True, True, True) == expected
    assert curate.compare_elements(el2, el1, True, True, True) == expected
Exemplo n.º 2
0

for fp in sys.argv[1:]:
    print("File " + fp)
    to_find_orig = bse.fileio.read_json_basis(fp)
    to_find = bse.manip.uncontract_general(to_find_orig)

    found_map = defaultdict(list)

    for el,elv in to_find['elements'].items():
        found = False
        for fname,bsd in bs_data.items():
            if el not in bsd['elements']:
                continue

            if curate.compare_elements(elv, bsd['elements'][el], rel_tol=1e-8):
                if found:
                    print("****Found match: Element {} = {}".format(el, fname))
                else:
                    print("    Found match: Element {} = {}".format(el, fname))
                found = True

                to_find_orig['elements'][el]['references'] = bsd['elements'][el]['references']
                found_map[fname].append(el)

        if not found:
            print("    Element {} not found".format(el))

    print("  Summary for " + fp)
    for k,v in found_map.items():
        print("{} : {}".format(bse.misc.compact_elements(v), k))