Closed mcocdawc closed 1 week ago
Just to give some exemplary easily avoided bugs that were found by the linting:
from molbe.external.eri_transform import get_emb_eri_fast_gdf
in kbe.pbe.eritransform_parallel
would fail, because the submodule does not even exists.
Moving all imports to the top and using libdmet.basis_transform.eri_transform.get_emb_eri_fast_gdf
throughout fixes it.
# Define fragment in the supercell
kfrag = fragpart(be_type="be2", mol=cell, kpt=kpt, frozen_core=True)
# Initialize BE
mykbe = BE(kmf, fobj, kpts=kpts)
# here the fobj is undefined and should be kfrag
mf = scf.RHF(mol)
mf.conv_tol = 1e-12
mf.kernel()
# Define fragments; use IAO scheme with 'sto-3g' as the minimal basis set
fobj = fragpart(be_type="be2", mol=mol, valence_basis="sto-3g", frozen_core=True)
# Initialize BE
mybe = BE(mg, fobj, lo_method="iao")
# here the mg is not defined and should be mf
Examples for constructs that raised a warning, but were not yet fixed because they require a deeper inspection and background knowlege:
In the following code the dm_init
is never used.
dm_init = fobj_b.get_nsocc(self.S, self.C_b, self.Nocc[1], ncore=self.ncore)
Since get_nsocc
has unfortunately side-effects, it requires more careful inspection if the line can be removed or replaced with:
fobj_b.get_nsocc(self.S, self.C_b, self.Nocc[1], ncore=self.ncore)
i.e. call get_nsocc
purely for its side-effect.
There is a line
ovlp_ciao = uciao[k].conj().T @ self.S[k] @ Ciao[k]
The name uciao
is undefined, most likely it should be
ovlp_ciao = Ciao[k].conj().T @ self.S[k] @ Ciao[k]
but one has to make sure this was actually intended.
The variable ECOUL
is unused and initialized to 0.0
ECOUL = 0.0
lateron in the code a variable ecoul
is used.
Most likely this was a typo and mismatched lower- vs upper-case.
In the function get_dt1ao_an
the variable deov
is assigned to but never used.
Since someone actually chose a name for it
deov = get_Dia_r(dmoe, no)
it might actually be relevant for later expressions and was just forgotten.
PR is postponed
Only merge after the current test-suite is fixed #53 Adresses one task in #54 merge after #55 and #56
made manual fixes of which I am sure and ignore E741
I fixed many of the reported warnings/errors, but the unused/undeclared variables still pose a problem for the following reasons:
Sometimes they come from function calls that have side effects, i.e. the function call has to be retained (perhaps)
They seem like typos or inconsisten casing, e.g. COUL vs. coul, that appears later in the code
Overall fixing these reported problems requires some deeper knowledge of the surrounding code.
ignore E741 in ruff linting https://docs.astral.sh/ruff/rules/ambiguous-variable-name/