Skip to content

Commit

Permalink
fix: rm unused import of __version__ (deepmodeling#3842)
Browse files Browse the repository at this point in the history
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Refactor**
- Reorganized and cleaned up import statements across multiple files for
improved readability and maintainability.
- Simplified version handling logic by removing unnecessary imports and
setting default version values.

- **Chores**
- Removed duplicate imports and restructured import order to enhance
code organization.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
iProzd authored and Mathieu Taillefumier committed Sep 18, 2024
1 parent ae40d60 commit 552f587
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 147 deletions.
46 changes: 20 additions & 26 deletions deepmd/dpmodel/descriptor/dpa1.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Union,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
Expand All @@ -24,32 +44,6 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
Any,
Callable,
List,
Optional,
Tuple,
Union,
)

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
34 changes: 14 additions & 20 deletions deepmd/dpmodel/descriptor/dpa2.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
from typing import (
List,
Optional,
Tuple,
Union,
)

import numpy as np

from deepmd.dpmodel import (
NativeOP,
)
from deepmd.dpmodel.utils import (
EnvMat,
NetworkCollection,
)
from deepmd.dpmodel.utils.network import (
Identity,
NativeLayer,
Expand All @@ -25,26 +39,6 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
List,
Optional,
Tuple,
Union,
)

from deepmd.dpmodel import (
NativeOP,
)
from deepmd.dpmodel.utils import (
EnvMat,
NetworkCollection,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
28 changes: 10 additions & 18 deletions deepmd/dpmodel/descriptor/repformers.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import numpy as np

from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from typing import (
Callable,
List,
Expand All @@ -25,6 +7,8 @@
Union,
)

import numpy as np

from deepmd.dpmodel import (
PRECISION_DICT,
NativeOP,
Expand All @@ -34,8 +18,16 @@
PairExcludeMask,
)
from deepmd.dpmodel.utils.network import (
LayerNorm,
NativeLayer,
get_activation_fn,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .descriptor import (
DescriptorBlock,
Expand Down
43 changes: 18 additions & 25 deletions deepmd/dpmodel/descriptor/se_e2_a.py
Original file line number Diff line number Diff line change
@@ -1,37 +1,15 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import itertools

import numpy as np

from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
import itertools
from typing import (
Any,
List,
Optional,
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
Expand All @@ -43,6 +21,21 @@
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .base_descriptor import (
BaseDescriptor,
Expand Down
34 changes: 14 additions & 20 deletions deepmd/dpmodel/descriptor/se_r.py
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import numpy as np

from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
from typing import (
Any,
Expand All @@ -27,6 +7,8 @@
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
Expand All @@ -38,9 +20,21 @@
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
from deepmd.env import (
GLOBAL_NP_FLOAT_PRECISION,
)
from deepmd.utils.data_system import (
DeepmdDataSystem,
)
from deepmd.utils.path import (
DPPath,
)
from deepmd.utils.version import (
check_version_compatibility,
)

from .base_descriptor import (
BaseDescriptor,
Expand Down
41 changes: 17 additions & 24 deletions deepmd/dpmodel/descriptor/se_t.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# SPDX-License-Identifier: LGPL-3.0-or-later
import copy
import itertools
from typing import (
List,
Optional,
Tuple,
)

import numpy as np

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)
from deepmd.dpmodel.utils.update_sel import (
UpdateSel,
)
Expand All @@ -19,30 +36,6 @@
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

import copy
from typing import (
List,
Optional,
Tuple,
)

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.dpmodel.utils import (
EmbeddingNet,
EnvMat,
NetworkCollection,
PairExcludeMask,
)

from .base_descriptor import (
BaseDescriptor,
)
Expand Down
12 changes: 3 additions & 9 deletions deepmd/dpmodel/utils/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,14 @@

import numpy as np

from deepmd.utils.version import (
check_version_compatibility,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"

from deepmd.dpmodel import (
DEFAULT_PRECISION,
PRECISION_DICT,
NativeOP,
)
from deepmd.utils.version import (
check_version_compatibility,
)


class Identity(NativeOP):
Expand Down
5 changes: 0 additions & 5 deletions deepmd/pt/model/network/mlp.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@
to_torch_tensor,
)

try:
from deepmd._version import version as __version__
except ImportError:
__version__ = "unknown"


def empty_t(shape, precision):
return torch.empty(shape, dtype=precision, device=device)
Expand Down

0 comments on commit 552f587

Please sign in to comment.