Commit 99a6f3c
feat: remove unused support_array_api decorator (#5200)
The `support_array_api` decorator defined in
`deepmd/dpmodel/array_api.py` was unused metadata that added no
functional value. It set an `array_api_version` attribute on decorated
functions, but this attribute was never checked anywhere in the
codebase.
## Changes
- **Removed decorator definition** from `deepmd/dpmodel/array_api.py`
(30 lines)
- **Removed decorator usages** from:
- `deepmd/dpmodel/utils/env_mat.py` - `compute_smooth_weight()`,
`compute_exp_sw()`
- `deepmd/dpmodel/utils/network.py` - `NativeLayer.call()`,
`get_activation_fn()`
- `deepmd/dpmodel/utils/type_embed.py` - `TypeEmbedNet.call()`
- **Removed unused test utility** `set_array_api_version()` from
`source/tests/common/dpmodel/array_api/utils.py`
- **Cleaned up imports** - removed `Callable` and
`set_array_api_strict_flags` where no longer needed
Functions previously decorated now have unchanged behavior:
```python
# Before
@support_array_api(version="2023.12")
def compute_smooth_weight(distance: Array, rmin: float, rmax: float) -> Array:
...
# After
def compute_smooth_weight(distance: Array, rmin: float, rmax: float) -> Array:
...
```
Total: 45 lines deleted across 5 files.
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
>
> ----
>
> *This section details on the original issue you should resolve*
>
> <issue_title>[Feature Request] Remove unused support_array_api
decorator to simplify codebase</issue_title>
> <issue_description>### Summary
>
> Propose to remove the rarely used `support_array_api` decorator
defined at
[deepmd/dpmodel/array_api.py#L21](https://github.com/deepmodeling/deepmd-kit/blob/ef0be638972739463813609729075bf38973dd9d/deepmd/dpmodel/array_api.py#L21)
to simplify and streamline the codebase.
>
> ### Detailed Description
>
> The `support_array_api` decorator is present in the codebase but is
used in only a few isolated functions and has not contributed to
significant or widely used features. Its presence now causes unnecessary
clutter and maintenance complexity.
>
> By removing this unused decorator and its usages, we can improve
overall code maintainability and reduce confusion for contributors. If a
future need for such a decorator arises, it can be revised and
reintroduced when there is a broader adoption scenario.
>
> ### Further Information, Files, and Links
>
> _No response_</issue_description>
>
> ## Comments on the Issue (you are @copilot in this section)
>
> <comments>
> </comments>
>
</details>
<!-- START COPILOT CODING AGENT SUFFIX -->
- Fixes #5199
<!-- START COPILOT CODING AGENT TIPS -->
---
💡 You can make Copilot smarter by setting up custom instructions,
customizing its development environment and configuring Model Context
Protocol (MCP) servers. Learn more [Copilot coding agent
tips](https://gh.io/copilot-coding-agent-tips) in the docs.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>1 parent ef0be63 commit 99a6f3c
5 files changed
Lines changed: 0 additions & 45 deletions
File tree
- deepmd/dpmodel
- utils
- source/tests/common/dpmodel/array_api
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
| |||
18 | 15 | | |
19 | 16 | | |
20 | 17 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | 18 | | |
49 | 19 | | |
50 | 20 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
14 | 13 | | |
15 | 14 | | |
16 | 15 | | |
17 | 16 | | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
21 | | - | |
22 | 20 | | |
23 | 21 | | |
24 | 22 | | |
| |||
35 | 33 | | |
36 | 34 | | |
37 | 35 | | |
38 | | - | |
39 | 36 | | |
40 | 37 | | |
41 | 38 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
27 | 26 | | |
28 | 27 | | |
29 | 28 | | |
| |||
259 | 258 | | |
260 | 259 | | |
261 | 260 | | |
262 | | - | |
263 | 261 | | |
264 | 262 | | |
265 | 263 | | |
| |||
296 | 294 | | |
297 | 295 | | |
298 | 296 | | |
299 | | - | |
300 | 297 | | |
301 | 298 | | |
302 | 299 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
12 | 11 | | |
13 | 12 | | |
14 | 13 | | |
| |||
96 | 95 | | |
97 | 96 | | |
98 | 97 | | |
99 | | - | |
100 | 98 | | |
101 | 99 | | |
102 | 100 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | 3 | | |
7 | 4 | | |
8 | 5 | | |
9 | 6 | | |
10 | 7 | | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | 8 | | |
16 | 9 | | |
17 | 10 | | |
| |||
0 commit comments