Skip to content

Commit

Permalink
Merge branch 'master' into pre-commit-ci-update-config
Browse files Browse the repository at this point in the history
  • Loading branch information
njzjz authored Aug 5, 2024
2 parents 533c913 + 3a299ec commit 52bd3ab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mddatasetbuilder/datasetbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ def _calcoulumbmatrix(self, atoms):
with np.errstate(divide="ignore", invalid="ignore"):
np.divide(top, r, top)
np.fill_diagonal(top, diag)
top[top == np.Infinity] = 0
top[top == np.inf] = 0
top[np.isnan(top)] = 0
return np.linalg.eigh(top)[0]

Expand Down Expand Up @@ -375,10 +375,11 @@ def _clusterdatas(cls, X, n_clusters, n_each=1):
)
labels = clus.fit_predict(X)
choosedidx = []
rng = np.random.default_rng()
for i in range(n_clusters):
idx = np.where(labels == i)[0]
if idx.size:
choosedidx.append(np.random.choice(idx, n_each))
choosedidx.append(rng.choice(idx, n_each))
index = np.concatenate(choosedidx)
return index

Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ select = [
"I", # isort
"UP", # pyupgrade
"C4", # flake8-comprehensions
"NPY", # numpy
]
ignore = [
"E501", # line too long
Expand Down

0 comments on commit 52bd3ab

Please sign in to comment.