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

Clean up unused methods in region.py and preprocess.py #3791

Closed
njzjz opened this issue May 16, 2024 · 10 comments
Closed

Clean up unused methods in region.py and preprocess.py #3791

njzjz opened this issue May 16, 2024 · 10 comments

Comments

@njzjz
Copy link
Member

njzjz commented May 16, 2024

source/tests/pt/model/test_region.py::TestLegacyRegion::test_inter_to_inter
  /opt/hostedtoolcache/Python/3.11.9/x64/lib/python3.11/site-packages/torch/utils/_device.py:78: UserWarning: Using torch.cross without specifying the dim arg is deprecated.
  Please either pass the dim explicitly or simply use torch.linalg.cross.
  The default value of dim will change to agree with that of linalg.cross in a future release. (Triggered internally at ../aten/src/ATen/native/Cross.cpp:62.)
    return func(*args, **kwargs)
@njzjz njzjz added the bug label May 16, 2024
@njzjz
Copy link
Member Author

njzjz commented May 21, 2024

Affected:

c_yz = torch.cross(cell[1], cell[2])
_h2yz = volume / torch.linalg.norm(c_yz)
c_zx = torch.cross(cell[2], cell[0])
_h2zx = volume / torch.linalg.norm(c_zx)
c_xy = torch.cross(cell[0], cell[1])

c_yz = torch.cross(boxt[1], boxt[2])
self._h2yz = self.volume / torch.linalg.norm(c_yz)
c_zx = torch.cross(boxt[2], boxt[0])
self._h2zx = self.volume / torch.linalg.norm(c_zx)
c_xy = torch.cross(boxt[0], boxt[1])

@wanghan-iapcm
Copy link
Collaborator

all functions in preprocess except compute_smooth_weight can be removed.

@njzjz
Copy link
Member Author

njzjz commented May 23, 2024

@wanghan-iapcm @iProzd could we find and remove all dead codes at once?

@wanghan-iapcm
Copy link
Collaborator

May not necessarily do it at once ? or is there tools for automatically removing the dead codes?

@njzjz
Copy link
Member Author

njzjz commented Jun 14, 2024

May not necessarily do it at once ? or is there tools for automatically removing the dead codes?

Indeed we can find them using Codecov, assuming all used functions are tested.

@njzjz
Copy link
Member Author

njzjz commented Jun 14, 2024

I see preprocess.py has a 93% coverage, though

@wanghan-iapcm
Copy link
Collaborator

good idea. I am wondering how much codes that are not dead are not covered by the UTs.

@njzjz
Copy link
Member Author

njzjz commented Jun 26, 2024

I just found _to_face_distance in region.py is also not used at all, but left there for an unclear reason.

@njzjz njzjz removed their assignment Jun 26, 2024
@njzjz
Copy link
Member Author

njzjz commented Jun 26, 2024

Since both code blocks are not used, I unassigned myself and moved from mustfix to enhance. cc @wanghan-iapcm @iProzd

@njzjz njzjz added enhancement and removed bug labels Jul 31, 2024
@njzjz njzjz changed the title UserWarning: Using torch.cross without specifying the dim arg is deprecated. Clean up unused methods in region.py and preprocess.py Jul 31, 2024
@njzjz
Copy link
Member Author

njzjz commented Sep 17, 2024

I've used deadcode to find out all used functions. Could you take a look? @wanghan-iapcm @iProzd

deepmd/dpmodel/output_def.py:416:0: DC02 Function `check_deriv` is never used
deepmd/pt/infer/deep_eval.py:595:0: DC02 Function `eval_model` is never used
deepmd/pt/model/model/transform_output.py:111:0: DC02 Function `get_atom_axis` is never used
deepmd/pt/model/network/init.py:425:0: DC02 Function `xavier_normal_` is never used
deepmd/pt/utils/nlist.py:175:0: DC02 Function `build_directional_neighbor_list` is never used
deepmd/pt/utils/preprocess.py:241:0: DC02 Function `make_env_mat` is never used
deepmd/pt/utils/region.py:71:0: DC02 Function `_to_face_distance` is never used
deepmd/tf/nvnmd/utils/network.py:31:0: DC02 Function `matmul2_qq` is never used
deepmd/tf/nvnmd/utils/network.py:45:0: DC02 Function `matmul3_qq` is never used
deepmd/tf/train/trainer.py:76:0: DC02 Function `_is_subdir` is never used
deepmd/tf/utils/graph.py:157:0: DC02 Function `get_embedding_net_nodes` is never used
deepmd/tf/utils/graph.py:285:0: DC02 Function `get_embedding_net_variables` is never used
deepmd/tf/utils/graph.py:337:0: DC02 Function `get_fitting_net_nodes` is never used
deepmd/tf/utils/graph.py:375:0: DC02 Function `get_fitting_net_variables` is never used
deepmd/utils/econf_embd.py:207:0: DC02 Function `make_econf_embedding` is never used
deepmd/utils/econf_embd.py:217:0: DC02 Function `print_econf_embedding` is never used

github-merge-queue bot pushed a commit that referenced this issue Sep 19, 2024
- #3791
- mainly preprocess and region
- deepmd/pt/infer/deep_eval.py:595:0: DC02 Function `eval_model` is
never used. used by test_unused_params, which seems not easy to remove

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
	- No new features introduced; significant code simplifications made.
  
- **Bug Fixes**
- No specific bug fixes identified; however, the removal of outdated
functions may enhance overall stability.

- **Refactor**
- Removed the `Region3D` class and associated functions to streamline
preprocessing logic.
- Eliminated the `get_atom_axis` function to simplify atom axis
determination.
- Removed the `_to_face_distance` function, suggesting a refactor in
distance calculations.

- **Tests**
- Removed the `TestLegacyRegion` class, reducing the scope of testing
related to the `Region3D` functionality.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Han Wang <wang_han@iapcm.ac.cn>
@njzjz njzjz closed this as completed Sep 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Status: Backlog
Development

No branches or pull requests

2 participants