mirror of
https://github.com/triqs/dft_tools
synced 2024-12-31 16:45:49 +01:00
[py3] Use isinstance for proper type checking
This commit is contained in:
parent
484e10ef1f
commit
6d5e04f006
@ -53,8 +53,7 @@ class HkConverter(ConverterTools):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert type(
|
assert isinstance(filename, str), "HkConverter: filename must be a filename."
|
||||||
filename) == StringType, "HkConverter: filename must be a filename."
|
|
||||||
if hdf_filename is None:
|
if hdf_filename is None:
|
||||||
hdf_filename = filename + '.h5'
|
hdf_filename = filename + '.h5'
|
||||||
self.hdf_file = hdf_filename
|
self.hdf_file = hdf_filename
|
||||||
|
@ -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'
|
if hdf_filename is None: hdf_filename = filename+'.h5'
|
||||||
self.hdf_file = hdf_filename
|
self.hdf_file = hdf_filename
|
||||||
self.basename = filename
|
self.basename = filename
|
||||||
|
@ -79,7 +79,7 @@ class Wannier90Converter(ConverterTools):
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
self._name = "Wannier90Converter"
|
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."
|
": Please provide the DFT files' base name as a string."
|
||||||
if hdf_filename is None:
|
if hdf_filename is None:
|
||||||
hdf_filename = seedname + '.h5'
|
hdf_filename = seedname + '.h5'
|
||||||
|
@ -65,8 +65,7 @@ class Wien2kConverter(ConverterTools):
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert type(
|
assert isinstance(filename, str), "Wien2kConverter: Please provide the DFT files' base name as a string."
|
||||||
filename) == StringType, "Wien2kConverter: Please provide the DFT files' base name as a string."
|
|
||||||
if hdf_filename is None:
|
if hdf_filename is None:
|
||||||
hdf_filename = filename + '.h5'
|
hdf_filename = filename + '.h5'
|
||||||
self.hdf_file = hdf_filename
|
self.hdf_file = hdf_filename
|
||||||
|
@ -81,7 +81,7 @@ class SumkDFT(object):
|
|||||||
Name of hdf5 subgroup in which miscellaneous DFT data are stored.
|
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!")
|
mpi.report("Give a string for the hdf5 filename to read the input!")
|
||||||
else:
|
else:
|
||||||
self.hdf_file = hdf_file
|
self.hdf_file = hdf_file
|
||||||
@ -1826,7 +1826,7 @@ class SumkDFT(object):
|
|||||||
elif dm_type == 'vasp':
|
elif dm_type == 'vasp':
|
||||||
filename = 'GAMMA'
|
filename = 'GAMMA'
|
||||||
|
|
||||||
assert type(filename) == StringType, ("calc_density_correction: "
|
assert isinstance(filename, str), ("calc_density_correction: "
|
||||||
"filename has to be a string!")
|
"filename has to be a string!")
|
||||||
|
|
||||||
ntoi = self.spin_names_to_ind[self.SO]
|
ntoi = self.spin_names_to_ind[self.SO]
|
||||||
|
@ -48,8 +48,7 @@ class Symmetry:
|
|||||||
the data is stored at the root of the hdf5 archive.
|
the data is stored at the root of the hdf5 archive.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
assert type(
|
assert isinstance(hdf_file, str), "Symmetry: hdf_file must be a filename."
|
||||||
hdf_file) == StringType, "Symmetry: hdf_file must be a filename."
|
|
||||||
self.hdf_file = hdf_file
|
self.hdf_file = hdf_file
|
||||||
things_to_read = ['n_symm', 'n_atoms', 'perm',
|
things_to_read = ['n_symm', 'n_atoms', 'perm',
|
||||||
'orbits', 'SO', 'SP', 'time_inv', 'mat', 'mat_tinv']
|
'orbits', 'SO', 'SP', 'time_inv', 'mat', 'mat_tinv']
|
||||||
@ -118,7 +117,7 @@ class Symmetry:
|
|||||||
# to be complex since self.mat is complex!
|
# to be complex since self.mat is complex!
|
||||||
symm_obj = [copy.deepcopy(obj[i]) for i in range(len(obj))]
|
symm_obj = [copy.deepcopy(obj[i]) for i in range(len(obj))]
|
||||||
for iorb in range(self.n_orbits):
|
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]:
|
for ii in symm_obj[iorb]:
|
||||||
symm_obj[iorb][ii] *= 0.0
|
symm_obj[iorb][ii] *= 0.0
|
||||||
else:
|
else:
|
||||||
@ -143,7 +142,7 @@ class Symmetry:
|
|||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
if type(obj[iorb]) == DictType:
|
if isinstance(obj[iorb], dict):
|
||||||
for ii in obj[iorb]:
|
for ii in obj[iorb]:
|
||||||
if self.time_inv[i_symm] == 0:
|
if self.time_inv[i_symm] == 0:
|
||||||
symm_obj[jorb][ii] += numpy.dot(numpy.dot(self.mat[i_symm][iorb], obj[iorb][ii]),
|
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
|
# symm_obj[iorb] /= 2.0
|
||||||
#
|
#
|
||||||
# else:
|
# else:
|
||||||
# if type(symm_obj[iorb]) == DictType:
|
# if isinstance(symm_obj[iorb], dict):
|
||||||
# for ii in symm_obj[iorb]:
|
# for ii in symm_obj[iorb]:
|
||||||
# symm_obj[iorb][ii] += numpy.dot(numpy.dot(self.mat_tinv[iorb],symm_obj[iorb][ii].conjugate()),
|
# symm_obj[iorb][ii] += numpy.dot(numpy.dot(self.mat_tinv[iorb],symm_obj[iorb][ii].conjugate()),
|
||||||
# self.mat_tinv[iorb].transpose().conjugate())
|
# self.mat_tinv[iorb].transpose().conjugate())
|
||||||
|
Loading…
Reference in New Issue
Block a user