3
0
mirror of https://github.com/triqs/dft_tools synced 2024-12-22 20:34:38 +01:00

[py3] Use isinstance for proper type checking

This commit is contained in:
Nils Wentzell 2020-04-08 15:55:39 -04:00
parent 484e10ef1f
commit 6d5e04f006
6 changed files with 10 additions and 13 deletions

View File

@ -53,8 +53,7 @@ class HkConverter(ConverterTools):
"""
assert type(
filename) == StringType, "HkConverter: filename must be a filename."
assert isinstance(filename, str), "HkConverter: filename must be a filename."
if hdf_filename is None:
hdf_filename = filename + '.h5'
self.hdf_file = hdf_filename

View File

@ -75,7 +75,7 @@ class VaspConverter(ConverterTools):
"""
assert type(filename)==StringType, "Please provide the DFT files' base name as a string."
assert isinstance(filename, str), "Please provide the DFT files' base name as a string."
if hdf_filename is None: hdf_filename = filename+'.h5'
self.hdf_file = hdf_filename
self.basename = filename

View File

@ -79,7 +79,7 @@ class Wannier90Converter(ConverterTools):
"""
self._name = "Wannier90Converter"
assert type(seedname) == StringType, self._name + \
assert isinstance(seedname, str), self._name + \
": Please provide the DFT files' base name as a string."
if hdf_filename is None:
hdf_filename = seedname + '.h5'

View File

@ -65,8 +65,7 @@ class Wien2kConverter(ConverterTools):
"""
assert type(
filename) == StringType, "Wien2kConverter: Please provide the DFT files' base name as a string."
assert isinstance(filename, str), "Wien2kConverter: Please provide the DFT files' base name as a string."
if hdf_filename is None:
hdf_filename = filename + '.h5'
self.hdf_file = hdf_filename

View File

@ -81,7 +81,7 @@ class SumkDFT(object):
Name of hdf5 subgroup in which miscellaneous DFT data are stored.
"""
if not type(hdf_file) == StringType:
if not isinstance(hdf_file, str):
mpi.report("Give a string for the hdf5 filename to read the input!")
else:
self.hdf_file = hdf_file
@ -1826,7 +1826,7 @@ class SumkDFT(object):
elif dm_type == 'vasp':
filename = 'GAMMA'
assert type(filename) == StringType, ("calc_density_correction: "
assert isinstance(filename, str), ("calc_density_correction: "
"filename has to be a string!")
ntoi = self.spin_names_to_ind[self.SO]

View File

@ -48,8 +48,7 @@ class Symmetry:
the data is stored at the root of the hdf5 archive.
"""
assert type(
hdf_file) == StringType, "Symmetry: hdf_file must be a filename."
assert isinstance(hdf_file, str), "Symmetry: hdf_file must be a filename."
self.hdf_file = hdf_file
things_to_read = ['n_symm', 'n_atoms', 'perm',
'orbits', 'SO', 'SP', 'time_inv', 'mat', 'mat_tinv']
@ -118,7 +117,7 @@ class Symmetry:
# to be complex since self.mat is complex!
symm_obj = [copy.deepcopy(obj[i]) for i in range(len(obj))]
for iorb in range(self.n_orbits):
if type(symm_obj[iorb]) == DictType:
if isinstance(symm_obj[iorb], dict):
for ii in symm_obj[iorb]:
symm_obj[iorb][ii] *= 0.0
else:
@ -143,7 +142,7 @@ class Symmetry:
else:
if type(obj[iorb]) == DictType:
if isinstance(obj[iorb], dict):
for ii in obj[iorb]:
if self.time_inv[i_symm] == 0:
symm_obj[jorb][ii] += numpy.dot(numpy.dot(self.mat[i_symm][iorb], obj[iorb][ii]),
@ -172,7 +171,7 @@ class Symmetry:
# symm_obj[iorb] /= 2.0
#
# else:
# if type(symm_obj[iorb]) == DictType:
# if isinstance(symm_obj[iorb], dict):
# for ii in symm_obj[iorb]:
# symm_obj[iorb][ii] += numpy.dot(numpy.dot(self.mat_tinv[iorb],symm_obj[iorb][ii].conjugate()),
# self.mat_tinv[iorb].transpose().conjugate())