Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use isinstance #58

Merged
merged 1 commit into from
May 23, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions effmass/inputs.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def check_settings(self):
assert (self.extrema_search_depth >
0), "The energy depth must be a positive number"
assert (
type(self.degree_bandfit) == int and self.degree_bandfit > 1
isinstance(self.degree_bandfit, int) and self.degree_bandfit > 1
), "The bandfit degree must be a positive integer greater than 1"

class Data():
Expand Down Expand Up @@ -131,10 +131,10 @@ def check_data(self, spin_channels, number_of_kpoints, number_of_bands, CBM,
((spin_channels == 1) | (spin_channels == 2) |
(spin_channels == 4)) is True
), "Spin channels must have value 1 (non spin-polarised) or 2 (spin-polarised)"
assert (type(number_of_kpoints) == int
assert (isinstance(number_of_kpoints, int)
and number_of_kpoints > 0
), "The number of kpoints is not a positive integer"
assert (type(number_of_bands) == int and number_of_bands > 0
assert (isinstance(number_of_bands, int) and number_of_bands > 0
), "The number of bands is not a positive integer"
assert (CBM >
VBM), "The CBM energy is lower than than the VBM energy"
Expand Down Expand Up @@ -340,8 +340,8 @@ def __init__(self, outcar_path, procar_path, ignore=0, **kwargs):

super().__init__()

assert (type(outcar_path) == str), "The OUTCAR path must be a string"
assert (type(ignore) == int and ignore >= 0
assert (isinstance(outcar_path, str)), "The OUTCAR path must be a string"
assert (isinstance(ignore, int) and ignore >= 0
), "The number of kpoints to ignore must be a positive integer"

reciprocal_lattice = outcar.reciprocal_lattice_from_outcar(outcar_path)
Expand Down Expand Up @@ -665,9 +665,9 @@ def __init__(self, bandstructure_path, info_path, results_path):

super().__init__()

assert (type(bandstructure_path) == str), "The bandStructure path must be a string"
assert (type(info_path) == str), "The info path must be a string"
assert (type(results_path) == str), "The results path must be a string"
assert (isinstance(bandstructure_path, str)), "The bandStructure path must be a string"
assert (isinstance(info_path, str)), "The info path must be a string"
assert (isinstance(results_path, str)), "The results path must be a string"

# load the Octopus data
band_struct = bandstructure.Bandstructure(bandstructure_path)
Expand Down