def test_int32FindMaxWhileLoopForwardIter(pymod_test_mod, seeded_random_number_generator, ndim): arg = array_utils.get_random_Nd_array_of_ndim_and_type(ndim, numpy.int32) print ("\nrandom number seed = %d\nndim = %d, shape = %s\narg =\n%s" % \ (seeded_random_number_generator, ndim, arg.shape, arg)) expectedRes = arg.max() res = pymod_test_mod.int32FindMaxWhileLoopForwardIter(arg) print ("res = %s" % str(res)) assert res == expectedRes
def test_int32FindMaxForLoopValues(pymod_test_mod, seeded_random_number_generator, ndim, nim_test_proc_name): arg = array_utils.get_random_Nd_array_of_ndim_and_type(ndim, numpy.int32) print ("\nrandom number seed = %d\nndim = %d, shape = %s\narg =\n%s" % \ (seeded_random_number_generator, ndim, arg.shape, arg)) expectedRes = arg.max() res = getattr(pymod_test_mod, nim_test_proc_name)(arg) print ("res = %s" % str(res)) assert res == expectedRes
def test_int32FindMaxWhileLoopRandaccIterDerefKParamAlternatives(pymod_test_mod, seeded_random_number_generator, ndim, nim_test_proc_name, k): arg = array_utils.get_random_Nd_array_of_ndim_and_type(ndim, numpy.int32) print ("\nnim_test_proc_name = %s, k = %d" % (nim_test_proc_name, k)) print ("random number seed = %d\nndim = %d, shape = %s\narg =\n%s" % \ (seeded_random_number_generator, ndim, arg.shape, arg)) expectedRes = arg.max() res = getattr(pymod_test_mod, nim_test_proc_name)(arg, k) print ("res = %s" % str(res)) assert res == expectedRes
def test_int32FindMaxForLoopRandaccIterDeltaN_1(pymod_test_mod, seeded_random_number_generator, ndim, nim_test_proc_name, n): arg = array_utils.get_random_Nd_array_of_ndim_and_type(ndim, numpy.int32) print ("\nnim_test_proc_name = %s, n = %d" % (nim_test_proc_name, n)) print ("random number seed = %d\nndim = %d, shape = %s\narg =\n%s" % \ (seeded_random_number_generator, ndim, arg.shape, arg)) argDeltaN = arg.flat[::n] print ("arg.flat[::n] =\n%s" % argDeltaN) expectedRes = argDeltaN.max() res = getattr(pymod_test_mod, nim_test_proc_name)(arg, n) print ("res = %s" % str(res)) assert res == expectedRes
def test_int32FindMaxForLoopRandaccIterExcludeLastM_1(pymod_test_mod, seeded_random_number_generator, ndim, nim_test_proc_name, m): dtype = numpy.int32 arg = array_utils.get_random_Nd_array_of_ndim_and_type(ndim, dtype) print ("\nnim_test_proc_name = %s, m = %d" % (nim_test_proc_name, m)) print ("random number seed = %d\nndim = %d, shape = %s\narg =\n%s" % \ (seeded_random_number_generator, ndim, arg.shape, arg)) argBeforeLastM = arg.flat[:-m] print ("arg.flat[:-m] =\n%s" % argBeforeLastM) if argBeforeLastM.size > 0: expectedRes = argBeforeLastM.max() print ("expectedRes = %s" % str(expectedRes)) else: expectedRes = numpy.iinfo(dtype).min print ("expectedRes = %s (int32.min)" % str(expectedRes)) res = getattr(pymod_test_mod, nim_test_proc_name)(arg, m) print ("res = %s" % str(res)) assert res == expectedRes