diff --git a/CHANGELOG.md b/CHANGELOG.md index 3294cb7814f8..beca7e02edc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,9 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `BaseStorage.get()` functionality ([#5240](https://github.com/pyg-team/pytorch_geometric/pull/5240)) - Added a test to confirm that `to_hetero` works with `SparseTensor` ([#5222](https://github.com/pyg-team/pytorch_geometric/pull/5222)) ### Changed -- Changed tests relying on `dblp` datasets to instead use synthetic data. ([#5250](https://github.com/pyg-team/pytorch_geometric/pull/5250)) -- Fixed a bug for the initialization of activation function examples in `custom_graphgym`. ([#5243](https://github.com/pyg-team/pytorch_geometric/pull/5243)) +- Do not fill `InMemoryDataset` cache on `dataset.num_features` ([#5264](https://github.com/pyg-team/pytorch_geometric/pull/5264)) +- Changed tests relying on `dblp` datasets to instead use synthetic data ([#5250](https://github.com/pyg-team/pytorch_geometric/pull/5250)) +- Fixed a bug for the initialization of activation function examples in `custom_graphgym` ([#5243](https://github.com/pyg-team/pytorch_geometric/pull/5243)) ### Removed ## [2.1.0] - 2022-08-17 diff --git a/torch_geometric/data/dataset.py b/torch_geometric/data/dataset.py index cf006b5f1054..87c88670de64 100644 --- a/torch_geometric/data/dataset.py +++ b/torch_geometric/data/dataset.py @@ -101,6 +101,9 @@ def processed_dir(self) -> str: def num_node_features(self) -> int: r"""Returns the number of features per node in the dataset.""" data = self[0] + # Do not fill cache for `InMemoryDataset`: + if hasattr(self, '_data_list') and self._data_list is not None: + self._data_list[0] = None data = data[0] if isinstance(data, tuple) else data if hasattr(data, 'num_node_features'): return data.num_node_features @@ -117,6 +120,9 @@ def num_features(self) -> int: def num_edge_features(self) -> int: r"""Returns the number of features per edge in the dataset.""" data = self[0] + # Do not fill cache for `InMemoryDataset`: + if hasattr(self, '_data_list') and self._data_list is not None: + self._data_list[0] = None data = data[0] if isinstance(data, tuple) else data if hasattr(data, 'num_edge_features'): return data.num_edge_features