-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3588 from GreatRSingh/deep-1
DFT Utilities [PR-1] [Config | Ztypes]
- Loading branch information
Showing
5 changed files
with
87 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
""" | ||
Density Functional Theory utilities. | ||
""" | ||
# flake8: noqa | ||
import logging | ||
|
||
logger_ = logging.getLogger(__name__) | ||
|
||
from deepchem.utils.dft_utils.config import config | ||
|
||
try: | ||
from deepchem.utils.dft_utils.datastruct import ZType | ||
except ModuleNotFoundError as e: | ||
logger_.warning( | ||
f'Skipped loading some Pytorch utilities, missing a dependency. {e}') |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
""" | ||
Density Function Theory Configuration Utilities. | ||
""" | ||
|
||
from dataclasses import dataclass | ||
|
||
__all__ = ["config"] | ||
|
||
|
||
@dataclass | ||
class _Config(object): | ||
"""Contains the configuration for the DFT module | ||
Examples | ||
-------- | ||
>>> from deepchem.utils.dft_utils.config import config | ||
>>> Memory_usage = 1024**4 # Sample Memory usage by some Object/Matrix | ||
>>> if Memory_usage > config.THRESHOLD_MEMORY : | ||
... print("Overload") | ||
Overload | ||
Attributes | ||
---------- | ||
THRESHOLD_MEMORY: int (default=10*1024**3) | ||
Threshold memory (matrix above this size should not be constructed) | ||
CHUNK_MEMORY: int (default=16*1024**2) | ||
The memory for splitting big tensors into chunks. | ||
VERBOSE: int (default=0) | ||
Allowed Verbosity level (Defines the level of detail) | ||
Used by Looger for maintaining Logs. | ||
Usage | ||
----- | ||
1. HamiltonCGTO: Usage it for splitting big tensors into chunks. | ||
""" | ||
THRESHOLD_MEMORY: int = 10 * 1024**3 # in Bytes | ||
CHUNK_MEMORY: int = 16 * 1024**2 # in Bytes | ||
VERBOSE: int = 0 | ||
|
||
|
||
config = _Config() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
""" | ||
Density Functional Theory Data Structure Utilities | ||
""" | ||
from typing import Union, TypeVar | ||
|
||
import torch | ||
|
||
__all__ = ["ZType"] | ||
|
||
T = TypeVar('T') | ||
P = TypeVar('P') | ||
|
||
# type of the atom Z | ||
ZType = Union[int, float, torch.Tensor] |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Test for DFT Config Utilities | ||
""" | ||
|
||
from deepchem.utils.dft_utils.config import config | ||
|
||
|
||
def test_config(): | ||
conf = config | ||
assert conf.THRESHOLD_MEMORY == 10 * 1024**3 | ||
assert conf.CHUNK_MEMORY == 16 * 1024**2 | ||
assert conf.VERBOSE == 0 |
This file contains 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