-
Notifications
You must be signed in to change notification settings - Fork 868
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
Remove duplicate ruff rule in pyproject.toml
#3755
Conversation
"TID" was listed twice. Signed-off-by: Andrew S. Rosen <asrosen93@gmail.com>
WalkthroughThe recent changes focus on enhancing functionality and improving code structure across various files in the project. From simplifying logic in functions to refining data handling and parsing processes, these updates aim to streamline operations and boost clarity within the codebase. Changes
Poem
Recent Review DetailsConfiguration used: CodeRabbit UI Files selected for processing (11)
Files skipped from review due to trivial changes (1)
Files skipped from review as they are similar to previous changes (1)
Additional comments not posted (51)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did a bit more clean up of the ruff
config. several auto-fixes were needlessly disabled for "PLR0402", "PLR1714", "PLR5501"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 10
elif self.incar.get("ENCUT", 0) > 0: | ||
encut = self.incar["ENCUT"] # get the ENCUT val | ||
else: | ||
if self.incar.get("ENCUT", 0) > 0: | ||
encut = self.incar["ENCUT"] # get the ENCUT val | ||
else: | ||
encut = max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"]) | ||
encut = max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refactor the conditional logic for setting encut
to enhance readability and reduce redundancy.
- if custom_encut is not None:
- encut = custom_encut
- elif self.incar.get("ENCUT", 0) > 0:
- encut = self.incar["ENCUT"] # get the ENCUT val
- else:
- encut = max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"])
+ encut = (
+ custom_encut if custom_encut is not None
+ else self.incar.get("ENCUT", max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"]))
+ )
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
elif self.incar.get("ENCUT", 0) > 0: | |
encut = self.incar["ENCUT"] # get the ENCUT val | |
else: | |
if self.incar.get("ENCUT", 0) > 0: | |
encut = self.incar["ENCUT"] # get the ENCUT val | |
else: | |
encut = max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"]) | |
encut = max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"]) | |
encut = ( | |
custom_encut if custom_encut is not None | |
else self.incar.get("ENCUT", max(i_species.enmax for i_species in self.get_vasp_input()["POTCAR"])) | |
) |
elif invert_axes: | ||
_ylim = ax.get_ylim() | ||
relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] or ax.get_xlim() | ||
ax.set_xlim((min(relevant_x), max(relevant_x))) | ||
else: | ||
if invert_axes: | ||
_ylim = ax.get_ylim() | ||
relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] or ax.get_xlim() | ||
ax.set_xlim((min(relevant_x), max(relevant_x))) | ||
else: | ||
_xlim = ax.get_xlim() | ||
relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] or ax.get_ylim() | ||
ax.set_ylim((min(relevant_y), max(relevant_y))) | ||
_xlim = ax.get_xlim() | ||
relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] or ax.get_ylim() | ||
ax.set_ylim((min(relevant_y), max(relevant_y))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider handling cases where relevant_x
or relevant_y
might be empty.
- relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] or ax.get_xlim()
+ relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]]
+ if not relevant_x:
+ relevant_x = ax.get_xlim()
- relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] or ax.get_ylim()
+ relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]]
+ if not relevant_y:
+ relevant_y = ax.get_ylim()
This change ensures that the axis limits are set to the current limits if no points fall within the specified range, preventing potential errors or unexpected behavior.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
elif invert_axes: | |
_ylim = ax.get_ylim() | |
relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] or ax.get_xlim() | |
ax.set_xlim((min(relevant_x), max(relevant_x))) | |
else: | |
if invert_axes: | |
_ylim = ax.get_ylim() | |
relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] or ax.get_xlim() | |
ax.set_xlim((min(relevant_x), max(relevant_x))) | |
else: | |
_xlim = ax.get_xlim() | |
relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] or ax.get_ylim() | |
ax.set_ylim((min(relevant_y), max(relevant_y))) | |
_xlim = ax.get_xlim() | |
relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] or ax.get_ylim() | |
ax.set_ylim((min(relevant_y), max(relevant_y))) | |
elif invert_axes: | |
_ylim = ax.get_ylim() | |
relevant_x = [p[1] for p in all_pts if _ylim[0] < p[0] < _ylim[1]] | |
if not relevant_x: | |
relevant_x = ax.get_xlim() | |
ax.set_xlim((min(relevant_x), max(relevant_x))) | |
else: | |
_xlim = ax.get_xlim() | |
relevant_y = [p[1] for p in all_pts if _xlim[0] < p[0] < _xlim[1]] | |
if not relevant_y: | |
relevant_y = ax.get_ylim() | |
ax.set_ylim((min(relevant_y), max(relevant_y))) |
# The start event tells us when we have entered blocks | ||
if tag == "calculation": | ||
parsed_header = True | ||
elif tag == "eigenvalues_kpoints_opt" or tag == "projected_kpoints_opt": | ||
elif tag in ("eigenvalues_kpoints_opt", "projected_kpoints_opt"): | ||
in_kpoints_opt = True | ||
else: # event == "end": | ||
# The end event happens when we have read a block, so have |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Consider adding error handling for file operations in Wavecar
.
- with open(self.filename, "rb") as file:
+ try:
+ with open(self.filename, "rb") as file:
+ # existing code...
+ except IOError as e:
+ raise IOError(f"Failed to open or read from file {self.filename}: {str(e)}")
This change ensures that any issues with file access are caught and reported clearly, improving the robustness of file operations.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Handle the gamma point check more robustly in get_parchg
.
- if phase and not np.all(self.kpoints[kpoint] == 0.0):
+ if phase and not np.isclose(self.kpoints[kpoint], 0.0, atol=1e-5).all():
Using np.isclose
with a tolerance allows for minor numerical inaccuracies in specifying the gamma point, which is more robust than a direct comparison to zero.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Ensure consistent data types in Eigenval
initialization.
- self.ispin = int(file.readline().split()[-1])
+ self.ispin = int(float(file.readline().split()[-1]))
Casting the spin value to float before converting to int ensures that the code handles cases where the spin value might be represented as a floating-point number in the file.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Add error handling for file operations in Waveder.from_file
.
- with zopen(filename, mode="rt") as file:
+ try:
+ with zopen(filename, mode="rt") as file:
+ # existing code...
+ except IOError as e:
+ raise IOError(f"Failed to open or read from file {filename}: {str(e)}")
This change ensures that any issues with file access are caught and reported clearly, improving the robustness of file operations.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Consider adding error handling for file operations in Wavecar
.
- with open(self.filename, "rb") as file:
+ try:
+ with open(self.filename, "rb") as file:
+ # existing code...
+ except IOError as e:
+ raise IOError(f"Failed to open or read from file {self.filename}: {str(e)}")
This change ensures that any issues with file access are caught and reported clearly, improving the robustness of file operations.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Handle the gamma point check more robustly in get_parchg
.
- if phase and not np.all(self.kpoints[kpoint] == 0.0):
+ if phase and not np.isclose(self.kpoints[kpoint], 0.0, atol=1e-5).all():
Using np.isclose
with a tolerance allows for minor numerical inaccuracies in specifying the gamma point, which is more robust than a direct comparison to zero.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Ensure consistent data types in Eigenval
initialization.
- self.ispin = int(file.readline().split()[-1])
+ self.ispin = int(float(file.readline().split()[-1]))
Casting the spin value to float before converting to int ensures that the code handles cases where the spin value might be represented as a floating-point number in the file.
📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [358-414]
Add error handling for file operations in Waveder.from_file
.
- with zopen(filename, mode="rt") as file:
+ try:
+ with zopen(filename, mode="rt") as file:
+ # existing code...
+ except IOError as e:
+ raise IOError(f"Failed to open or read from file {filename}: {str(e)}")
This change ensures that any issues with file access are caught and reported clearly, improving the robustness of file operations.
"TID" was listed twice.
Summary by CodeRabbit
get_plot
function ofplotter.py
.current_segment
in theprepare_band_input
function inbs.py
.connected_components.py
file for a more structured approach.encut
value in thecalculate_ng
function ofsets.py
.istruct
in theapply_tags
method ofstructure_vtk.py
.History node
toHistoryNode
in theparse_history_node
method.test_outputs.py
file by switching to importElementTree
fromxml.etree
.test_init.py
file related topymatgen.phonon
module.