Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ repos:
- id: check-toml
# Python
- repo: https://github.com/psf/black
rev: 22.12.0
rev: 23.1.0
hooks:
- id: black-jupyter
- repo: https://github.com/PyCQA/isort
Expand All @@ -26,7 +26,7 @@ repos:
files: \.py$
- repo: https://github.com/charliermarsh/ruff-pre-commit
# Ruff version.
rev: v0.0.243
rev: v0.0.257
hooks:
- id: ruff
args: ["--fix"]
Expand Down
2 changes: 1 addition & 1 deletion deepmd/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(
model: Union[str, "Path"],
label: str = "DP",
type_dict: Dict[str, int] = None,
**kwargs
**kwargs,
) -> None:
Calculator.__init__(self, label=label, **kwargs)
self.dp = DeepPotential(str(Path(model).resolve()))
Expand Down
2 changes: 1 addition & 1 deletion deepmd/descriptor/se_a.py
Original file line number Diff line number Diff line change
Expand Up @@ -866,7 +866,7 @@ def _filter_lower(
trainable=True,
suffix="",
):
"""input env matrix, returns R.G."""
"""Input env matrix, returns R.G."""
outputs_size = [1] + self.filter_neuron
# cut-out inputs
# with natom x (nei_type_i x 4)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/descriptor/se_atten.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def _filter_lower(
name="filter_",
reuse=None,
):
"""input env matrix, returns R.G."""
"""Input env matrix, returns R.G."""
outputs_size = [1] + self.filter_neuron
# cut-out inputs
# with natom x (nei_type_i x 4)
Expand Down
2 changes: 1 addition & 1 deletion deepmd/entrypoints/compress.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def compress(
mpi_log: str,
log_path: Optional[str],
log_level: int,
**kwargs
**kwargs,
):
"""Compress model.

Expand Down
3 changes: 1 addition & 2 deletions deepmd/infer/deep_dipole.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ def __init__(
load_prefix: str = "load",
default_tf_graph: bool = False,
) -> None:

# use this in favor of dict update to move attribute from class to
# instance namespace
self.tensors = dict(
{
# output tensor
"t_tensor": "o_dipole:0",
},
**self.tensors
**self.tensors,
)

DeepTensor.__init__(
Expand Down
4 changes: 1 addition & 3 deletions deepmd/infer/deep_polar.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,14 @@ def __init__(
load_prefix: str = "load",
default_tf_graph: bool = False,
) -> None:

# use this in favor of dict update to move attribute from class to
# instance namespace
self.tensors = dict(
{
# output tensor
"t_tensor": "o_polar:0",
},
**self.tensors
**self.tensors,
)

DeepTensor.__init__(
Expand Down Expand Up @@ -84,7 +83,6 @@ class DeepGlobalPolar(DeepTensor):
def __init__(
self, model_file: str, load_prefix: str = "load", default_tf_graph: bool = False
) -> None:

self.tensors.update(
{
"t_sel_type": "model_attr/sel_type:0",
Expand Down
1 change: 0 additions & 1 deletion deepmd/infer/deep_pot.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ def __init__(
default_tf_graph: bool = False,
auto_batch_size: Union[bool, int, AutoBatchSize] = True,
) -> None:

# add these tensors on top of what is defined by DeepTensor Class
# use this in favor of dict update to move attribute from class to
# instance namespace
Expand Down
3 changes: 1 addition & 2 deletions deepmd/infer/deep_wfc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,14 @@ def __init__(
load_prefix: str = "load",
default_tf_graph: bool = False,
) -> None:

# use this in favor of dict update to move attribute from class to
# instance namespace
self.tensors = dict(
{
# output tensor
"t_tensor": "o_wfc:0",
},
**self.tensors
**self.tensors,
)
DeepTensor.__init__(
self,
Expand Down
1 change: 0 additions & 1 deletion deepmd/loggers/loggers.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,6 @@ def set_log_handles(

# * add file handler ***************************************************************
if log_path:

# create directory
log_path.parent.mkdir(exist_ok=True, parents=True)

Expand Down
1 change: 0 additions & 1 deletion deepmd/model/ener.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def build(
suffix="",
reuse=None,
):

if input_dict is None:
input_dict = {}
with tf.variable_scope("model_attr" + suffix, reuse=reuse):
Expand Down
1 change: 0 additions & 1 deletion deepmd/model/multi.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ def build(
suffix="",
reuse=None,
):

if input_dict is None:
input_dict = {}
with tf.variable_scope("model_attr" + suffix, reuse=reuse):
Expand Down
1 change: 0 additions & 1 deletion deepmd/model/tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ def build(
suffix="",
reuse=None,
):

if input_dict is None:
input_dict = {}
with tf.variable_scope("model_attr" + suffix, reuse=reuse):
Expand Down
2 changes: 1 addition & 1 deletion deepmd/nvnmd/entrypoints/wrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ def wrap(
nvnmd_weight: Optional[str] = "nvnmd/weight.npy",
nvnmd_map: Optional[str] = "nvnmd/map.npy",
nvnmd_model: Optional[str] = "nvnmd/model.pb",
**kwargs
**kwargs,
):
wrapObj = Wrap(nvnmd_config, nvnmd_weight, nvnmd_map, nvnmd_model)
wrapObj.wrap()
2 changes: 1 addition & 1 deletion deepmd/nvnmd/utils/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def init_fitn(self, jdata: dict, jdata_parent: dict = {}) -> dict:
return jdata

def init_dpin(self, jdata: dict, jdata_parent: dict = {}) -> dict:
r"""initial members about other deepmd input."""
r"""Initial members about other deepmd input."""
return jdata

def init_size(self, jdata: dict, jdata_parent: dict = {}) -> dict:
Expand Down
2 changes: 0 additions & 2 deletions deepmd/train/trainer.py
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ def _init_session(self):
run_sess(self.sess, bcast_op)

def train(self, train_data=None, valid_data=None):

# if valid_data is None: # no validation set specified.
# valid_data = train_data # using training set as validation set.

Expand Down Expand Up @@ -793,7 +792,6 @@ def train(self, train_data=None, valid_data=None):
total_train_time = 0.0

while cur_batch < stop_batch:

# first round validation:
if not self.multi_task_mode:
train_batch = train_data.get_batch()
Expand Down
1 change: 0 additions & 1 deletion deepmd/utils/compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,6 @@ def remove_decay_rate(jdata: Dict[str, Any]):
def convert_input_v1_v2(
jdata: Dict[str, Any], warning: bool = True, dump: Optional[Union[str, Path]] = None
) -> Dict[str, Any]:

tr_cfg = jdata["training"]
tr_data_keys = {
"systems",
Expand Down
2 changes: 1 addition & 1 deletion deepmd/utils/neighbor_stat.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def builder():
self.sub_sess = tf.Session(graph=sub_graph, config=default_tf_session_config)

def get_stat(self, data: DeepmdDataSystem) -> Tuple[float, List[int]]:
"""get the data statistics of the training data, including nearest nbor distance between atoms, max nbor size of atoms.
"""Get the data statistics of the training data, including nearest nbor distance between atoms, max nbor size of atoms.

Parameters
----------
Expand Down
8 changes: 4 additions & 4 deletions deepmd/utils/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def __truediv__(self, key: str) -> "DPPath":

@abstractmethod
def __lt__(self, other: "DPPath") -> bool:
"""whether this DPPath is less than other for sorting."""
"""Whether this DPPath is less than other for sorting."""

@abstractmethod
def __str__(self) -> str:
Expand Down Expand Up @@ -204,7 +204,7 @@ def __truediv__(self, key: str) -> "DPPath":
return type(self)(self.path / key)

def __lt__(self, other: "DPOSPath") -> bool:
"""whether this DPPath is less than other for sorting."""
"""Whether this DPPath is less than other for sorting."""
return self.path < other.path

def __str__(self) -> str:
Expand Down Expand Up @@ -349,11 +349,11 @@ def _connect_path(self, path: str) -> str:
return f"{self.name}/{path}"

def __lt__(self, other: "DPH5Path") -> bool:
"""whether this DPPath is less than other for sorting."""
"""Whether this DPPath is less than other for sorting."""
if self.root_path == other.root_path:
return self.name < other.name
return self.root_path < other.root_path

def __str__(self) -> str:
"""returns path of self."""
"""Returns path of self."""
return f"{self.root_path}#{self.name}"
1 change: 0 additions & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,6 @@ def run_apidoc(_):


def setup(app):

# Add hook for building doxygen xml when needed
app.connect("builder-inited", run_apidoc)

Expand Down
2 changes: 0 additions & 2 deletions source/install/build_tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,6 @@ def post_process(self):
with tarfile.open(self.path) as tar:

def is_within_directory(directory, target):

abs_directory = os.path.abspath(directory)
abs_target = os.path.abspath(target)

Expand All @@ -171,7 +170,6 @@ def is_within_directory(directory, target):
return prefix == abs_directory

def safe_extract(tar, path=".", members=None, *, numeric_owner=False):

for member in tar.getmembers():
member_path = os.path.join(path, member.name)
if not is_within_directory(path, member_path):
Expand Down
6 changes: 3 additions & 3 deletions source/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ def stats_energy(self):
return np.average(eners)

def load_energy(self, set_name, nframes, nvalues, energy_file, atom_energy_file):
"""return : coeff_ener, ener, coeff_atom_ener, atom_ener."""
"""Return : coeff_ener, ener, coeff_atom_ener, atom_ener."""
# load atom_energy
coeff_atom_ener, atom_ener = self.load_data(
set_name, atom_energy_file, [nframes, nvalues], False
Expand Down Expand Up @@ -765,13 +765,13 @@ def get_set(self, data, idx=None):
return new_data

def get_test(self):
"""returned property prefector [4] in order:
"""Returned property prefector [4] in order:
energy, force, virial, atom_ener.
"""
return self.get_set(self.test_set)

def get_batch(self, batch_size):
"""returned property prefector [4] in order:
"""Returned property prefector [4] in order:
energy, force, virial, atom_ener.
"""
set_size = self.batch_set["energy"].shape[0]
Expand Down
1 change: 0 additions & 1 deletion source/tests/test_argument_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ def attr_and_type_check(
mapping = {**{"command": dict(type=str, value=command)}, **mapping}

for argument, test_data in mapping.items():

# get expected type
expected_type = test_data["type"]

Expand Down
1 change: 0 additions & 1 deletion source/tests/test_compat_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ def assertDictAlmostEqual(self, d1, d2, msg=None, places=7):
self.assertAlmostEqual(d1[kk], d2[kk], places=places, msg=msg)

def test_json_yaml_equal(self):

inputs = ("water_v1", "water_se_a_v1")

for i in inputs:
Expand Down
2 changes: 1 addition & 1 deletion source/tests/test_deepmd_data_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ def test_sys_prob_floating_point_error(self):
self.assertEqual(ds.sys_probs.size, len(sys_probs))

def test_get_mixed_batch(self):
"""test get_batch with mixed system."""
"""Test get_batch with mixed system."""
batch_size = "mixed:3"
test_size = 2

Expand Down
2 changes: 1 addition & 1 deletion source/tests/test_descrpt_sea_ef_rot.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def build_efv(self, dcoord, dbox, dtype, tnatoms, name, op, reuse=None):
"rcut_smth": 5.5,
"seed": 1,
"uniform_seed": True,
}
},
)
else:
descrpt = DescrptSeA(
Expand Down
1 change: 0 additions & 1 deletion source/tests/test_get_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def tearDown(self):
f.unlink()

def test_factory(self):

msg = "Returned wrong type of potential. Expected: {}, got: {}"

dp = DeepPotential(self.work_dir / "deep_dipole.pb")
Expand Down