Skip to content

Commit

Permalink
Merge pull request #308 from neutrinoceros/black2ruff
Browse files Browse the repository at this point in the history
STY: migrate from black to ruff-format
  • Loading branch information
neutrinoceros authored Apr 5, 2024
2 parents fe8ee8a + a64f66e commit a40e1a0
Show file tree
Hide file tree
Showing 10 changed files with 5 additions and 21 deletions.
6 changes: 1 addition & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ repos:
hooks:
- id: inifix-format

- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.3.0
hooks:
- id: black

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.3.5
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --show-fixes]

Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
[![PyPI](https://img.shields.io/badge/requires-Python%20≥%203.8-blue?logo=python&logoColor=white)](https://pypi.org/project/nonos/)
[![Documentation Status](https://readthedocs.org/projects/nonos/badge/?version=latest)](https://nonos.readthedocs.io/en/latest/?badge=latest)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/volodia99/nonos/main.svg)](https://results.pre-commit.ci/badge/github/volodia99/nonos/main.svg)
[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/charliermarsh/ruff/main/assets/badge/v2.json)](https://github.com/charliermarsh/ruff)

nonos is a 2D visualization command line application for planet-disk numerical simulations, as well as a Python library. It works with vtk-formatted data from Pluto and Idefix, and dat-formatted data for Fargo-adsg and Fargo3D.
Expand Down
1 change: 0 additions & 1 deletion nonos/_readers/binary.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,6 @@ def _read_array(file: Path):


class NPYReader(ReaderMixin):

# we accept a leading '_' for backward compatibility
_filename_re = re.compile(
r"^_?(?P<prefix>[\w\.]*)"
Expand Down
1 change: 0 additions & 1 deletion nonos/_readers/ini.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
class IdefixVTKReader(ReaderMixin):
@staticmethod
def read(file: PathT, /) -> IniData:

class IdefixIniOutput:
def __init__(self, *, vtk, **_kwargs) -> None:
self.vtk = float(vtk)
Expand Down
1 change: 0 additions & 1 deletion nonos/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class FrameType(Enum):
@final
@dataclass(frozen=True, eq=False)
class BinData:

# TODO: use slots=True in @dataclass when Python 3.9 is dropped
__slots__ = ["data", "geometry", "x1", "x2", "x3"]
data: StrDict
Expand Down
4 changes: 1 addition & 3 deletions nonos/api/from_simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,9 +757,7 @@ def idfxReadVTK(
if computedata:
logger.debug("loading data arrays")
while 1:
s = (
fid.readline()
) # SCALARS/VECTORS name data_type (ex: SCALARS imagedata unsigned_char)
s = fid.readline() # SCALARS/VECTORS name data_type (ex: SCALARS imagedata unsigned_char)
# print repr(s)
if len(s) < 2: # leave if end of file
break
Expand Down
4 changes: 1 addition & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,7 @@ def test_logo(capsys):
`:|}$$$$}):`
Analysis tool for idefix/pluto/fargo3d simulations (in polar coordinates).
""".lstrip(
"\n"
)
""".lstrip("\n")
)
expected += f"Version {__version__}\n"
assert out == expected
Expand Down
5 changes: 2 additions & 3 deletions tests/test_interfaces/test_binary_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,27 @@


class TestVTKReader:

# fmt: off
@pytest.mark.parametrize(
"file,expected_fields",
[
(
("micro_cubes", "micro_orszagtang.vtk"),
# fmt: off
[
"BX1","BX2", "BX3",
"PRS",
"RHO",
"TR0", "TR1",
"VX1", "VX2", "VX3"
],
# fmt: on
),
(
("micro_cubes", "micro_disk.vtk"),
["RHO", "VX1", "VX2", "VX3"],
),
],
)
# fmt: on
def test_fields(self, test_data_dir, file, expected_fields):
bd = VTKReader.read(test_data_dir.joinpath(*file))
fields = sorted(bd.data.keys())
Expand Down
1 change: 0 additions & 1 deletion tests/test_interfaces/test_ini_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def compile_to_Fargo3D(text: str) -> str:

@pytest.mark.parametrize("reader", [Fargo3DReader, FargoADSGReader])
class TestFargoReaders:

def compile(self, text: str, reader: IniReader) -> str:
if reader is FargoADSGReader:
return compile_to_FargoADSG(text)
Expand Down
2 changes: 0 additions & 2 deletions tests/test_interfaces/test_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@


class TestLoader:

@pytest.fixture(params=Loader.__slots__, ids=lambda s: s.removesuffix("_"))
def loader_slot(self, request):
return request.param
Expand Down Expand Up @@ -185,7 +184,6 @@ def test_ambiguous_directory(self, tmp_path):
],
)
class TestLoaderFrom:

def test_loaders_from_user_inputs(self, test_data_dir, parameter_file, code):
parameter_file = test_data_dir.joinpath(*parameter_file)
directory = parameter_file.parent
Expand Down

0 comments on commit a40e1a0

Please sign in to comment.