def test_stencil_call_const(self):
        """Tests numba.stencil call that has an index that can be inferred as
        constant from a unary expr. Otherwise, this would raise an error since
        neighborhood length is not specified.
        """
        def test_impl1(n):
            A = np.arange(n)
            B = np.zeros(n)
            c = 1
            numba.stencil(lambda a,c : 0.3 * (a[-c] + a[0] + a[c]))(A, c, out=B)
            return B

        def test_impl2(n):
            A = np.arange(n)
            B = np.zeros(n)
            c = 2
            numba.stencil(
                lambda a,c : 0.3 * (a[1 - c] + a[0] + a[c - 1]))(A, c, out=B)
            return B

        # recursive expr case
        def test_impl3(n):
            A = np.arange(n)
            B = np.zeros(n)
            c = 2
            numba.stencil(
                lambda a,c : 0.3 * (a[-c + 1] + a[0] + a[c - 1]))(A, c, out=B)
            return B

        # multi-constant case
        def test_impl4(n):
            A = np.arange(n)
            B = np.zeros(n)
            d = 1
            c = 2
            numba.stencil(
                lambda a,c,d : 0.3 * (a[-c + d] + a[0] + a[c - d]))(A, c, d,
                                                                    out=B)
            return B

        def test_impl_seq(n):
            A = np.arange(n)
            B = np.zeros(n)
            c = 1
            for i in range(1, n - 1):
                B[i] = 0.3 * (A[i - c] + A[i] + A[i + c])
            return B

        n = 100
        # constant inference is only possible in parallel path
        cpfunc1 = self.compile_parallel(test_impl1, (types.intp,))
        cpfunc2 = self.compile_parallel(test_impl2, (types.intp,))
        cpfunc3 = self.compile_parallel(test_impl3, (types.intp,))
        cpfunc4 = self.compile_parallel(test_impl4, (types.intp,))
        expected = test_impl_seq(n)
        # parfor result
        parfor_output1 = cpfunc1.entry_point(n)
        parfor_output2 = cpfunc2.entry_point(n)
        parfor_output3 = cpfunc3.entry_point(n)
        parfor_output4 = cpfunc4.entry_point(n)
        np.testing.assert_almost_equal(parfor_output1, expected, decimal=3)
        np.testing.assert_almost_equal(parfor_output2, expected, decimal=3)
        np.testing.assert_almost_equal(parfor_output3, expected, decimal=3)
        np.testing.assert_almost_equal(parfor_output4, expected, decimal=3)

        # check error in regular Python path
        with self.assertRaises(NumbaValueError) as e:
            test_impl4(4)

        self.assertIn("stencil kernel index is not constant, "
                      "'neighborhood' option required", str(e.exception))
        # check error in njit path
        # TODO: ValueError should be thrown instead of LoweringError
        with self.assertRaises((LoweringError, NumbaValueError)) as e:
            njit(test_impl4)(4)

        self.assertIn("stencil kernel index is not constant, "
                      "'neighborhood' option required", str(e.exception))
Tests numba.stencil call that has an index that can be inferred as
        constant from a unary expr. Otherwise, this would raise an error since
        neighborhood length is not specified.
        
numba/tests/test_stencils.py