diff --git a/python/converters/hk_converter.py b/python/converters/hk_converter.py index aa828e39..70b3738b 100644 --- a/python/converters/hk_converter.py +++ b/python/converters/hk_converter.py @@ -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 diff --git a/python/converters/vasp_converter.py b/python/converters/vasp_converter.py index 486e558e..a0066325 100644 --- a/python/converters/vasp_converter.py +++ b/python/converters/vasp_converter.py @@ -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 diff --git a/python/converters/wannier90_converter.py b/python/converters/wannier90_converter.py index 82d4ecbc..6410b72c 100644 --- a/python/converters/wannier90_converter.py +++ b/python/converters/wannier90_converter.py @@ -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' diff --git a/python/converters/wien2k_converter.py b/python/converters/wien2k_converter.py index 44406bcf..066a3454 100644 --- a/python/converters/wien2k_converter.py +++ b/python/converters/wien2k_converter.py @@ -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 diff --git a/python/sumk_dft.py b/python/sumk_dft.py index e76a1c6b..715fe2b1 100644 --- a/python/sumk_dft.py +++ b/python/sumk_dft.py @@ -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] diff --git a/python/symmetry.py b/python/symmetry.py index 6e1ee825..000edd7b 100644 --- a/python/symmetry.py +++ b/python/symmetry.py @@ -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())