Skip to content

Commit

Permalink
format + remove unreachable code
Browse files Browse the repository at this point in the history
  • Loading branch information
nikolasibalic committed Sep 30, 2023
1 parent e0e237c commit 8a153d1
Showing 1 changed file with 26 additions and 23 deletions.
49 changes: 26 additions & 23 deletions arc/wigner.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,51 +229,54 @@ def Wigner6j(j1, j2, j3, J1, J2, J3, verbose=False):
# Check if the 4 triads ( (j1 j2 j3), (j1 J2 J3), (J1 j2 J3), (J1 J2 j3) )
# satisfy the triangular inequalities
IsTriangle = True
msg = ''
if ((abs(j1 - j2) > j3) | (j1 + j2 < j3)):
msg = ""
if (abs(j1 - j2) > j3) | (j1 + j2 < j3):
IsTriangle = False
msg += '(%.1f, %.1f, %.1f) is not triangular\n'%(j1,j2,j3)
if ((abs(j1 - J2) > J3) | (j1 + J2 < J3)):
msg += "(%.1f, %.1f, %.1f) is not triangular\n" % (j1, j2, j3)
if (abs(j1 - J2) > J3) | (j1 + J2 < J3):
IsTriangle = False
msg += '(%.1f, %.1f, %.1f) is not triangular\n'%(j1,J2,J3)
if ((abs(J1 - j2) > J3) | (J1 + j2 < J3)):
msg += "(%.1f, %.1f, %.1f) is not triangular\n" % (j1, J2, J3)
if (abs(J1 - j2) > J3) | (J1 + j2 < J3):
IsTriangle = False
msg += '(%.1f, %.1f, %.1f) is not triangular\n'%(J1,j2,J3)
if ((abs(J1 - J2) > j3) | (J1 + J2 < j3)):
msg += "(%.1f, %.1f, %.1f) is not triangular\n" % (J1, j2, J3)
if (abs(J1 - J2) > j3) | (J1 + J2 < j3):
IsTriangle = False
msg += '(%.1f, %.1f, %.1f) is not triangular\n'%(J1,J2,j3)
msg += "(%.1f, %.1f, %.1f) is not triangular\n" % (J1, J2, j3)
if not IsTriangle:
msg = "WARNING!!\n" + msg
msg += "For the 6j-Symbol:\n ⎰%3.1f %3.1f %3.1f⎱\n ⎱%3.1f %3.1f %3.1f⎰"%(j1,j2,j3,J1,J2,J3)
msg += (
"For the 6j-Symbol:\n ⎰%3.1f %3.1f %3.1f⎱\n ⎱%3.1f %3.1f %3.1f⎰"
% (j1, j2, j3, J1, J2, J3)
)
if verbose:
print(msg)
return 0
raise ValueError("6j-Symbol is not triangular!")

# Check if the sum of the elements of each traid is an integer
SumIsInteger = True
msg = ''
if (2 * roundPy2(j1 + j2 + j3) != roundPy2(2 * (j1 + j2 + j3))):
msg = ""
if 2 * roundPy2(j1 + j2 + j3) != roundPy2(2 * (j1 + j2 + j3)):
SumIsInteger = False
msg += '%.1f + %.1f + %.1f is not an integer\n'%(j1,j2,j3)
if (2 * roundPy2(j1 + J2 + J3) != roundPy2(2 * (j1 + J2 + J3))):
msg += "%.1f + %.1f + %.1f is not an integer\n" % (j1, j2, j3)
if 2 * roundPy2(j1 + J2 + J3) != roundPy2(2 * (j1 + J2 + J3)):
SumIsInteger = False
msg += '%.1f + %.1f + %.1f is not an integer\n'%(j1,J2,J3)
if (2 * roundPy2(J1 + j2 + J3) != roundPy2(2 * (J1 + j2 + J3))):
msg += "%.1f + %.1f + %.1f is not an integer\n" % (j1, J2, J3)
if 2 * roundPy2(J1 + j2 + J3) != roundPy2(2 * (J1 + j2 + J3)):
SumIsInteger = False
msg += '%.1f + %.1f + %.1f is not an integer\n'%(J1,j2,J3)
if (2 * roundPy2(J1 + J2 + j3) != roundPy2(2 * (J1 + J2 + j3))):
msg += "%.1f + %.1f + %.1f is not an integer\n" % (J1, j2, J3)
if 2 * roundPy2(J1 + J2 + j3) != roundPy2(2 * (J1 + J2 + j3)):
SumIsInteger = False
msg += '%.1f + %.1f + %.1f is not an integer\n'%(J1,J2,j3)
msg += "%.1f + %.1f + %.1f is not an integer\n" % (J1, J2, j3)
if not SumIsInteger:
msg = "WARNING!!\n" + msg
msg += "For the 6j-Symbol:\n ⎰%3.1f %3.1f %3.1f⎱\n ⎱%3.1f %3.1f %3.1f⎰"%(j1,j2,j3,J1,J2,J3)
msg += (
"For the 6j-Symbol:\n ⎰%3.1f %3.1f %3.1f⎱\n ⎱%3.1f %3.1f %3.1f⎰"
% (j1, j2, j3, J1, J2, J3)
)
msg += "\n6j-Symbol is undefined when any triad has a non-integer sum"
if verbose:
print(msg)
return np.nan
raise ValueError("6j-Symbol is undefined when any triad has a non-integer sum")
raise ValueError("6j-Symbol is defined only when all triads have integer sums")

# if possible, use precalculated values
global wignerPrecal
Expand Down

0 comments on commit 8a153d1

Please sign in to comment.