# Typing Error and not sure why

**URL:** <https://numba.discourse.group/t/typing-error-and-not-sure-why/1913>\
**Category:** Support: What is this error message?\
**Created:** [May 2, 2023, 4:47pm UTC](https://numba.discourse.group/t/typing-error-and-not-sure-why/1913 "2023-05-02T16:47:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![QuantFreedom1022](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/quantfreedom1022/32/827_2.png) [@QuantFreedom1022](https://numba.discourse.group/u/QuantFreedom1022)\
**Post date:** [May 2, 2023, 4:47pm UTC](https://numba.discourse.group/t/typing-error-and-not-sure-why/1913/1 "2023-05-02T16:47:29Z")

</div>

hey all … i am dealing with a typing error that i really don’t understand why its happening … i have tried to change the typing and also remove default values but no matter what i do … i always get the same error … anyone have any ideas

```auto
TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Cannot unify PriceTuple(float64 x 5) and PriceTuple(float64, array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F)) for 'prices.4', defined at e:\coding\backtesters\quantfreedom\quantfreedom\nb\simulate.py (191)

File "..\quantfreedom\nb\simulate.py", line 191:
def backtest_df_only_nb(
    
                        # Process Order nb
                        account_state, order_result = process_order_nb(
                        ^

During: typing of assignment at e:\coding\backtesters\quantfreedom\quantfreedom\nb\simulate.py (191)

File "..\quantfreedom\nb\simulate.py", line 191:
def backtest_df_only_nb(
    
                        # Process Order nb
                        account_state, order_result = process_order_nb(

```

```auto
class PriceTuple(NamedTuple):
    # PossibleArray = Union[np.ndarray, int, float, bool]
    entry: float
    open: PossibleArray
    high: PossibleArray
    low: PossibleArray
    close: PossibleArray

```

Here is some info from the debugger

```auto
 prices := PriceTuple(float64, array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F)),
 prices.1 := PriceTuple(float64, array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F), array(float64, 1d, F)),
 prices.2 := PriceTuple(float64 x 5),
 prices.3 := PriceTuple(float64 x 5),
 prices.4 := PriceTuple(float64 x 5),

```

here is the link to the actual code [QuantFreedom/simulate.py at 7267b4c38f28e1d4e6e1a975cd481ed55d887394 · QuantFreedom1022/QuantFreedom · GitHub](https://github.com/QuantFreedom1022/QuantFreedom//blob/7267b4c38f28e1d4e6e1a975cd481ed55d887394/quantfreedom/nb/simulate.py#L163-L188)

---

<div class="post-metadata">

**Author:** ![gmarkall](https://yyz2.discourse-cdn.com/free1/user_avatar/numba.discourse.group/gmarkall/32/42_2.png) [@gmarkall](https://numba.discourse.group/u/gmarkall)\
**Post date:** [May 2, 2023, 11:44pm UTC](https://numba.discourse.group/t/typing-error-and-not-sure-why/1913/2 "2023-05-02T23:44:01Z")

</div>

From a quick glance, it looks like `PriceTuple` is getting two different types in two different branches. One typing is from:

```python
prices = PriceTuple(
    entry=open_prices[bar],
    open=open_prices[0 : bar + 1],
    high=high_prices[0 : bar + 1],
    low=low_prices[0 : bar + 1],
    close=close_prices[0 : bar + 1],

```

in the `if` branch, which gives you a tuple of a scalar and 4 arrays. The other is from an `else` branch:

```python
prices = PriceTuple(
    entry=open_prices[bar],
    open=open_prices[bar],
    high=high_prices[bar],
    low=low_prices[bar],
    close=close_prices[bar],

```

Which is a tuple of 5 scalars. Numba can’t unify (find a type that is common to both types) an array and a scalar. One way to allow the unification to succeed would be to make sure the last 4 elements of the tuple are all arrays in your `else` branch, like:

```python
prices = PriceTuple(
    entry=open_prices[bar],
    open=open_prices[bar:bar+1],
    high=high_prices[bar:bar+1],
    low=low_prices[bar:bar+1],
    close=close_prices[bar:bar+1],

```
