-
Notifications
You must be signed in to change notification settings - Fork 1
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
π Bug Report
Running the preprocessing pipeline with NumPy 2.x results in the following error:
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
π Location
File: chebai_graph/preprocessing/properties.py
Line: 158
Function: get_property_value
np.nan_to_num(features_normalized, copy=False)
π₯ Cause
In NumPy 2.0, the copy=False
argument is now strictly enforced β it raises an error if avoiding a copy isnβt possible.
See: NumPy 2.0 Migration Guide
β Proposed Fix
Replace:
np.nan_to_num(features_normalized, copy=False)
with:
features_normalized = np.nan_to_num(features_normalized)
This ensures compatibility with both NumPy 1.x and 2.x versions.
π Related Stack Trace
G:\anaconda3\envs\gnn3\python.exe -m chebai fit --trainer=configs/training/default_trainer.yml --model=../python-chebai-graph/configs/model/gnn_res_gated.yml --model.train_metrics=configs/metrics/micro-macro-f1.yml --model.test_metrics=configs/metrics/micro-macro-f1.yml --model.val_metrics=configs/metrics/micro-macro-f1.yml --data=../python-chebai-graph/configs/data/chebi50_graph_properties.yml --data.init_args.batch_size=128 --trainer.accumulate_grad_batches=4 --data.init_args.num_workers=10 --model.pass_loss_kwargs=false --data.init_args.chebi_version=231 --trainer.min_epochs=1 --trainer.max_epochs=1 --model.criterion=configs/loss/bce.yml --model.criterion.init_args.beta=0.99 --trainer.logger.init_args.name=resgated_gnn
G:\anaconda3\envs\gnn3\lib\site-packages\lightning\fabric\utilities\seed.py:42: No seed found, seed set to 0
Seed set to 0
Checking for processed data in data\chebi_v231\ChEBI50\processed
Data module uses these properties (ordered): AtomAromaticity, AtomCharge, AtomHybridization, AtomNumHs, AtomType, BondAromaticity, BondInRing, BondType, NumAtomBonds, RDKit2DNormalized
Check for processed data in data\chebi_v231\ChEBI50\processed\graph_properties
Cross-validation enabled: False
Number of labels for loaded data: 1511
Feature vector size: 3
Processing property AtomAromaticity
100%|ββββββββββ| 20/20 [00:00<00:00, 185.79it/s]
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
Processing property AtomCharge
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 66.08it/s]
saved index of property AtomCharge to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\AtomCharge\indices_one_hot.txt, index length: 13 (new: 0)
saved index of property AtomHybridization to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\AtomHybridization\indices_one_hot.txt, index length: 7 (new: 0)
Processing property AtomHybridization
100%|ββββββββββ| 20/20 [00:00<00:00, 15670.85it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 20020.54it/s]
Processing property AtomNumHs
100%|ββββββββββ| 20/20 [00:00<00:00, 20039.68it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 20073.24it/s]
Processing property AtomType
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 10033.02it/s]
Processing property BondAromaticity
0%| | 0/20 [00:00<?, ?it/s]saved index of property AtomNumHs to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\AtomNumHs\indices_one_hot.txt, index length: 7 (new: 0)
saved index of property AtomType to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\AtomType\indices_one_hot.txt, index length: 119 (new: 0)
100%|ββββββββββ| 20/20 [00:00<00:00, 827.75it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 19987.15it/s]
Processing property BondInRing
100%|ββββββββββ| 20/20 [00:00<00:00, 20799.92it/s]
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
Processing property BondType
100%|ββββββββββ| 20/20 [00:00<00:00, 20763.88it/s]
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
Processing property NumAtomBonds
100%|ββββββββββ| 20/20 [00:00<?, ?it/s]
100%|ββββββββββ| 20/20 [00:00<00:00, 9873.60it/s]
Processing property RDKit2DNormalized
0%| | 0/20 [00:00<?, ?it/s]saved index of property BondType to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\BondType\indices_one_hot.txt, index length: 5 (new: 0)
saved index of property NumAtomBonds to G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\bin\NumAtomBonds\indices_one_hot.txt, index length: 11 (new: 0)
Generate dynamic splits...
Generate dynamic splits...
Generate dynamic splits...
Generate dynamic splits...
Traceback (most recent call last):
File "G:\anaconda3\envs\gnn3\lib\site-packages\jsonargparse\_link_arguments.py", line 267, in call_compute_fn
return self.compute_fn(*args)
File "G:\github-aditya0by0\python-chebai\chebai\cli.py", line 46, in call_data_methods
data.setup()
File "G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\datasets\chebi.py", line 141, in setup
self._setup_properties()
File "G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\datasets\chebi.py", line 109, in _setup_properties
property_values = [
File "G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\datasets\chebi.py", line 110, in <listcomp>
self.reader.read_property(feat, property)
File "G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\reader.py", line 78, in read_property
return property.get_property_value(mol)
File "G:\github-aditya0by0\python-chebai-graph\chebai_graph\preprocessing\properties.py", line 158, in get_property_value
np.nan_to_num(features_normalized, copy=False)
File "G:\anaconda3\envs\gnn3\lib\site-packages\numpy\lib\_type_check_impl.py", line 458, in nan_to_num
x = _nx.array(x, subok=True, copy=copy)
ValueError: Unable to avoid copy while creating an array as requested.
If using `np.array(obj, copy=False)` replace it with `np.asarray(obj)` to allow a copy when needed (no behavior change in NumPy 1.x).
For more details, see https://numpy.org/devdocs/numpy_2_0_migration_guide.html#adapting-to-changes-in-the-copy-keyword.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working