From 7d3dcfedc0fb30da1e1cc911d910d4165cd218fe Mon Sep 17 00:00:00 2001 From: John Tramm Date: Fri, 22 Nov 2019 19:27:42 +0000 Subject: [PATCH] Probably the final fix for unit tests --- openmc/lib/math.py | 10 +++++----- tests/unit_tests/test_math.py | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/openmc/lib/math.py b/openmc/lib/math.py index 5d00ad9d8..d9e6845e5 100644 --- a/openmc/lib/math.py +++ b/openmc/lib/math.py @@ -26,7 +26,7 @@ _dll.calc_zn_rad.argtypes = [c_int, c_double, ndpointer(c_double)] _dll.rotate_angle_c.restype = None _dll.rotate_angle_c.argtypes = [ndpointer(c_double), c_double, - ndpointer(c_double), ndpointer(c_uint64), c_int] + POINTER(c_double), ndpointer(c_uint64), c_int] _dll.maxwell_spectrum.restype = c_double _dll.maxwell_spectrum.argtypes = [c_double, ndpointer(c_uint64), c_int] @@ -210,12 +210,12 @@ def rotate_angle(uvw0, mu, phi, prn_seeds, stream ): """ uvw0_arr = np.array(uvw0, dtype=np.float64) - phi_arr = np.array(phi, dtype=np.float64) - if phi_arr.size == 0: - phi_arr = None prn_seeds_arr = np.array(prn_seeds, dtype=np.uint64) + if phi is None: + _dll.rotate_angle_c(uvw0_arr, mu, None, prn_seeds_arr, stream) + else: + _dll.rotate_angle_c(uvw0_arr, mu, c_double(phi), prn_seeds_arr, stream) - _dll.rotate_angle_c(uvw0_arr, mu, phi_arr, prn_seeds_arr, stream) uvw = uvw0_arr return uvw diff --git a/tests/unit_tests/test_math.py b/tests/unit_tests/test_math.py index f95c7b734..24dce4f95 100644 --- a/tests/unit_tests/test_math.py +++ b/tests/unit_tests/test_math.py @@ -154,7 +154,7 @@ def test_calc_zn_rad(): def test_rotate_angle(): uvw0 = np.array([1., 0., 0.]) - phi = [0.] + phi = 0. mu = 0. prn_seeds = [1, 2, 3, 4, 5, 6] stream = 0 @@ -176,7 +176,7 @@ def test_rotate_angle(): # Now to test phi is None mu = 0.9 - phi = [] + phi = None # When seed = 1, phi will be sampled as 1.9116495709698769 # The resultant reference is from hand-calculations given the above