Code Duplication    Length = 14-15 lines in 2 locations

amd/io.py 2 locations

@@ 509-523 (lines=15) @@
506
507
    # atomic types
508
    asym_symbols = block._get_any(CIF_TAGS['atom_symbol'])
509
    if asym_symbols is None:
510
        warnings.warn('missing atomic types will be labelled 0')
511
        asym_types = [0] * len(asym_unit)
512
    else:
513
        asym_types = []
514
        for label in asym_symbols:
515
            if label in ('.', '?'):
516
                warnings.warn('missing atomic types will be labelled 0')
517
                num = 0
518
            else:
519
                sym = re.search(r'([A-Z][a-z]?)', label).group(0)
520
                if sym == 'D':
521
                    sym = 'H'
522
                num = ase.data.atomic_numbers[sym]
523
            asym_types.append(num)
524
525
    # find if sites have disorder or not (if necassary)
526
    has_disorder = []
@@ 739-752 (lines=14) @@
736
    # atomic types
737
    for tag in CIF_TAGS['atom_symbol']:
738
        asym_symbols = odict.get(tag)
739
        if asym_symbols is not None:
740
            asym_types = []
741
            for label in asym_symbols:
742
                if label in ('.', '?'):
743
                    warnings.warn('missing atomic types will be labelled 0')
744
                    num = 0
745
                else:
746
                    sym = re.search(r'([A-Z][a-z]?)', label).group(0)
747
                    if sym == 'D':
748
                        sym = 'H'
749
                    # could use pymatgen here
750
                    num = ase.data.atomic_numbers[sym]
751
                asym_types.append(num)
752
            break
753
    else:
754
        warnings.warn('missing atomic types will be labelled 0')
755
        asym_types = [0] * len(asym_unit)