Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (deepmodeling#3305)
Browse files Browse the repository at this point in the history
<!--pre-commit.ci start-->
updates:
- [github.com/astral-sh/ruff-pre-commit: v0.2.1 →
v0.2.2](astral-sh/ruff-pre-commit@v0.2.1...v0.2.2)
- [github.com/Lucas-C/pre-commit-hooks: v1.5.4 →
v1.5.5](Lucas-C/pre-commit-hooks@v1.5.4...v1.5.5)
<!--pre-commit.ci end-->

---------

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
(cherry picked from commit 4b994df)
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
  • Loading branch information
pre-commit-ci[bot] and njzjz committed Apr 6, 2024
1 parent c0dc506 commit ba81a00
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repos:
exclude: ^source/3rdparty
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.2.1
rev: v0.2.2
hooks:
- id: ruff
args: ["--fix"]
Expand Down Expand Up @@ -75,7 +75,7 @@ repos:
#- id: cmake-lint
# license header
- repo: https://github.com/Lucas-C/pre-commit-hooks
rev: v1.5.4
rev: v1.5.5
hooks:
# C++, js
- id: insert-license
Expand Down
6 changes: 4 additions & 2 deletions source/tests/test_data_modifier_shuffle.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,10 @@ def _setUp_data(self):
self.nsel = 0
for ii in self.sel_type:
self.nsel += np.sum(self.atom_types0 == ii)
self.coords0 = np.random.random([self.nframes, self.natoms * 3]) * scale
self.dipoles0 = np.random.random([self.nframes, self.nsel * 3])
self.coords0 = (
np.random.default_rng().random([self.nframes, self.natoms * 3]) * scale
)
self.dipoles0 = np.random.default_rng().random([self.nframes, self.nsel * 3])
self.box0 = np.reshape(np.eye(3) * scale, [-1, 9])
self.box0 = np.tile(self.box0, [self.nframes, 1])
self._write_sys_data(
Expand Down
24 changes: 13 additions & 11 deletions source/tests/test_deepmd_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ def setUp(self):
self.natoms = 6
# coord
path = os.path.join(self.data_name, "set.foo", "coord.npy")
self.coord = np.random.random([self.nframes, self.natoms, 3])
self.coord = np.random.default_rng().random([self.nframes, self.natoms, 3])
np.save(path, np.reshape(self.coord, [self.nframes, -1]))
self.coord = self.coord[:, [0, 3, 1, 2, 4, 5], :]
self.coord = self.coord.reshape([self.nframes, -1])
# box
path = os.path.join(self.data_name, "set.foo", "box.npy")
self.box = np.random.random([self.nframes, 9])
self.box = np.random.default_rng().random([self.nframes, 9])
np.save(path, self.box)
# value
path = os.path.join(self.data_name, "set.foo", "value_1.npy")
Expand Down Expand Up @@ -92,49 +92,51 @@ def setUp(self):
self.natoms = 2
# coord
path = os.path.join(self.data_name, "set.foo", "coord.npy")
self.coord = np.random.random([self.nframes, self.natoms, 3])
self.coord = np.random.default_rng().random([self.nframes, self.natoms, 3])
np.save(path, np.reshape(self.coord, [self.nframes, -1]))
self.coord = self.coord[:, [1, 0], :]
self.coord = self.coord.reshape([self.nframes, -1])
# coord bar
path = os.path.join(self.data_name, "set.bar", "coord.npy")
self.coord_bar = np.random.random([self.nframes, 3 * self.natoms])
self.coord_bar = np.random.default_rng().random([self.nframes, 3 * self.natoms])
np.save(path, self.coord_bar)
self.coord_bar = self.coord_bar.reshape([self.nframes, self.natoms, 3])
self.coord_bar = self.coord_bar[:, [1, 0], :]
self.coord_bar = self.coord_bar.reshape([self.nframes, -1])
# coord tar
path = os.path.join(self.data_name, "set.tar", "coord.npy")
self.coord_tar = np.random.random([2, 3 * self.natoms])
self.coord_tar = np.random.default_rng().random([2, 3 * self.natoms])
np.save(path, self.coord_tar)
self.coord_tar = self.coord_tar.reshape([2, self.natoms, 3])
self.coord_tar = self.coord_tar[:, [1, 0], :]
self.coord_tar = self.coord_tar.reshape([2, -1])
# box
path = os.path.join(self.data_name, "set.foo", "box.npy")
self.box = np.random.random([self.nframes, 9])
self.box = np.random.default_rng().random([self.nframes, 9])
np.save(path, self.box)
# box bar
path = os.path.join(self.data_name, "set.bar", "box.npy")
self.box_bar = np.random.random([self.nframes, 9])
self.box_bar = np.random.default_rng().random([self.nframes, 9])
np.save(path, self.box_bar)
# box tar
path = os.path.join(self.data_name, "set.tar", "box.npy")
self.box_tar = np.random.random([2, 9])
self.box_tar = np.random.default_rng().random([2, 9])
np.save(path, self.box_tar)
# t a
path = os.path.join(self.data_name, "set.foo", "test_atomic.npy")
self.test_atomic = np.random.random([self.nframes, self.natoms, 7])
self.test_atomic = np.random.default_rng().random(
[self.nframes, self.natoms, 7]
)
self.redu_atomic = np.sum(self.test_atomic, axis=1)
np.save(path, np.reshape(self.test_atomic, [self.nframes, -1]))
self.test_atomic = self.test_atomic[:, [1, 0], :]
self.test_atomic = self.test_atomic.reshape([self.nframes, -1])
# t f
path = os.path.join(self.data_name, "set.foo", "test_frame.npy")
self.test_frame = np.random.random([self.nframes, 5])
self.test_frame = np.random.default_rng().random([self.nframes, 5])
np.save(path, self.test_frame)
path = os.path.join(self.data_name, "set.bar", "test_frame.npy")
self.test_frame_bar = np.random.random([self.nframes, 5])
self.test_frame_bar = np.random.default_rng().random([self.nframes, 5])
np.save(path, self.test_frame_bar)
# t n
self.test_null = np.zeros([self.nframes, 2 * self.natoms])
Expand Down
8 changes: 5 additions & 3 deletions source/tests/test_deepmd_data_sys.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,15 @@ def setUp(self):
set_name = os.path.join(sys_name, "set.%03d" % jj)
os.makedirs(set_name, exist_ok=True)
path = os.path.join(set_name, "coord.npy")
val = np.random.random([self.nframes[ii] + jj, self.natoms[ii] * 3])
val = np.random.default_rng().random(
[self.nframes[ii] + jj, self.natoms[ii] * 3]
)
np.save(path, val)
path = os.path.join(set_name, "box.npy")
val = np.random.random([self.nframes[ii] + jj, 9]) * 10
val = np.random.default_rng().random([self.nframes[ii] + jj, 9]) * 10
np.save(path, val)
path = os.path.join(set_name, "test.npy")
val = np.random.random(
val = np.random.default_rng().random(
[self.nframes[ii] + jj, self.natoms[ii] * self.test_ndof]
)
np.save(path, val)
Expand Down
4 changes: 2 additions & 2 deletions source/tests/test_descrpt_sea_ef_rot.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def build_efv(self, dcoord, dbox, dtype, tnatoms, name, op, reuse=None):
return energy, force, virial, atom_ener, atom_vir

def make_test_data(self, nframes):
dcoord = np.random.random([nframes, self.natoms[0], 3])
dcoord = np.random.default_rng().random([nframes, self.natoms[0], 3])
for ii in range(nframes):
dcoord[ii, :, :] = dcoord[ii, :, :] - np.tile(
dcoord[ii, 0, :], [self.natoms[0], 1]
Expand All @@ -111,7 +111,7 @@ def make_test_data(self, nframes):
np.random.shuffle(one_type) # noqa: NPY002
one_type = np.array(one_type, dtype=int).reshape([1, -1])
dtype = np.tile(one_type, [nframes, 1])
defield = np.random.random(dcoord.shape)
defield = np.random.default_rng().random(dcoord.shape)
return dcoord, dbox, dtype, defield

def rotate_mat(self, axis_, theta):
Expand Down
6 changes: 3 additions & 3 deletions source/tests/test_ewald.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,16 +38,16 @@ def setUp(self):
box = np.eye(3) * boxl
box[1][1] += 1
box[2][2] += 2
box += np.random.random([3, 3]) * box_pert
box += np.random.default_rng().random([3, 3]) * box_pert
box = 0.5 * (box + box.T)
self.dbox.append(box)
# scaled
coord = np.random.random([self.natoms, 3])
coord = np.random.default_rng().random([self.natoms, 3])
self.rcoord.append(coord)
# real coords
self.dcoord.append(np.matmul(coord, box))
# charge
dcharge = np.random.random([self.natoms])
dcharge = np.random.default_rng().random([self.natoms])
dcharge -= np.average(dcharge)
assert np.abs(np.sum(self.dcharge) - 0) < 1e-12
self.dcharge.append(dcharge)
Expand Down
8 changes: 4 additions & 4 deletions source/tests/test_gen_stat_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@
def gen_sys(nframes, atom_types):
natoms = len(atom_types)
data = {}
data["coords"] = np.random.random([nframes, natoms, 3])
data["forces"] = np.random.random([nframes, natoms, 3])
data["cells"] = np.random.random([nframes, 9])
data["energies"] = np.random.random([nframes, 1])
data["coords"] = np.random.default_rng().random([nframes, natoms, 3])
data["forces"] = np.random.default_rng().random([nframes, natoms, 3])
data["cells"] = np.random.default_rng().random([nframes, 9])
data["energies"] = np.random.default_rng().random([nframes, 1])
types = list(set(atom_types))
types.sort()
data["atom_names"] = []
Expand Down

0 comments on commit ba81a00

Please sign in to comment.