irreducible-representations / irrep

GNU General Public License v3.0
62 stars 31 forks source link

Revisiting the structure of the code #70

Closed MIraola closed 4 months ago

MIraola commented 6 months ago

This is a PR which implements several modifications to the code. The code has been tested for all DFT codes and the compatibility with banduppy has been checked. Of course, we can never discard completely the potential existence of bugs.

Summary of changes

Simplification of the structure

To do:

stepan-tsirkin commented 6 months ago

Hi @MIraola

I would suggest you fix all 'F' problems that flake8 detects. Mostly it is just removing unnecessary imports, but one should be careful, sometimes it can signal a bug, for example if a variable is assigned and never used, there might be a typo in that variable, or you forgot to do something that should have been done.

See here:

stepan@stepan-desktop:~/github/irrep/irrep$ flake8 --select=F
./bandstructure.py:25:1: F401 '.utility.str2bool' imported but unused
./bandstructure.py:25:1: F401 '.utility.BOHR' imported but unused
./bandstructure.py:25:1: F401 '.utility.split' imported but unused
./bandstructure.py:26:1: F401 '.readfiles.Hartree_eV' imported but unused
./bandstructure.py:27:1: F401 '.readfiles.WAVECARFILE' imported but unused
./bandstructure.py:191:21: F841 local variable 'IBstartE' is assigned to but never used
./bandstructure.py:700:9: F841 local variable 'nmax' is assigned to but never used
./cli.py:22:1: F401 'sys' imported but unused
./cli.py:24:1: F401 'datetime' imported but unused
./cli.py:25:1: F401 'math' imported but unused
./cli.py:30:1: F401 '.spacegroup.SpaceGroup' imported but unused
./cli.py:32:1: F401 '.utility.str2bool' imported but unused
./cli.py:336:9: F841 local variable 'preline' is assigned to but never used
./cli.py:408:17: F841 local variable 'plotfile' is assigned to but never used
./gvectors.py:232:5: F841 local variable 'npw1' is assigned to but never used
./gvectors.py:321:21: F523 '...'.format(...) has unused arguments at position(s): 0
./gvectors.py:321:21: F524 '...'.format(...) is missing argument(s) for placeholder(s): other
./gvectors.py:322:29: F821 undefined name 'other'
./kpoint.py:22:1: F401 '.gvectors.calc_gvectors' imported but unused
./kpoint.py:22:1: F401 '.gvectors.sortIG' imported but unused
./kpoint.py:23:1: F401 '.readfiles.Hartree_eV' imported but unused
./kpoint.py:24:1: F401 '.readfiles.record_abinit' imported but unused
./kpoint.py:26:1: F401 'scipy.io.FortranFile as FF' imported but unused
./kpoint.py:161:17: F841 local variable 'err' is assigned to but never used
./kpoint.py:764:75: F821 undefined name 'd'
./kpoint.py:783:29: F821 undefined name 'preline'
./readfiles.py:327:24: F841 local variable 'occ' is assigned to but never used
./readfiles.py:373:9: F841 local variable 'title' is assigned to but never used
./readfiles.py:468:9: F841 local variable 'err' is assigned to but never used
./readfiles.py:487:9: F841 local variable 'nat' is assigned to but never used
./readfiles.py:604:21: F841 local variable 'j' is assigned to but never used
./spacegroup.py:561:9: F841 local variable 'nsym' is assigned to but never used
./spacegroup.py:690:13: F841 local variable 'write_ref' is assigned to but never used
./spacegroup.py:876:9: F841 local variable 'nmax' is assigned to but never used
./spacegroup.py:936:21: F841 local variable 'err' is assigned to but never used
./spacegroup.py:1037:13: F841 local variable 'found' is assigned to but never used
./spacegroup.py:1159:9: F841 local variable 'errtxt' is assigned to but never used
./tests/test_abinit_scalar.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_abinit_spinor.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_espresso_spinor.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_refUC.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_symsep.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_vasp_scalar.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_vasp_spinor.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_wannier_scalar.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
./tests/test_wannier_spinor.py:4:1: F401 'monty.serialization.dumpfn' imported but unused
MIraola commented 6 months ago

Hi @stepan-tsirkin ,

thank you for the recommendation. I have fixed the F errors of flake8 as you suggested. There is an error left which is in the WCC routines; I am pretty sure that removing it will do nothing, but I leave it since I try not to do changes to this routines until we fully test them.

The flake8 is really helpful and it works very well! I will use it from now on.

MIraola commented 4 months ago

I have...

MIraola commented 4 months ago

Done, thanks!

I agree, we can address the remaining issues in smaller and more dedicated PRs.