# No implementation of function for making an array

**URL:** <https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320>\
**Category:** Support: What is this error message?\
**Created:** [October 29, 2020, 8:21pm UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320 "2020-10-29T20:21:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ismaelbrowne](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/ismaelbrowne/32/137_2.png) [@ismaelbrowne](https://numba.discourse.group/u/ismaelbrowne)\
**Post date:** [October 29, 2020, 8:21pm UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/1 "2020-10-29T20:21:36Z")

</div>

Hello.  
I´m trying to make an array with numpy for to later insert tuples into indexes.  
This is the relevant line: `lis=np.zeros(int((n+1)*(n/2+1)), dtype=(np.int16,np.int16,np.int16))`  
And it gives out this error:  
`TypingError: No implementation of function Function() found for signature:

zeros(int64, dtype=UniTuple(class(int16) x 3))

There are 2 candidate implementations:  
- Of which 2 did not match due to:  
Overload of function ‘zeros’: File: numba\core\typing\npydecl.py: Line 504.  
With argument(s): ‘(int64, dtype=UniTuple(class(int16) x 3))’:  
No match.`  
What other numpy function can I use to make an array like this one?

---

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [October 29, 2020, 9:05pm UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/2 "2020-10-29T21:05:21Z")

</div>

hi @ismaelbrowne, are you sure that line is valid numpy? I cannot get it running

```python
np.zeros(10, dtype=(np.int16,np.int16,np.int16))

TypeError: Tuple must have size 2, but has size 3 

```

What type of array are you trying to build?

Luk

---

<div class="post-metadata">

**Author:** ![ismaelbrowne](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/ismaelbrowne/32/137_2.png) [@ismaelbrowne](https://numba.discourse.group/u/ismaelbrowne)\
**Post date:** [October 29, 2020, 9:55pm UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/3 "2020-10-29T21:55:29Z")

</div>

If you don’t jit the function, the first element in dtype should be the type of the elements in the tuple, and the second is the amount of those elements per tuple, so `dtype=(np.int16,2)` would mean that each tuple has 2 int16 elements inside. But when you jit the function, it requires, at least from how I saw it interpreted the function, to put the type as many times as elements will be in each tuple, so `dtype=(np.int16,np.int16,np.int16)` would mean that each tuple has 3 int16 elements inside. Also, I’m trying to build a 1d array of tuples which contain 3 elements each.

---

<div class="post-metadata">

**Author:** ![luk-f-a](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/luk-f-a/32/56_2.png) [@luk-f-a](https://numba.discourse.group/u/luk-f-a)\
**Post date:** [October 30, 2020, 8:01am UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/4 "2020-10-30T08:01:18Z")

</div>

> [@ismaelbrowne](#):
>
> `dtype=(np.int16,np.int16,np.int16)` would mean that each tuple has 3 int16 elements inside.

Sorry if I didn’t explain myself better, what I wanted to say is that `dtype=(np.int16,np.int16,np.int16)` is not valid Numpy, so it will never be valid in Numba.

---

<div class="post-metadata">

**Author:** ![stuartarchibald](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/stuartarchibald/32/10_2.png) [@stuartarchibald](https://numba.discourse.group/u/stuartarchibald)\
**Post date:** [October 30, 2020, 10:01am UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/5 "2020-10-30T10:01:07Z")

</div>

Hi @ismaelbrowne

Numba won’t work with a 1d array of tuples, as I think that requires an object dtype? If you need a 1d array with 3 elements in each location perhaps consider using a [structured dtype/record array](https://numpy.org/doc/stable/user/basics.rec.html). For example, in NumPy:

```auto
In [37]: np.zeros(4, dtype=[(f'f{x}', np.int16) for x in range(3)])
Out[37]: 
array([(0, 0, 0), (0, 0, 0), (0, 0, 0), (0, 0, 0)],
      dtype=[('f0', '<i2'), ('f1', '<i2'), ('f2', '<i2')])

```

in Numba, the type will need to be specified outside of the jit compiled function due to limitations in the compiler. Example:

```python
In [67]: dt=np.dtype([(f'f{x}', np.int16) for x in range(3)])

In [68]: dt
Out[68]: dtype([('f0', '<i2'), ('f1', '<i2'), ('f2', '<i2')])

In [69]: @njit
    ...: def foo():
    ...: n = 4
    ...: x = np.zeros(n, dtype=dt)
    ...: for i in range(n):
    ...: x[i].f0 = 1 + i
    ...: x[i].f1 = 2 + i
    ...: x[i].f2 = 3 + i
    ...: return x
    ...: 

In [70]: foo()
Out[70]: 
array([(1, 2, 3), (2, 3, 4), (3, 4, 5), (4, 5, 6)],
      dtype=[('f0', '<i2'), ('f1', '<i2'), ('f2', '<i2')])

```

hope this helps?

---

<div class="post-metadata">

**Author:** ![ismaelbrowne](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/ismaelbrowne/32/137_2.png) [@ismaelbrowne](https://numba.discourse.group/u/ismaelbrowne)\
**Post date:** [October 30, 2020, 10:56am UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/6 "2020-10-30T10:56:11Z")

</div>

So that was it, I needed to specify the type outside of the jitted function.  
Thank you very much!

---

<div class="post-metadata">

**Author:** ![stuartarchibald](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/stuartarchibald/32/10_2.png) [@stuartarchibald](https://numba.discourse.group/u/stuartarchibald)\
**Post date:** [November 3, 2020, 9:04pm UTC](https://numba.discourse.group/t/no-implementation-of-function-for-making-an-array/320/7 "2020-11-03T21:04:02Z")

</div>

No problem, glad you have something that works.
