Repository: fujiisoup/py3nj

Issue:
wigner 9j disagrees with online calculators
I want to know what following 9j symbol evaluates to
{ 3/2 3/2 1
  2    2    2
1/2 1/2 1 } 

A couple of online calculators say the value is around 0.048:

- http://www-stone.ch.cam.ac.uk/cgi-bin/wigner.cgi?symbol=9j&a=3%2F2&b=3%2F2&c=1&d=2&e=2&f=2&g=1%2F2&h=1%2F2&i=1

- http://dentonwoods.nfshost.com/3j6j9j.html

- py3nj says the value is zero

- sympy.physics.wigner throws an error Value error saying the values must be integer or half integer and fulfill the triangle relation.

I don't know who's right?

Discussion:

Patch:
diff --git a/py3nj/wigner.py b/py3nj/wigner.py
index f9d15c1..01fd012 100644
--- a/py3nj/wigner.py
+++ b/py3nj/wigner.py
@@ -162,11 +162,11 @@ def wigner9j(two_l1, two_l2, two_l3, two_l4, two_l5, two_l6,
         two_l1, two_l2, two_l3, two_l4, two_l5, two_l6, two_l7, two_l8, two_l9)
 
     # calculat summation directory from 6-j symbol
-    x, sixj = drc6j(np.stack([two_lf, two_lh, two_la]),
-                    np.stack([two_lb, two_lb, two_lj]),
+    x, sixj = drc6j(np.stack([two_lf, two_lb, two_la]),
+                    np.stack([two_lb, two_lf, two_lj]),
                     np.stack([two_lc, two_le, two_lg]),
-                    np.stack([two_la, two_lf, two_lh]),
-                    np.stack([two_lj, two_ld, two_ld]))
+                    np.stack([two_la, two_ld, two_lh]),
+                    np.stack([two_lj, two_lh, two_ld]))
     neg_phase = (2 * x) % 4 - 1
     return np.sum(-neg_phase * (x + 1) * sixj[0] * sixj[1] * sixj[2], axis=-1)
 


Test patch:
diff --git a/tests/test_9j.py b/tests/test_9j.py
index 24df4bf..78ba8bc 100644
--- a/tests/test_9j.py
+++ b/tests/test_9j.py
@@ -32,3 +32,10 @@ def test_wigner9j():
     expected = np.array([value for _, value in NINE_J]).T
     actual = wigner9j(*nine_j)
     assert np.allclose(actual, expected)
+
+
+def test_issue2():
+  # https://github.com/fujiisoup/py3nj/issues/2
+  actual = wigner9j(0, 0, 0, 2 * 1, 0, 2 * 1, 2 * 1, 0, 2 * 1)
+  expected = 1.0 / 3.0
+  assert np.allclose(actual, expected)
\ No newline at end of file