Code Duplication    Length = 14-15 lines in 2 locations

amd/io.py 2 locations

@@ 523-537 (lines=15) @@
520
521
    # atomic types
522
    asym_symbols = block._get_any(CIF_TAGS['atom_symbol'])
523
    if asym_symbols is None:
524
        warnings.warn('missing atomic types will be labelled 0')
525
        asym_types = [0] * len(asym_unit)
526
    else:
527
        asym_types = []
528
        for label in asym_symbols:
529
            if label in ('.', '?'):
530
                warnings.warn('missing atomic types will be labelled 0')
531
                num = 0
532
            else:
533
                sym = re.search(r'([A-Z][a-z]?)', label).group(0)
534
                if sym == 'D':
535
                    sym = 'H'
536
                num = ase_atomic_numbers[sym]
537
            asym_types.append(num)
538
539
    # find if sites have disorder if necassary
540
    has_disorder = []
@@ 759-772 (lines=14) @@
756
    # atomic types
757
    for tag in CIF_TAGS['atom_symbol']:
758
        asym_symbols = odict.get(tag)
759
        if asym_symbols is not None:
760
            asym_types = []
761
            for label in asym_symbols:
762
                if label in ('.', '?'):
763
                    warnings.warn('missing atomic types will be labelled 0')
764
                    num = 0
765
                else:
766
                    sym = re.search(r'([A-Z][a-z]?)', label).group(0)
767
                    if sym == 'D':
768
                        sym = 'H'
769
                    # could use pymatgen here
770
                    num = ase_atomic_numbers[sym]
771
                asym_types.append(num)
772
            break
773
    else:
774
        warnings.warn('missing atomic types will be labelled 0')
775
        asym_types = [0] * len(asym_unit)