zhykoties / TimeSeries

Implementation of deep learning models for time series in PyTorch.
Apache License 2.0
372 stars 98 forks source link

bug in gen_covariates #1

Closed jonathanstrong closed 4 years ago

jonathanstrong commented 5 years ago

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]
zhykoties commented 5 years ago

This part is hard-coded. You will have to change what goes inside which dimension manually.