Closed njzjz closed 2 months ago
dpgen/auto_test/mpdb.py (1)
`9-10`: **LGTM! Import localized within the function.** The import of `MPRester` and `MPRestError` within the function scope improves module loading efficiency and avoids unnecessary imports when the function is not called.dpgen/auto_test/lib/crys.py (7)
`5-6`: **LGTM! Import localized within the function.** The import of `Structure` within the function scope improves module loading efficiency and avoids unnecessary imports when the function is not called. --- `13-15`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called. --- `25-27`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called. --- `33-35`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called. --- `50-52`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called. --- `66-68`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called. --- `87-89`: **LGTM! Imports localized within the function.** The imports of `Lattice` and `Structure` within the function scope improve module loading efficiency and avoid unnecessary imports when the function is not called.dpgen/generator/lib/ele_temp.py (2)
`88-89`: **LGTM! Import localized within the method.** The import of `Incar` within the method scope improves module loading efficiency and avoids unnecessary imports when the method is not called. --- `95-96`: **LGTM! Import localized within the method.** The import of `Incar` within the method scope improves module loading efficiency and avoids unnecessary imports when the method is not called.dpgen/generator/lib/vasp.py (1)
`133-134`: **LGTM! Import localized within the function.** The import of `Incar` within the function scope improves module loading efficiency and avoids unnecessary imports when the function is not called.dpgen/database/entry.py (1)
`54-55`: **Good practice: Localized import.** Moving the import of `Composition` to within the `__init__` method ensures that `pymatgen` is only imported when an instance of `Entry` is created. This can help avoid unnecessary imports and potential import errors if `pymatgen` is not installed.pyproject.toml (3)
`92-92`: **Good practice: Enforcing linting rules.** Adding the linting rule `TID253` to the `select` list ensures that module-level imports of banned modules are flagged by the linter, promoting better import practices. --- `116-119`: **Good practice: Banning module-level imports.** Adding `pymatgen` to the `banned-module-level-imports` list ensures that module-level imports of `pymatgen` are flagged, aligning with the PR objective to move such imports to runtime. --- `121-122`: **Good practice: Extending per-file ignores.** Adding the rule `TID253` to the per-file ignores for files under `tests/` ensures that test files are not flagged for module-level imports, which might be necessary for testing purposes.dpgen/auto_test/gen_confs.py (3)
`20-21`: **Good practice: Localized import.** Moving the import of `StructureMatcher` to within the `test_fit` function ensures that `pymatgen` is only imported when the function is called. This can help avoid unnecessary imports if the function is not used. --- `52-54`: **Good practice: Localized imports.** Moving the imports of `StructureMatcher` and `MPRester` to within the `gen_element` function ensures that `pymatgen` is only imported when the function is called. This can help avoid unnecessary imports if the function is not used. --- `98-99`: **Good practice: Localized import.** Moving the import of `MPRester` to within the `gen_alloy` function ensures that `pymatgen` is only imported when the function is called. This can help avoid unnecessary imports if the function is not used.dpgen/database/vasp.py (3)
`20-21`: **Good practice: Localized imports.** Moving the imports of `Potcar` and `PotcarSingle` to within the `__init__` method ensures that `pymatgen` is only imported when an instance of `DPPotcar` is created. This can help avoid unnecessary imports if the class is not used. --- `83-84`: **Good practice: Localized import.** Moving the import of `Potcar` to within the `from_file` method ensures that `pymatgen` is only imported when the method is called. This can help avoid unnecessary imports if the method is not used. --- `183-184`: **Good practice: Localized imports.** Moving the imports of `Incar`, `Kpoints`, and `Poscar` to within the `from_directory` method ensures that `pymatgen` is only imported when the method is called. This can help avoid unnecessary imports if the method is not used.dpgen/auto_test/VASP.py (2)
`23-24`: **LGTM! Localized import for `Structure`.** The import of `Structure` has been moved to within the method, which is a good practice for optimizing imports. --- `72-73`: **LGTM! Localized imports for `Incar` and `Kpoints`.** The imports of `Incar` and `Kpoints` have been moved to within the method, which is a good practice for optimizing imports.dpgen/auto_test/Vacancy.py (1)
`78-80`: **LGTM! Localized imports for `VacancyGenerator` and `Structure`.** The imports of `VacancyGenerator` and `Structure` have been moved to within the method, which is a good practice for optimizing imports.dpgen/auto_test/Elastic.py (3)
`51-53`: **LGTM! Localized imports for `DeformedStructureSet`, `Strain`, and `Structure`.** The imports of `DeformedStructureSet`, `Strain`, and `Structure` have been moved to within the method, which is a good practice for optimizing imports. --- `190-191`: **LGTM! Localized imports for `Incar` and `Kpoints`.** The imports of `Incar` and `Kpoints` have been moved to within the method, which is a good practice for optimizing imports. --- `253-255`: **LGTM! Localized imports for `ElasticTensor` and `Stress`.** The imports of `ElasticTensor` and `Stress` have been moved to within the method, which is a good practice for optimizing imports.dpgen/auto_test/Surface.py (1)
`86-88`: **LGTM! Localized imports for `Structure` and `generate_all_slabs`.** The imports of `Structure` and `generate_all_slabs` have been moved to within the method, which is a good practice for optimizing imports.dpgen/auto_test/lib/vasp.py (1)
`505-506`: **LGTM! Imports moved inside the function.** The import statements for `Incar` and `Kpoints` were moved inside the `make_vasp_kpoints_from_incar` function to avoid module-level imports of `pymatgen`. This change ensures that the import is only done when necessary.dpgen/auto_test/Gamma.py (2)
`95-96`: **LGTM! Import moved inside the method.** The import statement for `Structure` was moved inside the `make_confs` method to avoid module-level imports of `pymatgen`. This change ensures that the import is only done when necessary. --- `290-291`: **LGTM! Import moved inside the method.** The import statement for `AseAtomsAdaptor` was moved inside the `__gen_slab_ase` method to avoid module-level imports of `pymatgen`. This change ensures that the import is only done when necessary.dpgen/data/surf.py (3)
`166-167`: **LGTM! Import moved inside the function.** The import statement for `Structure` was moved inside the `poscar_elong` function to avoid module-level imports of `pymatgen`. This change ensures that the import is only done when necessary. --- `215-217`: **LGTM! Imports moved inside the function.** The import statements for `Element`, `Structure`, and `AseAtomsAdaptor` were moved inside the `make_super_cell_pymatgen` function to avoid module-level imports of `pymatgen`. This change ensures that the imports are only done when necessary. --- `404-405`: **LGTM! Import moved inside the function.** The import statement for `Poscar` was moved inside the `poscar_scale` function to avoid module-level imports of `pymatgen`. This change ensures that the import is only done when necessary.dpgen/auto_test/Interstitial.py (1)
`79-81`: **LGTM! Imports moved inside the method.** The import statements for `InterstitialGenerator` and `Structure` were moved inside the `make_confs` method to avoid module-level imports of `pymatgen`. This change ensures that the imports are only done when necessary.dpgen/data/gen.py (4)
`301-302`: **LGTM! Import moved to runtime.** The import of `Structure` from `pymatgen.core` has been moved to runtime, which is appropriate to avoid module-level import issues. --- `345-346`: **LGTM! Import moved to runtime.** The import of `Structure` from `pymatgen.core` has been moved to runtime, which is appropriate to avoid module-level import issues. --- `1449-1450`: **LGTM! Import moved to runtime.** The import of `Incar` from `pymatgen.io.vasp` has been moved to runtime, which is appropriate to avoid module-level import issues. --- `1449-1450`: **LGTM! Import moved to runtime.** The import of `Incar` from `pymatgen.io.vasp` has been moved to runtime, which is appropriate to avoid module-level import issues.dpgen/generator/run.py (2)
`3080-3081`: **LGTM!** The import statement for `Incar` is correctly moved to within the function to avoid unnecessary module-level imports. --- `3159-3160`: **LGTM!** The import statements for `Incar` and `Kpoints` are correctly moved to within the function to avoid unnecessary module-level imports.
Attention: Patch coverage is 54.90196%
with 23 lines
in your changes missing coverage. Please review.
Project coverage is 49.51%. Comparing base (
a33e270
) to head (8c541b7
). Report is 2 commits behind head on devel.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Pymatgen is still imcompatbile with NumPy 2. Move the import into runtime to fix the documentation builds and prevent potential errors when one uses dpgen without using pymatgen.
Signed-off-by: Jinzhe Zeng jinzhe.zeng@rutgers.edu
Summary by CodeRabbit
pyproject.toml
to include new rules and per-file exceptions.