Skip to content

Commit

Permalink
pylint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippRue committed Nov 20, 2024
1 parent eb18b6c commit bbcd765
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 38 deletions.
1 change: 1 addition & 0 deletions aiida_kkr/calculations/kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def _get_and_verify_hostfiles(self, tempfolder):
parent_calc = parent_calcs.first().node
# extract impurity_info
found_impurity_inputnode = False
found_host_parent = False
if 'impurity_info' in self.inputs:
imp_info_inputnode = self.inputs.impurity_info
if not isinstance(imp_info_inputnode, Dict):
Expand Down
4 changes: 2 additions & 2 deletions aiida_kkr/calculations/kkrnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ def prepare_for_submission(self, tempfolder):

if noco:
with tempfolder.open(self._DEFAULT_NOCO_INPUT_FILE, u'w') as nonco_angles_handle:
self._write_nonco_angles(nonco_angles_handle, nonco_angles, structure)
self._write_nonco_angles(nonco_angles_handle, nonco_angles, structure) # pylint: disable=possibly-used-before-assignment

# Prepare rbasis.xyz and input.conf from Structure and input parameter data unless convert mode
if not convert:
Expand All @@ -288,7 +288,7 @@ def prepare_for_submission(self, tempfolder):
self._write_rbasis(rbasis_handle, structure, passed_lattice_const)
if write_efermi:
with tempfolder.open(self._DEFAULT_EFERMI_FILE, u'w') as efermi_file_handle:
self._write_efermi_file(efermi_file_handle, fermi)
self._write_efermi_file(efermi_file_handle, fermi) # pylint: disable=used-before-assignment

# Prepare potential and shapefun file from strucwithpot, if necessary
if use_strucwithpot:
Expand Down
8 changes: 4 additions & 4 deletions aiida_kkr/calculations/voro.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def prepare_for_submission(self, tempfolder):
vca_structure = False
if found_structure:
# for VCA: check if input structure and parameter node define VCA structure
vca_structure = vca_check(structure, parameters)
vca_structure = vca_check(structure, parameters) # pylint: disable=used-before-assignment

code = self.inputs.code

Expand All @@ -120,7 +120,7 @@ def prepare_for_submission(self, tempfolder):

if found_parent:
# check if parent is either Voronoi or previous KKR calculation
overwrite_potential, parent_calc = self._check_valid_parent(parent_calc_folder)
overwrite_potential, parent_calc = self._check_valid_parent(parent_calc_folder) # pylint: disable=possibly-used-before-assignment

#cross check if no structure was given and extract structure from parent
if found_structure and not vca_structure:
Expand Down Expand Up @@ -188,7 +188,7 @@ def prepare_for_submission(self, tempfolder):
outfolder = parent_calc.outputs.retrieved # copy from remote folder
copylist = [parent_calc.process_class._OUT_POTENTIAL]
elif has_potfile_overwrite:
outfolder = potfile_overwrite # copy from potential sfd
outfolder = potfile_overwrite # copy from potential sfd # pylint: disable=possibly-used-before-assignment
copylist = [potfile_overwrite.filename]
else:
copylist = []
Expand All @@ -197,7 +197,7 @@ def prepare_for_submission(self, tempfolder):
filename = file1
if (found_parent or has_potfile_overwrite) and file1 == copylist[0]:
filename = self._POTENTIAL_IN_OVERWRITE
local_copy_list.append((outfolder.uuid, file1, filename))
local_copy_list.append((outfolder.uuid, file1, filename)) # pylint: disable=possibly-used-before-assignment

# add shapefun to overwrite
if 'shapefun_overwrite' in self.inputs:
Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/parsers/kkrnano.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def _findSimpleEntries(self, string2find, retrieved_folder, output_file_name, li
array = np.genfromtxt(StringIO(keyvalue.replace('D', 'e')), delimiter=' ', dtype=None) #[0]

try:
returnlist.append(array.item()[0])
returnlist.append(array.item()[0]) # pylint: disable=possibly-used-before-assignment
except TypeError:
returnlist.append(array.item())

Expand Down
2 changes: 1 addition & 1 deletion aiida_kkr/tools/imp_cluster_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def create_combined_imp_info(

# set zimp in scoef file (not used by the code but makes it easier to read the files / debug)
if single_single:
clust1[0][4] = zimp1
clust1[0][4] = zimp1 # pylint: disable=possibly-used-before-assignment
clust2[0][4] = zimp2
#if debug:
# print('cls1:', clust1)
Expand Down
12 changes: 6 additions & 6 deletions aiida_kkr/tools/ldau.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,9 @@ def get_ldaumatrices(retrieved):
iphi = ii
ii += 1
# save matrices to output dict
txt_dict_ldaumats['wldau'] = txt[iwldau + 1:iuldau]
txt_dict_ldaumats['uldau'] = txt[iuldau + 1:iphi]
txt_dict_ldaumats['phi'] = txt[iphi + 1:]
txt_dict_ldaumats['wldau'] = txt[iwldau + 1:iuldau] # pylint: disable=possibly-used-before-assignment
txt_dict_ldaumats['uldau'] = txt[iuldau + 1:iphi] # pylint: disable=possibly-used-before-assignment
txt_dict_ldaumats['phi'] = txt[iphi + 1:] # pylint: disable=possibly-used-before-assignment

return has_ldaupot_file, txt_dict_ldaumats

Expand Down Expand Up @@ -164,8 +164,8 @@ def get_LDAU_initmatrices_dict(txts_ldaumat1, offset=0):
# Fill the dictionary with atom-wise information
for iatom in range(len(iatoms)):
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}'] = {}
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['wldau'] = wldaumat[iatom]
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['uldau'] = uldaumat[iatom]
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['phi'] = phimat[iatom]
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['wldau'] = wldaumat[iatom] # pylint: disable=possibly-used-before-assignment
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['uldau'] = uldaumat[iatom] # pylint: disable=used-before-assignment
LDAU_initmatrices_dict[f'iatom={int(iatoms[iatom])-1+offset}']['phi'] = phimat[iatom] # pylint: disable=used-before-assignment

return LDAU_initmatrices_dict
4 changes: 2 additions & 2 deletions aiida_kkr/tools/plot_kkr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1307,7 +1307,7 @@ def plot_kkrimp_dos_wc(self, node, **kwargs):
from aiida_kkr.tools import find_parent_structure
natoms = get_natyp(find_parent_structure(calcnode))
self.dosplot(
d,
d, # pylint: disable=possibly-used-before-assignment
natoms,
nofig,
all_atoms,
Expand Down Expand Up @@ -1536,7 +1536,7 @@ def plot_kkr_startpot(self, node, **kwargs):
tit_add = ''
if emin is not None:
axvline(emin, color='r', ls='--', label='emin')
if ef_Ry is not None and len(ecore_max) > 0:
if ef_Ry is not None and len(ecore_max) > 0: # pylint: disable=possibly-used-before-assignment
if abs((ecore_max[0] - ef_Ry) * get_Ry2eV() - emin) < 20:
axvline((ecore_max[0] - ef_Ry) * get_Ry2eV(), color='b', ls='--', label='ecore_max')
else:
Expand Down
4 changes: 3 additions & 1 deletion aiida_kkr/tools/tools_kkrimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,10 +418,12 @@ def find_neighbors(structure, structure_array, i, radius, clust_shape='spherical
box_1 = int(maxval / structure.cell_lengths[0] + 3)
box_2 = int(maxval / structure.cell_lengths[1] + 3)
box_3 = int(maxval / sl3 + 3)
else:
raise ValueError("clust_shape needs to be either 'sperical' or 'cylindrical'")
#================================================================================================================

#create array of all the atoms in an expanded system
box = max(box_1, box_2, box_3)
box = max(box_1, box_2, box_3) #pylint: disable=possibly-used-before-assignment
cell = np.array(structure.cell)
cell[2] = c3
for j in range(len(x)):
Expand Down
12 changes: 6 additions & 6 deletions aiida_kkr/workflows/_combine_imps.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ def extract_imps_info_exact_cluster(self):
imp2_impurity_info = self.ctx.imp2.inputs.impurity_info

try:
imps_info_in_exact_cluster = out_workflow_info.get_dict()['imps_info_in_exact_cluster']
imps_info_in_exact_cluster = out_workflow_info.get_dict()['imps_info_in_exact_cluster'] # pylint: disable=possibly-used-before-assignment
except KeyError:
parent_input_imp1 = parent_combine_wc.inputs.impurity1_output_node # TODO: rename combine_wc to the parent_combine_wc
parent_input_imp2 = parent_combine_wc.inputs.impurity2_output_node
Expand Down Expand Up @@ -654,7 +654,7 @@ def run_gf_writeout(self):
print('DEBUG:', self.ctx.imp1, list(self.ctx.imp1.inputs))
imp1_sub = self.ctx.imp1.get_outgoing(node_class=kkr_imp_sub_wc).first().node
if gf_writeout_calc is None:
gf_writeout_calc = imp1_sub.inputs.remote_data.get_incoming(node_class=KkrCalculation).first().node
gf_writeout_calc = imp1_sub.inputs.remote_data.get_incoming(node_class=KkrCalculation).first().node # pylint: disable=possibly-used-before-assignment
builder.remote_data = gf_writeout_calc.inputs.parent_folder

# set label and description of the calc
Expand Down Expand Up @@ -888,10 +888,10 @@ def get_ldau_combined(self):
if imp1_has_ldau and imp2_has_ldau:
# combine LDA+U settings of the two imps
settings_LDAU_combined = combine_settings_ldau(
settings_LDAU1=settings_LDAU1,
retrieved1=retrieved1,
settings_LDAU2=settings_LDAU2,
retrieved2=retrieved2,
settings_LDAU1=settings_LDAU1, # pylint: disable=used-before-assignment
retrieved1=retrieved1, # pylint: disable=used-before-assignment
settings_LDAU2=settings_LDAU2, # pylint: disable=used-before-assignment
retrieved2=retrieved2, # pylint: disable=used-before-assignment
kickout_info=self.ctx.kickout_info
)
elif imp1_has_ldau:
Expand Down
5 changes: 2 additions & 3 deletions aiida_kkr/workflows/bs.py
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,8 @@ def parse_BS_data(retrieved_folder, fermi_level, kpoints):
qdos_file_list = [i for i in retrieved_list if 'qdos.' in i]
q_vec_file = 'qvec.dat'

if q_vec_file in retrieved_list:
with retrieved_folder.open(q_vec_file) as file_opened:
q_vec = np.loadtxt(file_opened, skiprows=1)
with retrieved_folder.open(q_vec_file) as file_opened:
q_vec = np.loadtxt(file_opened, skiprows=1)

for icount, fname in enumerate(qdos_file_list):
with retrieved_folder.open(fname) as _f:
Expand Down
3 changes: 2 additions & 1 deletion aiida_kkr/workflows/kkr_imp_dos.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@ def run_imp_dos(self):
})
kkrimp_params = self.ctx.kkrimp_params_dict
label_imp = 'KKRimp DOS (GF: {}, imp_pot: {}, Zimp: {}, ilayer_cent: {})'.format(
gf_writeout_calc.pk, impurity_pot_or_remote.pk,
gf_writeout_calc.pk,
impurity_pot_or_remote.pk, # pylint: disable=possibly-used-before-assignment
imps.get_dict().get('Zimp'),
imps.get_dict().get('ilayer_center')
)
Expand Down
4 changes: 2 additions & 2 deletions aiida_kkr/workflows/kkr_imp_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -851,7 +851,7 @@ def run_kkrimp(self):

# add LDA+U input node if it was set in parent calculation of last kkrimp_remote or from input port
if self.ctx.settings_LDAU is not None:
inputs['settings_LDAU'] = self.ctx.settings_LDAU
inputs['settings_LDAU'] = self.ctx.settings_LDAU # pylint: disable=possibly-used-before-assignment

# set nonco angles if given
if 'initial_noco_angles' in self.inputs:
Expand Down Expand Up @@ -990,7 +990,7 @@ def inspect_kkrimp(self):
for name, val in {
'isteps': isteps,
'imix': self.ctx.last_mixing_scheme,
'mixfac': mixfac,
'mixfac': mixfac, # pylint: disable=possibly-used-before-assignment
'qbound': qbound,
'high_sett': self.ctx.kkr_higher_accuracy,
'first_rms': first_rms,
Expand Down
14 changes: 7 additions & 7 deletions aiida_kkr/workflows/kkr_scf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1898,14 +1898,14 @@ def create_scf_result_node(**kwargs):
outdict = {}

if has_last_outpara:
outputnode = outpara
outputnode = outpara # pylint: disable=possibly-used-before-assignment
outputnode.label = 'workflow_Results'
outputnode.description = ('Contains self-consistency results and '
'information of an kkr_scf_wc run.')
outdict['output_kkr_scf_wc_ParameterResults'] = outputnode

if has_last_calc_out_dict:
outputnode = last_calc_out_dict
outputnode = last_calc_out_dict # pylint: disable=used-before-assignment
outputnode.label = 'last_calc_out'
outputnode.description = (
'Contains the Results Parameter node from the output '
Expand All @@ -1914,7 +1914,7 @@ def create_scf_result_node(**kwargs):
outdict['last_calc_out'] = outputnode

if has_last_RemoteData:
outputnode = last_RemoteData_dict
outputnode = last_RemoteData_dict # pylint: disable=used-before-assignment
outputnode.label = 'last_RemoteData'
outputnode.description = (
'Contains a link to the latest remote data node '
Expand All @@ -1923,7 +1923,7 @@ def create_scf_result_node(**kwargs):
outdict['last_RemoteData'] = outputnode

if has_last_InputParameters:
outputnode = last_InputParameters_dict
outputnode = last_InputParameters_dict # pylint: disable=used-before-assignment
outputnode.label = 'last_InputParameters'
outputnode.description = (
'Contains the latest parameter data node '
Expand All @@ -1932,7 +1932,7 @@ def create_scf_result_node(**kwargs):
outdict['last_InputParameters'] = outputnode

if has_vorostart_output:
outputnode = vorostart_output_dict
outputnode = vorostart_output_dict # pylint: disable=used-before-assignment
outputnode.label = 'results_vorostart'
outputnode.description = (
'Contains the results parameter data node '
Expand All @@ -1941,14 +1941,14 @@ def create_scf_result_node(**kwargs):
outdict['results_vorostart'] = outputnode

if has_starting_dos:
outputnode = start_dosdata_interpol_dict
outputnode = start_dosdata_interpol_dict # pylint: disable=used-before-assignment
outputnode.label = 'starting_dosdata_interpol'
outputnode.description = ('Contains the interpolated DOS data note, computed '
'from the starting portential.')
outdict['starting_dosdata_interpol'] = outputnode

if has_final_dos:
outputnode = final_dosdata_interpol_dict
outputnode = final_dosdata_interpol_dict # pylint: disable=used-before-assignment
outputnode.label = 'final_dosdata_interpol'
outputnode.description = ('Contains the interpolated DOS data note, computed '
'from the converged potential.')
Expand Down
4 changes: 2 additions & 2 deletions aiida_kkr/workflows/voro_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,10 +547,10 @@ def run_voronoi(self):
kkr_para.set_value('RCLUSTZ', self.ctx.r_cls)
self.report(f'INFO: setting RCLUSTZ to {self.ctx.r_cls}')
if 'RMAX' in update_list:
kkr_para.set_value('RMAX', rmax_input)
kkr_para.set_value('RMAX', rmax_input) # pylint: disable=possibly-used-before-assignment
self.report(f'INFO: setting RMAX to {rmax_input} (needed for DOS check with KKRcode)')
if 'GMAX' in update_list:
kkr_para.set_value('GMAX', gmax_input)
kkr_para.set_value('GMAX', gmax_input) # pylint: disable=possibly-used-before-assignment
self.report(f'INFO: setting GMAX to {gmax_input} (needed for DOS check with KKRcode)')
if 'EMIN' in update_list:
kkr_para.set_value('EMIN', emin_new)
Expand Down

0 comments on commit bbcd765

Please sign in to comment.