the signature of gen_covariates in preprocess_elect.py takes a parameter num_covariates, and uses it to reshape the array it returns. However, this will crash for num_covariates < 4, since the shape of the containing array is set by num_covariates and column indices 1, 2, 3 are accessed while it is being populated with data. If the containing array is (n, 3), the function will crash when it tries to put the month in covariates[i, 3].
def gen_covariates(times, num_covariates):
covariates = np.zeros((times.shape[0], num_covariates))
for i, input_time in enumerate(times):
covariates[i, 1] = input_time.weekday()
covariates[i, 2] = input_time.hour
covariates[i, 3] = input_time.month
for i in range(1,num_covariates):
covariates[:,i] = stats.zscore(covariates[:,i])
return covariates[:, :num_covariates]
the signature of
gen_covariates
in preprocess_elect.py takes a parameternum_covariates
, and uses it to reshape the array it returns. However, this will crash fornum_covariates
< 4, since the shape of the containing array is set bynum_covariates
and column indices 1, 2, 3 are accessed while it is being populated with data. If the containing array is (n, 3), the function will crash when it tries to put the month incovariates[i, 3]
.