Code quality improvements#7001
Merged
mohanchen merged 13 commits intodeepmodeling:developfrom Mar 9, 2026
Merged
Conversation
added 9 commits
March 7, 2026 20:13
Replace standard exception handling with project-specific error handling in cell_index.cpp to comply with ABACUS code style guidelines. Changes: - Replace 3 instances of 'throw std::out_of_range' with ModuleBase::WARNING_QUIT in functions: iw2l(), iw2z(), iw2m() - Remove unnecessary #include <stdexcept> - Fix incorrect error message strings in iw2z() and iw2m() (was 'iw2l') This change follows the cpp-code-style skill rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions for error handling in the ABACUS project.
Add const qualifier to all getter and helper member functions in CellIndex class to improve const-correctness according to cpp-code-style skill guidelines. Changes in cell_index.h: - Add const to all public getter functions: get_nat(), get_ntype(), get_nw(), get_iwt(), get_maxL(), get_nchi(), get_atom_label() - Add const to write_orb_info() and change parameter to const reference - Add const to private helper functions: iat2it(), iat2ia(), iw2l(), iw2z(), iw2m() Changes in cell_index.cpp: - Update all function definitions to match header declarations - Change write_orb_info parameter from std::string to const std::string& This follows the ABACUS code style rule that getter functions and functions that do not modify member state should be marked const.
- 在density_matrix.cpp中添加了tool_quit.h头文件 - 将第616行的throw std::string替换为ModuleBase::WARNING_QUIT - 统一了项目的错误处理方式,符合ABACUS代码规范 修改文件: - source/source_estate/module_dm/density_matrix.cpp 影响范围:错误处理流程
- 将泛型lambda [](auto x) 改为 [](double x) - 符合ABACUS项目只支持C++11标准的要求 - Matrix3的元素类型为double,无需泛型 修改文件: - source/source_lcao/module_ri/module_exx_symmetry/symmetry_rotation_output.cpp
Replace standard exception handling with project-specific error handling in restart.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 4 instances of 'throw std::runtime_error' with ModuleBase::WARNING_QUIT in functions: write_file2() and read_file2() - Remove unnecessary #include <stdexcept> - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions.
Replace standard exception handling with project-specific error handling in write_libxc_r.cpp to comply with cpp-code-style skill guidelines. Changes: - Replace 9 instances of throw with ModuleBase::WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - Remove #include <stdexcept> - Add #include "source_base/tool_quit.h" This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions.
- Replace tabs with 4 spaces in md_func.cpp (lines 198-209) - Replace tabs with 4 spaces in md_base.cpp (line 65) - Replace tabs with 4 spaces in run_md.cpp (lines 59-61)
Replace standard exception handling with project-specific error handling in source_io directory to comply with cpp-code-style skill guidelines. Changes: - Replace all instances of throw with ModuleBase::WARNING_QUIT - throw std::runtime_error -> WARNING_QUIT - throw std::logic_error -> WARNING_QUIT - throw std::invalid_argument -> WARNING_QUIT - throw std::domain_error -> WARNING_QUIT - Remove unnecessary #include <stdexcept> - Add #include "source_base/tool_quit.h" where needed Files modified: - module_restart/restart.cpp (4 instances) - module_chgpot/write_libxc_r.cpp (9 instances) - module_wannier/to_wannier90_lcao.h (1 instance) - module_wannier/to_wannier90_lcao_in_pw.h (1 instance) - module_wannier/to_wannier90_pw.h (1 instance) - module_wannier/to_wannier90.cpp (1 instance) - module_unk/berryphase.h (1 instance) - module_parameter/read_input_tool.h (1 instance) - module_parameter/input_conv.cpp (1 instance) This follows the ABACUS code style rule that requires using ModuleBase::WARNING/WARNING_QUIT instead of standard exceptions.
added 4 commits
March 8, 2026 21:37
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reminder
Linked Issue
Fix #...
Unit Tests and/or Case Tests for my changes
What's changed?
Any changes of core modules? (ignore if not applicable)