Skip to content

Commit

Permalink
enable ruff and npy rules (#1998)
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
njzjz and pre-commit-ci[bot] authored Aug 27, 2023
1 parent 1bf57b7 commit 15f75b5
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ select = [
"I", # isort
"UP", # pyupgrade
"C4", # flake8-comprehensions
"RUF", # ruff
"NPY", # numpy
]
ignore = [
"E501", # line too long
Expand Down
2 changes: 1 addition & 1 deletion reacnetgenerator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from ._version import __version__

mpl.use("svg") # noqa
mpl.use("svg")

from .reacnetgen import ReacNetGenerator

Expand Down
6 changes: 3 additions & 3 deletions reacnetgenerator/_detect.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from abc import ABCMeta, abstractmethod
from collections import defaultdict
from enum import Enum, auto
from typing import Optional, Tuple
from typing import ClassVar, Optional, Tuple

import numpy as np

Expand Down Expand Up @@ -59,7 +59,7 @@ class _Detect(SharedRNGData, metaclass=ABCMeta):
The ReacNetGenerator class.
"""

subclasses = {}
subclasses: ClassVar[dict] = {}

# type hints
# TODO: we need a better way to communicate with parameters
Expand Down Expand Up @@ -223,7 +223,7 @@ def _readNfunc(self, f):
else:
iscompleted = True
stepaindex = index
N = [int(s) for s in line.split() if s.isdigit()][0]
N = next(int(s) for s in line.split() if s.isdigit())
atomtype = np.zeros(N, dtype=int)
else:
s = line.split()
Expand Down
5 changes: 2 additions & 3 deletions tests/test_reacnetgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,8 @@ def test_benchmark_hmm(self, benchmark, reacnetgen_param):
hmmclass = _HMMFilter(reacnetgen)
if hmmclass.runHMM:
hmmclass._initHMM()
index = np.sort(
np.random.choice(hmmclass.step, hmmclass.step // 2, replace=False)
)
rng = np.random.default_rng()
index = np.sort(rng.choice(hmmclass.step, hmmclass.step // 2, replace=False))
compressed_bytes = [
listtobytes((5, 6)),
listtobytes(((5, 6, 1),)),
Expand Down

0 comments on commit 15f75b5

Please sign in to comment.