Operands could not be broadcast together with shapes (5,) (2,) For train_val_split

Hi,
I’m getting the following feedbacks upon submitting the Week 1 Assignment and got the score 0. Other functions are all passed though. I can’t find any issue with my code though. any ideas?

Define time step to split the series

SPLIT_TIME = 1100

GRADED FUNCTION: train_val_split

def train_val_split(time, series, time_step=SPLIT_TIME):

### START CODE HERE
time_train = time[:SPLIT_TIME]
series_train = series[:SPLIT_TIME]
time_valid = time[SPLIT_TIME:]
series_valid = series[SPLIT_TIME:]
### END CODE HERE

return time_train, series_train, time_valid, series_valid
1 Like

Hello @wokee, thanks for reaching out.
It is always better to work with local variables in functions and not with global ones. Use time_step instead of SPLIT_TIME.

4 Likes

oops! totally missed that :smile:
I must have copied variable name too much. haha.
Thank @m.abidat . I have resubmitted and passed 80/80 now.

Congrats! happy learning!

Thank you so much! I had the same problem.

1 Like

Thanks you for the information. I had used the global variable too. I’ll be watching for local variables more now.

Thank you…it was the crucial piece that I missed earlier!