From 164bf7905318f35fb771863deb92a83911cff49b Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Wed, 13 May 2020 00:54:02 +0200 Subject: [PATCH] Fixed Python3 --- stable/champ/qp_convert.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/stable/champ/qp_convert.py b/stable/champ/qp_convert.py index 6e218a2..c6e6459 100755 --- a/stable/champ/qp_convert.py +++ b/stable/champ/qp_convert.py @@ -93,7 +93,7 @@ process = subprocess.Popen( stdout=subprocess.PIPE) out, err = process.communicate() -basis_raw, sym_raw, _ = out.split("\n\n\n") +basis_raw, sym_raw, _ = out.decode().split("\n\n\n") # _ __ # |_) _. _ o _ (_ _ _|_ @@ -131,24 +131,20 @@ print("END_BASIS_SET") # # Function # -d_gms_order ={ 0:["s"], - 1:[ "x", "y", "z" ], - 2:[ "xx", "yy", "zz", "xy", "xz", "yz" ], - 3:[ "xxx", "yyy", "zzz", "xxy", "xxz", "yyx", "yyz", "zzx", "zzy", "xyz"], - 4:[ "xxxx", "yyyy", "zzzz", "xxxy", "xxxz", "yyyx", "yyyz", "zzzx", "zzzy", "xxyy", "xxzz", "yyzz", "xxyz", "yyxz", "zzxy"] } +d_gms_order = ["s", + "x", "y", "z" , + "xx", "yy", "zz", "xy", "xz", "yz" , + "xxx", "yyy", "zzz", "xxy", "xxz", "yyx", "yyz", "zzx", "zzy", "xyz", + "xxxx", "yyyy", "zzzz", "xxxy", "xxxz", "yyyx", "yyyz", "zzzx", "zzzy", "xxyy", "xxzz", "yyzz", "xxyz", "yyxz", "zzxy"] -def compare_gamess_style(item1, item2): - n1,n2 = list(map(len,(item1,item2))) - assert (n1 == n2) +def key_gamess_style(item1): try: - l = d_gms_order[n1] - except KeyError: + l = d_gms_order.index(item1) + except ValueError: return 0 -# raise (KeyError, "We dont handle L than 4") else: - a = l.index(item1) - b = l.index(item2) - return cmp( a, b ) + result = d_gms_order.index(item1) + return result def expend_sym_str(str_): #Expend x2 -> xx @@ -184,6 +180,7 @@ def get_nb_permutation(str_): if (str_) == 's': return 1 else: return n_orbital(len(str_)) +import functools def order_l_l_sym(l_l_sym): n = 1 iter_ = list(range(len(l_l_sym))) @@ -195,9 +192,11 @@ def order_l_l_sym(l_l_sym): l = l_l_sym[i] n = get_nb_permutation(l[2]) + def local_key(x): + return key_gamess_style(x[2]) + l_l_sym[i:i + n] = sorted(l_l_sym[i:i + n], - key=lambda x: x[2], - cmp=compare_gamess_style) + key=local_key) return l_l_sym