You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are many unused imports. While not critical, some may have import speed implications. Even if not, it tends to make maintainability a bit more difficult.
Here is the result of a check with ruff 0.3.4 (rule F401):
$ ruff check --select F401 $(find mala -name "*.py")| grep -v __init__
mala/datahandling/data_handler.py:5:29: F401 `horovod.torch` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/datahandling/data_shuffler.py:6:8: F401 [*] `mala` imported but unused
mala/datahandling/data_shuffler.py:7:36: F401 [*] `mala.common.parameters.ParametersData` imported but unused
mala/datahandling/lazy_load_dataset.py:11:30: F401 [*] `torch.utils.data.Dataset` imported but unused
mala/datahandling/lazy_load_dataset_single.py:7:30: F401 [*] `torch.utils.data.Dataset` imported but unused
mala/datahandling/lazy_load_dataset_single.py:7:39: F401 [*] `torch.utils.data.DataLoader` imported but unused
mala/datahandling/snapshot.py:2:21: F401 [*] `os.path.join` imported but unused
mala/datahandling/snapshot.py:4:17: F401 [*] `numpy` imported but unused
mala/descriptors/atomic_density.py:7:24: F401 `lammps.lammps` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/descriptors/atomic_density.py:18:43: F401 [*] `mala.descriptors.lammps_utils.set_cmdlinevars` imported but unused
mala/descriptors/bispectrum.py:7:24: F401 `lammps.lammps` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/descriptors/bispectrum.py:17:43: F401 [*] `mala.descriptors.lammps_utils.set_cmdlinevars` imported but unused
mala/descriptors/minterpy_descriptors.py:7:24: F401 `lammps.lammps` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/descriptors/minterpy_descriptors.py:18:43: F401 [*] `mala.descriptors.lammps_utils.set_cmdlinevars` imported but unused
mala/descriptors/minterpy_descriptors.py:97:28: F401 [*] `lammps.lammps` imported but unused
mala/interfaces/ase_calculator.py:4:17: F401 [*] `numpy` imported but unused
mala/interfaces/ase_calculator.py:6:69: F401 [*] `mala.Density` imported but unused
mala/interfaces/ase_calculator.py:7:18: F401 [*] `mala.DOS` imported but unused
mala/interfaces/ase_calculator.py:8:38: F401 [*] `mala.common.parallelizer.get_rank` imported but unused
mala/interfaces/ase_calculator.py:8:48: F401 [*] `mala.common.parallelizer.get_comm` imported but unused
mala/interfaces/ase_calculator_simple_ensemble.py:6:30: F401 [*] `mala.Network` imported but unused
mala/interfaces/ase_calculator_simple_ensemble.py:7:38: F401 [*] `mala.common.parallelizer.get_rank` imported but unused
mala/interfaces/ase_calculator_simple_ensemble.py:7:48: F401 [*] `mala.common.parallelizer.get_comm` imported but unused
mala/network/hyper_opt_oat.py:4:8: F401 [*] `os` imported but unused
mala/network/hyperparameter_acsd.py:2:26: F401 [*] `optuna.trial.Trial` imported but unused
mala/network/predictor.py:2:8: F401 [*] `ase.io` imported but unused
mala/network/predictor.py:4:29: F401 `horovod.torch` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/network/simple_ensemble_predictor.py:3:30: F401 [*] `zipfile.ZIP_STORED` imported but unused
mala/network/simple_ensemble_predictor.py:5:8: F401 [*] `ase.io` imported but unused
mala/network/simple_ensemble_predictor.py:7:29: F401 `horovod.torch` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/network/simple_ensemble_predictor.py:11:17: F401 [*] `numpy` imported but unused
mala/network/simple_ensemble_predictor.py:12:8: F401 [*] `torch` imported but unused
mala/network/simple_ensemble_predictor.py:14:38: F401 [*] `mala.common.parallelizer.printout` imported but unused
mala/network/simple_ensemble_predictor.py:14:48: F401 [*] `mala.common.parallelizer.get_rank` imported but unused
mala/network/simple_ensemble_predictor.py:14:58: F401 [*] `mala.common.parallelizer.barrier` imported but unused
mala/network/tester.py:3:29: F401 `horovod.torch` imported but unused; consider using `importlib.util.find_spec` to testfor availability
mala/network/trainer.py:19:38: F401 [*] `mala.common.parallelizer.parallel_warn` imported but unused
mala/network/trainer.py:21:34: F401 [*] `mala.network.network.Network` imported but unused
mala/targets/calculation_helpers.py:6:8: F401 [*] `sys` imported but unused
mala/targets/density.py:2:8: F401 [*] `os` imported but unused
mala/targets/density.py:5:8: F401 [*] `ase.io` imported but unused
mala/targets/target.py:2:17: F401 [*] `abc.ABC` imported but unused
mala/targets/target.py:7:30: F401 [*] `ase.neighborlist.NeighborList` imported but unused
Found 124 errors.
[*] 36 fixable with the `--fix` option.
I'm excluding __init__.py since imports in there are "not used" but needed for namespace reasons. There may be other false positives, but most of them are valid.
An example from mala/network/predictor.py (note that also the module doc string is the one from mala/network/tester.py, but that's a separate issue):
"""Tester class for testing a network."""importase.iotry:
importhorovod.torchashvdexceptModuleNotFoundError:
# Warning is thrown by Parameters classpass
ase.io is not used. I'm no expert in horovod so I'm not sure if importing it is needed even if not used in the code.
The text was updated successfully, but these errors were encountered:
Hi @elcorto thanks for bringing this to my attention, I will have a look! :)
I think many of these are just from checking whether or not a particular library is available. Many of these can probably be rewritten using the importlib library or be completely deleted, like the horovod import.
There are many unused imports. While not critical, some may have import speed implications. Even if not, it tends to make maintainability a bit more difficult.
Here is the result of a check with
ruff
0.3.4 (rule F401):I'm excluding
__init__.py
since imports in there are "not used" but needed for namespace reasons. There may be other false positives, but most of them are valid.An example from
mala/network/predictor.py
(note that also the module doc string is the one frommala/network/tester.py
, but that's a separate issue):ase.io
is not used. I'm no expert inhorovod
so I'm not sure if importing it is needed even if not used in the code.The text was updated successfully, but these errors were encountered: