<commit_before>"""Example: sum each row using guvectorize

See Numpy documentation for detail about gufunc:
    http://docs.scipy.org/doc/numpy/reference/c-api.generalized-ufuncs.html
"""
from __future__ import absolute_import, print_function, division
import numpy as np
from numba import guvectorize, cuda
from numba import unittest_support as unittest
from numba.tests.support import TestCase
from numba.cuda.testing import skip_on_cudasim, SerialMixin


@skip_on_cudasim('ufunc API unsupported in the simulator')
class TestGUFuncScalr(SerialMixin, TestCase):
    def test_gufunc_scalar_output(self):
        #    function type:
        #        - has no void return type
        #        - array argument is one dimenion fewer than the source array
        #        - scalar output is passed as a 1-element array.
        #
        #    signature: (n)->()
        #        - the function takes an array of n-element and output a scalar.

        @guvectorize(['void(int32[:], int32[:])'], '(n)->()', target='cuda')
        def sum_row(inp, out):
            tmp = 0.
            for i in range(inp.shape[0]):
                tmp += inp[i]
            out[0] = tmp<commit_msg>Fix typo in test<commit_after>"""Example: sum each row using guvectorize

See Numpy documentation for detail about gufunc:
    http://docs.scipy.org/doc/numpy/reference/c-api.generalized-ufuncs.html
"""
from __future__ import absolute_import, print_function, division
import numpy as np
from numba import guvectorize, cuda
from numba import unittest_support as unittest
from numba.tests.support import TestCase
from numba.cuda.testing import skip_on_cudasim, SerialMixin


@skip_on_cudasim('ufunc API unsupported in the simulator')
class TestGUFuncScalar(SerialMixin, TestCase):
    def test_gufunc_scalar_output(self):
        #    function type:
        #        - has no void return type
        #        - array argument is one dimenion fewer than the source array
        #        - scalar output is passed as a 1-element array.
        #
        #    signature: (n)->()
        #        - the function takes an array of n-element and output a scalar.

        @guvectorize(['void(int32[:], int32[:])'], '(n)->()', target='cuda')
        def sum_row(inp, out):
            tmp = 0.
            for i in range(inp.shape[0]):
                tmp += inp[i]
            out[0] = tmp
{'fraction_non_alphanumeric': 0.09737510584250635, 'fraction_numerical': 0.006773920406435224, 'mean_word_length': 2.646604938271605, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3008588', 'n_tokens_mistral': 722, 'n_tokens_neox': 699, 'n_words': 222}