internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: numba/numba

Issue:
CUDA Gufunc error with scalar output
From ML: https://groups.google.com/a/continuum.io/d/msgid/numba-users/cb5a3d06-6287-4291-9dfd-b70135ec23c7%40continuum.io?utm_medium=email&utm_source=footer

Minimal case:

```python

@guvectorize(['void(int64, float64[:], float64[:])'],  '(),(N) -> ()', target='cuda')
def p_neg_gpu(i,theta,res):
    res[0]=1.0
```

Error appears to be specific to the CUDA target.
CUDA Gufunc error with scalar output
From ML: https://groups.google.com/a/continuum.io/d/msgid/numba-users/cb5a3d06-6287-4291-9dfd-b70135ec23c7%40continuum.io?utm_medium=email&utm_source=footer

Minimal case:

```python

@guvectorize(['void(int64, float64[:], float64[:])'],  '(),(N) -> ()', target='cuda')
def p_neg_gpu(i,theta,res):
    res[0]=1.0
```

Error appears to be specific to the CUDA target.


Discussion:

Resolving patch:
diff --git a/numba/npyufunc/deviceufunc.py b/numba/npyufunc/deviceufunc.py
--- a/numba/npyufunc/deviceufunc.py
+++ b/numba/npyufunc/deviceufunc.py
@@ -498,7 +498,7 @@ def expand_gufunc_template(template, indims, outdims, funcname, argtypes):
               for aref, adims, atype in zip(argnames, indims, argtypes)]
     outputs = [_gen_src_for_indexing(aref, adims, atype)
                for aref, adims, atype in zip(argnames[len(indims):], outdims,
-                                             argtypes)]
+                                             argtypes[len(indims):])]
     argitems = inputs + outputs
     src = template.format(name=funcname, args=', '.join(argnames),
                           checkedarg=checkedarg,


Test patch:
diff --git a/numba/cuda/tests/cudapy/test_gufunc_scalar.py b/numba/cuda/tests/cudapy/test_gufunc_scalar.py
--- a/numba/cuda/tests/cudapy/test_gufunc_scalar.py
+++ b/numba/cuda/tests/cudapy/test_gufunc_scalar.py
@@ -7,11 +7,12 @@
 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, unittest.TestCase):
+class TestGUFuncScalar(SerialMixin, TestCase):
     def test_gufunc_scalar_output(self):
         #    function type:
         #        - has no void return type
@@ -54,6 +55,16 @@ def sum_row(inp, out):
             self.assertTrue(out1[i] == inp[i].sum())
             self.assertTrue(out2[i] == inp[i].sum())
 
+    def test_gufunc_scalar_output_bug(self):
+        # Issue 2812: Error due to using input argument types as output argument
+        @guvectorize(['void(int32, int32[:])'], '()->()', target='cuda')
+        def twice(inp, out):
+            out[0] = inp * 2
+
+        self.assertEqual(twice(10), 20)
+        arg = np.arange(10).astype(np.int32)
+        self.assertPreciseEqual(twice(arg), arg * 2)
+
     def test_gufunc_scalar_input_saxpy(self):
         @guvectorize(['void(float32, float32[:], float32[:], float32[:])'],
                      '(),(t),(t)->(t)', target='cuda')
Repository: numba/numba

Issue:
Misconfigured CUDA driver prevents test discovery from working
It turns out that if you e.g. have a bad CUDA driver installation, the Numba CUDA driver binding themselves can fail to init (but obviously try because it looks like they should work), this isn't caught as part of the `is_available()` check for `numba.cuda` that the guards around CUDA testing rely on and as a result the test suite errors/test discovery don't work. CC @nehaljwani


Discussion:

Resolving patch:
diff --git a/numba/cuda/device_init.py b/numba/cuda/device_init.py
--- a/numba/cuda/device_init.py
+++ b/numba/cuda/device_init.py
@@ -23,8 +23,18 @@ def is_available():
 
     This will initialize the driver if it hasn't been initialized.
     """
-    return driver.driver.is_available and nvvm.is_available()
-
+    # whilst `driver.is_available` will init the driver itself,
+    # the driver initialization may raise and as a result break
+    # test discovery/orchestration as `cuda.is_available` is often
+    # used as a guard for whether to run a CUDA test, the try/except
+    # below is to handle this case.
+    driver_is_available = False
+    try:
+        driver_is_available = driver.driver.is_available
+    except CudaSupportError:
+        pass
+
+    return driver_is_available and nvvm.is_available()
 
 def cuda_error():
     """Returns None or an exception if the CUDA driver fails to initialize.


Test patch:
Repository: numba/numba

Issue:
ParallelAccelerator crash with some ufunc operators
This code crashes since somewhere in ParallelAccelerator arrayexpr operators are assumed to be just strings. I'll submit a patch soon.

```python
@numba.njit(parallel=True)
def f():
    A = np.ones(3, np.uint8)
    B = np.ones(3, np.uint8)
    C = np.bitwise_and(A, B)
    return C.sum()
```
```
  File "/home/etotoni/pse-hpc/python/numba/numba/parfor.py", line 733, in _convert_numpy
    equiv_set, lhs, expr, avail_vars)
  File "/home/etotoni/pse-hpc/python/numba/numba/parfor.py", line 1289, in _arrayexpr_to_parfor
    ('arrayexpr {}'.format(repr_arrayexpr(arrayexpr.expr)),),
  File "/home/etotoni/pse-hpc/python/numba/numba/parfor.py", line 2945, in repr_arrayexpr
    return '({})'.format(opr.join([ repr_arrayexpr(x) for x in args ]))
AttributeError: Failed at nopython (convert to parfors)
'numpy.ufunc' object has no attribute 'join'
```


Discussion:

Resolving patch:
diff --git a/numba/parfor.py b/numba/parfor.py
--- a/numba/parfor.py
+++ b/numba/parfor.py
@@ -2921,6 +2921,12 @@ def repr_arrayexpr(arrayexpr):
     """
     if isinstance(arrayexpr, tuple):
         opr = arrayexpr[0]
+        # sometimes opr is not string like '+', but is a ufunc object
+        if not isinstance(opr, str):
+            if hasattr(opr, '__name__'):
+                opr = opr.__name__
+            else:
+                opr = '_'  # can return dummy since repr is not critical
         args = arrayexpr[1]
         if len(args) == 1:
             return '({}{})'.format(opr, repr_arrayexpr(args[0]))


Test patch:
diff --git a/numba/tests/test_parfors.py b/numba/tests/test_parfors.py
--- a/numba/tests/test_parfors.py
+++ b/numba/tests/test_parfors.py
@@ -1131,6 +1131,17 @@ def test_impl(N, D):
         self.assertEqual(countArrayAllocs(test_impl, (types.intp, types.intp)), 4)
         self.assertEqual(countParfors(test_impl, (types.intp, types.intp)), 4)
 
+    @skip_unsupported
+    def test_ufunc_expr(self):
+        # issue #2885
+        def test_impl(A, B):
+            return np.bitwise_and(A, B)
+
+        A = np.ones(3, np.uint8)
+        B = np.ones(3, np.uint8)
+        B[1] = 0
+        self.check(test_impl, A, B)
+
 
 class TestPrangeBase(TestParforsBase):
Repository: numba/numba

Issue:
cuda/random.py's uint64_to_unit_float32 docstring has simple paste error
numba/cuda/random.py has uint64_to_unit_float32(x) that returns float32,
but its docstring claims to return float64, being a paste of uint64_to_unit_float64()'s.


Discussion:

Resolving patch:
diff --git a/numba/cuda/random.py b/numba/cuda/random.py
--- a/numba/cuda/random.py
+++ b/numba/cuda/random.py
@@ -127,7 +127,7 @@ def uint64_to_unit_float64(x):
 
 @jit
 def uint64_to_unit_float32(x):
-    '''Convert uint64 to float64 value in the range [0.0, 1.0)'''
+    '''Convert uint64 to float32 value in the range [0.0, 1.0)'''
     x = uint64(x)
     return float32(uint64_to_unit_float64(x))
 


Test patch:
Repository: numba/numba

Issue:
Make ROCm device wavesize and wavebits into compile time constants
(Feedback from AMD user)
At several points in the examples, globals are created for WAVESIZE and WAVEBITS:

https://github.com/numba/roc-examples/blob/master/numba_roc_examples/reduction/reduction.py#L7
https://github.com/numba/roc-examples/blob/master/numba_roc_examples/radixsort/roc_scan.py#L5
https://github.com/numba/roc-examples/blob/master/numba_roc_examples/kerneldensity/roc_imp.py#L17

These are in principle properties of the device, and should probably be constants in the `numba.roc` module that can be used directly without the user needing to define them.


Discussion:

Resolving patch:
diff --git a/numba/roc/hsadrv/driver.py b/numba/roc/hsadrv/driver.py
--- a/numba/roc/hsadrv/driver.py
+++ b/numba/roc/hsadrv/driver.py
@@ -452,6 +452,14 @@ def regions(self):
     def mempools(self):
         return self._mempools
 
+    @property
+    def wavebits(self):
+        """
+        log2(wavefront_size)
+        """
+        # assume wavefront_size will always be a power of 2
+        return bin(self.wavefront_size)[::-1].index('1')
+
     def _initialize_regions(self):
         region_ids = []
 


Test patch:
diff --git a/numba/roc/tests/hsadrv/test_driver.py b/numba/roc/tests/hsadrv/test_driver.py
--- a/numba/roc/tests/hsadrv/test_driver.py
+++ b/numba/roc/tests/hsadrv/test_driver.py
@@ -55,6 +55,12 @@ def test_agents_create_queue_multi(self):
                 queue = agent.create_queue_multi(2 ** 5)
                 self.assertIsInstance(queue, Queue)
 
+    def test_agent_wavebits(self):
+        for agent in roc.agents:
+            if agent.is_component:
+                if agent.name.decode() in ['gfx803', 'gfx900']:
+                    self.assertEqual(agent.wavebits, 6)
+
 
 class _TestBase(unittest.TestCase):
     def setUp(self):
Repository: numba/numba

Issue:
Negative indexing unsupported in `tuple` type.
- [x] I am using the latest released version of Numba (most recent is visible in
 the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- [x] I have included below a minimal working reproducer (if you are unsure how
 to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).

Negative indexing unsupported in `tuple` type.

From https://stackoverflow.com/questions/52777695/negative-dynamic-index-in-numba

```python
from numba import njit
@njit
def test_fn():
    tup = (3,2,4,6,2)
    total = 0
    for idx in range(5):
        total += tup[-idx]
    return total

test_fn()
```
raises `IndexError: tuple index out of range`



Discussion:

Resolving patch:
diff --git a/numba/targets/tupleobj.py b/numba/targets/tupleobj.py
--- a/numba/targets/tupleobj.py
+++ b/numba/targets/tupleobj.py
@@ -231,6 +231,10 @@ def getitem_unituple(context, builder, sig, args):
             ki = context.get_constant(types.intp, i)
             bbi = builder.append_basic_block("switch.%d" % i)
             switch.add_case(ki, bbi)
+            # handle negative indexing, create case (-tuple.count + i) to
+            # reference same block as i
+            kin = context.get_constant(types.intp, -tupty.count + i)
+            switch.add_case(kin, bbi)
             with builder.goto_block(bbi):
                 value = builder.extract_value(tup, i)
                 builder.branch(bbend)


Test patch:
diff --git a/numba/tests/test_tuples.py b/numba/tests/test_tuples.py
--- a/numba/tests/test_tuples.py
+++ b/numba/tests/test_tuples.py
@@ -186,6 +186,18 @@ def test_index(self):
         for i in range(len(tup)):
             self.assertPreciseEqual(cr.entry_point(tup, i), tup[i])
 
+        # test negative indexing
+        for i in range(len(tup) + 1):
+            self.assertPreciseEqual(cr.entry_point(tup, -i), tup[-i])
+
+        # oob indexes, +ve then -ve
+        with self.assertRaises(IndexError) as raises:
+            cr.entry_point(tup, len(tup))
+        self.assertEqual("tuple index out of range", str(raises.exception))
+        with self.assertRaises(IndexError) as raises:
+            cr.entry_point(tup, -(len(tup) + 1))
+        self.assertEqual("tuple index out of range", str(raises.exception))
+
         # Test empty tuple
         cr = compile_isolated(pyfunc,
                               [types.UniTuple(types.int64, 0), types.int64])
Repository: numba/numba

Issue:
Random Shuffle error
A minimum reproducer is shown below.  The np.random.shuffle does not shuffle the numbers in place as the normal numpy function does. 

```
import numba as nb
import numpy as np

def testSuffle():
    numbers = np.array([i for i in range(10)])
    np.random.shuffle(numbers)
    print("Without numba ",numbers)

@nb.njit()
def testNumbaShuffle():
    numbers = np.array([i for i in range(10)])
    np.random.shuffle(numbers)
    print("With numba", numbers)


if __name__ == '__main__':
    testSuffle()
    testNumbaShuffle()
```

Output

Without numba  [4 9 0 1 6 5 2 7 3 8]
With numba [0 1 2 3 4 5 6 7 8 9]



Discussion:
Bug confirmed.  It's seems to be related to the InlineClosurePass. Using `numbers = np.arange(10)` works.  The bug only occurs when a list-comprehension is used.


The InlineClosurePass is removing the shuffle call thinking it is dead by: 
https://github.com/numba/numba/blob/3b7ad858ab6b60aa1e31ca5bc905647afd0cae32/numba/ir_utils.py#L587-L590



Resolving patch:
diff --git a/numba/ir_utils.py b/numba/ir_utils.py
--- a/numba/ir_utils.py
+++ b/numba/ir_utils.py
@@ -586,7 +586,7 @@ def remove_dead_block(block, lives, call_table, arg_aliases, alias_map,
 
 def remove_dead_random_call(rhs, lives, call_list):
     if len(call_list) == 3 and call_list[1:] == ['random', numpy]:
-        return call_list[0] != 'seed'
+        return call_list[0] not in {'seed', 'shuffle'}
     return False
 
 remove_call_handlers.append(remove_dead_random_call)


Test patch:
diff --git a/numba/tests/test_comprehension.py b/numba/tests/test_comprehension.py
--- a/numba/tests/test_comprehension.py
+++ b/numba/tests/test_comprehension.py
@@ -13,6 +13,7 @@
 from numba import types, utils, jit, types
 from numba.errors import TypingError, LoweringError
 from .support import tag
+from numba.tests.support import captured_stdout
 
 from .test_parfors import _windows_py27, _32bit
 
@@ -460,6 +461,27 @@ def array_comp(n, v):
         self.assertIn("setitem: array({}, 1d, C)[0] = complex128".format(types.intp),
                       str(raises.exception))
 
+    def test_array_comp_shuffle_sideeffect(self):
+        nelem = 100
+
+        @jit(nopython=True)
+        def foo():
+            numbers = np.array([i for i in range(nelem)])
+            np.random.shuffle(numbers)
+            print(numbers)
+
+        with captured_stdout() as gotbuf:
+            foo()
+        got = gotbuf.getvalue().strip()
+
+        with captured_stdout() as expectbuf:
+            print(np.array([i for i in range(nelem)]))
+        expect = expectbuf.getvalue().strip()
+
+        # For a large enough array, the chances of shuffle to not move any
+        # element is tiny enough.
+        self.assertNotEqual(got, expect)
+        self.assertRegexpMatches(got, r'\[(\s*\d+)+\]')
 
 
 if __name__ == '__main__':
Repository: numba/numba

Issue:
simulate bug func_or_sig vs fn_or_sig named parameter
There seems to be a difference in the named parameter func_or_sig/fn_or_sig between the cuda.jit() in the simulator vs gpu code. 


Discussion:
Thanks for the report. This is clearly a mistake!

Resolving patch:
diff --git a/numba/cuda/simulator/api.py b/numba/cuda/simulator/api.py
--- a/numba/cuda/simulator/api.py
+++ b/numba/cuda/simulator/api.py
@@ -72,19 +72,19 @@ def elapsed_time(self, event):
 event = Event
 
 
-def jit(fn_or_sig=None, device=False, debug=False, argtypes=None, inline=False, restype=None,
-        fastmath=False, link=None):
+def jit(func_or_sig=None, device=False, debug=False, argtypes=None,
+        inline=False, restype=None, fastmath=False, link=None):
     if link is not None:
         raise NotImplementedError('Cannot link PTX in the simulator')
     # Check for first argument specifying types - in that case the
     # decorator is not being passed a function
-    if fn_or_sig is None or isinstance(fn_or_sig, (str, tuple, Signature)):
+    if func_or_sig is None or isinstance(func_or_sig, (str, tuple, Signature)):
         def jitwrapper(fn):
             return FakeCUDAKernel(fn,
                                   device=device,
                                   fastmath=fastmath)
         return jitwrapper
-    return FakeCUDAKernel(fn_or_sig, device=device)
+    return FakeCUDAKernel(func_or_sig, device=device)
 
 autojit = jit
 


Test patch:
Repository: numba/numba

Issue:
cuda to_device shouldn't always require writeable numpy array
Fix at https://github.com/numba/numba/blob/24aabbbd1d3a6ad87c4425bfde8e3936377b8071/numba/cuda/cudadrv/driver.py#L1497-L1507


Discussion:

Resolving patch:
diff --git a/numba/cuda/cudadrv/driver.py b/numba/cuda/cudadrv/driver.py
--- a/numba/cuda/cudadrv/driver.py
+++ b/numba/cuda/cudadrv/driver.py
@@ -1734,9 +1734,11 @@ def _workaround_for_datetime(obj):
         obj = obj.view(np.int64)
     return obj
 
+def host_pointer(obj, readonly=False):
+    """Get host pointer from an obj.
+
+    If `readonly` is False, the buffer must be writable.
 
-def host_pointer(obj):
-    """
     NOTE: The underlying data pointer from the host data buffer is used and
     it should not be changed until the operation which can be asynchronous
     completes.
@@ -1744,10 +1746,12 @@ def host_pointer(obj):
     if isinstance(obj, (int, long)):
         return obj
 
-    forcewritable = isinstance(obj, np.void) or _is_datetime_dtype(obj)
-    obj = _workaround_for_datetime(obj)
-    return mviewbuf.memoryview_get_buffer(obj, forcewritable)
+    forcewritable = False
+    if not readonly:
+        forcewritable = isinstance(obj, np.void) or _is_datetime_dtype(obj)
 
+    obj = _workaround_for_datetime(obj)
+    return mviewbuf.memoryview_get_buffer(obj, forcewritable, readonly)
 
 def host_memory_extents(obj):
     "Returns (start, end) the start and end pointer of the array (half open)."
@@ -1828,7 +1832,7 @@ def host_to_device(dst, src, size, stream=0):
     else:
         fn = driver.cuMemcpyHtoD
 
-    fn(device_pointer(dst), host_pointer(src), size, *varargs)
+    fn(device_pointer(dst), host_pointer(src, readonly=True), size, *varargs)
 
 
 def device_to_host(dst, src, size, stream=0):


Test patch:
diff --git a/numba/cuda/tests/cudadrv/test_cuda_ndarray.py b/numba/cuda/tests/cudadrv/test_cuda_ndarray.py
--- a/numba/cuda/tests/cudadrv/test_cuda_ndarray.py
+++ b/numba/cuda/tests/cudadrv/test_cuda_ndarray.py
@@ -19,6 +19,16 @@ def test_device_array_interface(self):
         self.assertEquals(dary.ndim, 1)
         devicearray.verify_cuda_ndarray_interface(dary)
 
+    def test_device_array_from_readonly(self):
+        ary = np.arange(100, dtype=np.float32)
+        # Make the array readonly
+        ary.flags.writeable = False
+        self.assertFalse(ary.flags.writeable)
+        # Ensure that we can copy the readonly array
+        dary = cuda.to_device(ary)
+        retr = dary.copy_to_host()
+        np.testing.assert_array_equal(retr, ary)
+
     def test_devicearray_no_copy(self):
         array = np.arange(100, dtype=np.float32)
         cuda.to_device(array, copy=False)
@@ -287,7 +297,7 @@ def test_devicearray_contiguous_device_strided(self):
         self.assertEqual(
             devicearray.errmsg_contiguous_buffer,
             str(e.exception))
-        
+
 
 if __name__ == '__main__':
     unittest.main()
Repository: numba/numba

Issue:
"data type not understood" with readonly array argument
## Reporting a bug

The following program should succeed, because `astype` makes a copy of its argument:

```
@nb.jit()
def numba_astype(xs):
    ys = xs.astype(nb.float32)
    ys[0] = 1.0
    return ys

xs = np.array([1.0], dtype='f4')
xs.flags.writeable = False
numba_astype(xs)
```

In fact it just throws `TypeError: data type not understood`. (This might be related to the fact that the type of the array returned by `astype` is still marked `readonly` if the inital array is `readonly` - i.e. the readonly flag is not being cleared.)


Discussion:

Resolving patch:
diff --git a/numba/typing/arraydecl.py b/numba/typing/arraydecl.py
--- a/numba/typing/arraydecl.py
+++ b/numba/typing/arraydecl.py
@@ -449,7 +449,9 @@ def resolve_astype(self, ary, args, kws):
                             "cannot convert from %s to %s"
                             % (dtype, ary, ary.dtype, dtype))
         layout = ary.layout if ary.layout in 'CF' else 'C'
-        retty = ary.copy(dtype=dtype, layout=layout)
+        # reset the write bit irrespective of whether the cast type is the same
+        # as the current dtype, this replicates numpy
+        retty = ary.copy(dtype=dtype, layout=layout, readonly=False)
         return signature(retty, *args)
 
     @bound_function("array.ravel")


Test patch:
diff --git a/numba/tests/test_array_methods.py b/numba/tests/test_array_methods.py
--- a/numba/tests/test_array_methods.py
+++ b/numba/tests/test_array_methods.py
@@ -419,6 +419,11 @@ def check(arr, dtype):
         arr = np.arange(16, dtype=np.int32)[::2]
         check(arr, np.uint64)
 
+        # check read only attr does not get copied
+        arr = np.arange(16, dtype=np.int32)
+        arr.flags.writeable = False
+        check(arr, np.int32)
+
         # Invalid conversion
         dt = np.dtype([('x', np.int8)])
         with self.assertTypingError() as raises:
Repository: numba/numba

Issue:
numpy booleans that aren't 0/1 in memory are treated differently to numpy
## Reporting a bug

- [X ] I am using the latest released version of Numba (most recent is visible in
 the change log (https://github.com/numba/numba/blob/master/CHANGE_LOG).
- [X ] I have included below a minimal working reproducer (if you are unsure how
 to write one see http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports).

It is possible for a numpy boolean array to have values other than 0 or 1 in the underlying memory, and numpy generally handles this as anything non-zero is true (modulo the occasional bug). In at least one case it seems that numba is instead taking the LSB at the boolean value.

Example code:
```python
import numpy as np
import numba

@numba.jit(nopython=True)
def copy(a, b):
    for i in range(a.shape[0]):
        a[i] = b[i]

b = np.arange(5, dtype=np.uint8).view(np.bool_)
a = np.zeros_like(b)
copy(a, b)
print(a)
```

Output:
```
[False  True False  True False]
```

Expected output (and actual output when `@numba.jit` decorator is removed):
```
[False  True  True  True  True]
```

- python 2.7.12 or 3.5.2
- numba 0.38.0
- llvmlite 0.23.0


Discussion:
We should not have truncated the byte into bit: https://github.com/numba/numba/blob/2a2b772fc0dd19dd3d6b2db2421c78c8b4da046e/numba/datamodel/models.py#L192-L193

We need to use a `!= 1`.

Resolving patch:
diff --git a/numba/datamodel/models.py b/numba/datamodel/models.py
--- a/numba/datamodel/models.py
+++ b/numba/datamodel/models.py
@@ -190,7 +190,15 @@ def as_return(self, builder, value):
         return self.as_data(builder, value)
 
     def from_data(self, builder, value):
-        return builder.trunc(value, self.get_value_type())
+        ty = self.get_value_type()
+        resalloca = cgutils.alloca_once(builder, ty)
+        cond = builder.icmp_unsigned('==', value, value.type(0))
+        with builder.if_else(cond) as (then, otherwise):
+            with then:
+                builder.store(ty(0), resalloca)
+            with otherwise:
+                builder.store(ty(1), resalloca)
+        return builder.load(resalloca)
 
     def from_argument(self, builder, value):
         return self.from_data(builder, value)


Test patch:
diff --git a/numba/tests/test_datamodel.py b/numba/tests/test_datamodel.py
--- a/numba/tests/test_datamodel.py
+++ b/numba/tests/test_datamodel.py
@@ -201,5 +201,22 @@ def test_tuple_of_array(self):
         self.assertTrue(dm.contains_nrt_meminfo())
 
 
+class TestMisc(unittest.TestCase):
+
+    def test_issue2921(self):
+        import numpy as np
+        from numba import njit
+
+        @njit
+        def copy(a, b):
+            for i in range(a.shape[0]):
+                a[i] = b[i]
+
+        b = np.arange(5, dtype=np.uint8).view(np.bool_)
+        a = np.zeros_like(b)
+        copy(a, b)
+        np.testing.assert_equal(a, np.array((False,) + (True,) * 4))
+
+
 if __name__ == '__main__':
     unittest.main()