Skip to content

Commit

Permalink
more ruff fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
DomFijan committed Apr 9, 2024
1 parent e2b1f45 commit 6e0002a
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ConservedWaterSearch/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ def visualise_nglview(
) -> NGLWidget:
"""Creates a nglview visualisation widget for results.
Starts a `nglview <https://github.com/nglviewer/nglview>`__ visualisation
Starts a `nglview <https://github.com/nglviewer/nglview>`__ visualisation
instance from clustering results.
Args:
Expand Down
10 changes: 6 additions & 4 deletions tests/test_hydrogen_orientation.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ def test_orientation_normalization():

def test_orientation_shape():
orientations = np.asarray([[[1]]])
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Input array must be 2-dimensional"):
ConservedWaterSearch.hydrogen_orientation.hydrogen_orientation_analysis(
orientations
)


def test_orientation_dimensions():
orientations = np.asarray([[1, 0], [0, 1]])
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Input array must have shape (N, 3)"):
ConservedWaterSearch.hydrogen_orientation.hydrogen_orientation_analysis(
orientations
)
Expand All @@ -48,15 +48,17 @@ def test_orientation_valid_input():

def test_orientation_size():
orientations = np.asarray([[1, 0, 0]])
with pytest.raises(ValueError):
with pytest.raises(ValueError, match="Input array must have shape (N, 3)"):
ConservedWaterSearch.hydrogen_orientation.hydrogen_orientation_analysis(
orientations
)


def test_orientation_array_odd():
orientations = np.asarray([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
with pytest.raises(ValueError):
with pytest.raises(
ValueError, match="Input array must have an even number of rows"
):
ConservedWaterSearch.hydrogen_orientation.hydrogen_orientation_analysis(
orientations
)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


@pytest.fixture(autouse=True)
def pymol_skip():
def _pymol_skip():
pytest.importorskip("pymol")


Expand Down
6 changes: 3 additions & 3 deletions tests/test_water_clustering.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import numpy as np
import numpy.testing as npt
import pytest

from ConservedWaterSearch.utils import (
get_orientations_from_positions,
Expand Down Expand Up @@ -140,10 +141,9 @@ def test_create_from_file():

def test_read_and_set_water_clust_options_file_not_found():
wc = WaterClustering(9)
try:
with pytest.raises(FileNotFoundError, match="output file not found") as e:
wc.read_and_set_water_clust_options("tests/data/nonexistent.dat")
except Exception as e:
assert str(e) == "output file not found"
assert str(e.value) == "output file not found"


def test_restart_cluster_onlyO():
Expand Down

0 comments on commit 6e0002a

Please sign in to comment.