New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incompatibility between MultivariateGrouper and Numpy version 1.24 #2612
Labels
bug
Something isn't working
Comments
Here is a suggested fix for the issue, although I have only minimally tested it, so I don't know if there are incompatibilities with other parts of the code. class FixedMultivariateGrouper(MultivariateGrouper):
def _prepare_test_data(self, dataset: Dataset) -> Dataset:
assert self.num_test_dates is not None
assert len(dataset) % self.num_test_dates == 0
logging.info("group test time series to datasets")
test_length = len(dataset) // self.num_test_dates
all_entries = list()
for test_start in range(0, len(dataset), test_length):
dataset_at_test_date = dataset[test_start:test_start+test_length]
transformed_target = self._transform_target(self._left_pad_data, dataset_at_test_date)[FieldName.TARGET]
grouped_data = dict()
grouped_data[FieldName.TARGET] = np.array(
list(transformed_target), dtype=np.float32
)
for data in dataset:
fields = data.keys()
break
if FieldName.FEAT_DYNAMIC_REAL in fields:
grouped_data[FieldName.FEAT_DYNAMIC_REAL] = np.vstack(
[data[FieldName.FEAT_DYNAMIC_REAL] for data in dataset],
)
grouped_data = self._restrict_max_dimensionality(grouped_data)
grouped_data[FieldName.START] = self.first_timestamp
grouped_data[FieldName.FEAT_STATIC_CAT] = [0]
all_entries.append(grouped_data)
return ListDataset(
all_entries, freq=self.frequency, one_dim_target=False
) |
Caused by numpy/numpy#22004 |
The fix suggest by numpy would be to replace the offending line by:
Then again, I don't know anything about the |
Fixed in #2671 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
When using MultivariateGrouper to create a list of backtesting data entries, I get a
VisibleDeprecationWarning
if I have Numpy version <= 1.23 installed, and an outright error with version >= 1.24.This is due to the MultivariateGrouper combining the data of each test case in a single Numpy array, even if their dimensions is not constant.
To Reproduce
Error message or code output
On Numpy == 1.23.5:
On Numpy == 1.24.1:
Environment
The text was updated successfully, but these errors were encountered: