Typing Error and not sure why

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

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(
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

 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

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

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:

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:

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],