Skip to content

Commit

Permalink
fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
cbouy committed Aug 26, 2024
1 parent 6d69af3 commit 899f74b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 19 deletions.
6 changes: 2 additions & 4 deletions prolif/interactions/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,9 @@ def metadata(self, lig_res, prot_res, lig_indices, prot_indices, **data):
"protein": prot_indices,
},
"parent_indices": {
"ligand": tuple(
[get_mapindex(lig_res, index) for index in lig_indices],
),
"ligand": tuple(get_mapindex(lig_res, index) for index in lig_indices),
"protein": tuple(
[get_mapindex(prot_res, index) for index in prot_indices],
get_mapindex(prot_res, index) for index in prot_indices
),
},
**data,
Expand Down
7 changes: 3 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,7 @@ exclude = [
"dist",
"site-packages",
]

[tool.ruff.format]
exclude = ["*.ipynb"]
extend-exclude = ["*.ipynb"]

[tool.ruff.lint]
select = [
Expand Down Expand Up @@ -150,7 +148,8 @@ select = [
]
ignore = [
"PLW1514", "PTH123", "PLR0904", "PLR0911", "PLR0913", "PLR0914", "PLR0915",
"PLR0916", "PLR0917", "PLR2004", "PLR6301", "PD901", "PT018", "FURB103", "COM812",
"PLR0916", "PLR0917", "PLR2004", "PLR6301", "PD901", "PT001", "PT018", "FURB103",
"COM812",
# typing incompatible with 3.9
"UP035", "UP006", "UP007",
]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_ifp.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def ifp(u, ligand_ag, protein_ag) -> IFP:

def test_ifp_indexing(ifp: IFP) -> None:
lig_id, prot_id = "LIG1.G", "LEU126.A"
metadata1 = ifp[(ResidueId.from_string(lig_id), ResidueId.from_string(prot_id))]
metadata2 = ifp[(lig_id, prot_id)]
metadata1 = ifp[ResidueId.from_string(lig_id), ResidueId.from_string(prot_id)]
metadata2 = ifp[lig_id, prot_id]
assert metadata1 is metadata2


Expand All @@ -24,7 +24,7 @@ def test_ifp_filtering(ifp: IFP) -> None:
assert ifp[lig_id] == ifp
assert (
next(iter(ifp[prot_id].values()))
== ifp[(ResidueId.from_string(lig_id), ResidueId.from_string(prot_id))]
== ifp[ResidueId.from_string(lig_id), ResidueId.from_string(prot_id)]
)


Expand Down
2 changes: 1 addition & 1 deletion tests/test_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def detect(self):
assert old != new
# fix dummy Hydrophobic class being reused in later unrelated tests

class Hydrophobic(prolif.interactions.Hydrophobic): # noqa: F811
class Hydrophobic(prolif.interactions.Hydrophobic):
__doc__ = prolif.interactions.Hydrophobic.__doc__

def test_error_no_detect(self):
Expand Down
14 changes: 7 additions & 7 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ def test_to_df(ifp):
assert df.dtypes.iloc[0].type is np.bool_
assert df.index.name == "Frame"
assert ("LIG", "ALA1", "A") in df.columns
assert df[("LIG", "ALA1", "A")][0] is np.bool_(True)
assert df["LIG", "ALA1", "A"][0] is np.bool_(True)
assert ("LIG", "ALA1", "B") in df.columns
assert df[("LIG", "ALA1", "B")][0] is np.bool_(False)
assert df["LIG", "ALA1", "B"][0] is np.bool_(False)
assert ("LIG", "ALA1", "C") not in df.columns
assert ("LIG", "GLU2", "A") not in df.columns
assert ("LIG", "ASP3", "B") in df.columns
assert df[("LIG", "ASP3", "B")][0] is np.bool_(False)
assert df["LIG", "ASP3", "B"][0] is np.bool_(False)


@pytest.mark.parametrize(
Expand All @@ -219,9 +219,9 @@ def test_to_df(ifp):
def test_to_df_dtype(dtype, ifp):
df = to_dataframe(ifp, ["A", "B", "C"], dtype=dtype)
assert df.dtypes.iloc[0].type is dtype
assert df[("LIG", "ALA1", "A")][0] == dtype(True)
assert df[("LIG", "ALA1", "B")][0] == dtype(False)
assert df[("LIG", "ASP3", "B")][0] == dtype(False)
assert df["LIG", "ALA1", "A"][0] == dtype(True)
assert df["LIG", "ALA1", "B"][0] == dtype(False)
assert df["LIG", "ASP3", "B"][0] == dtype(False)


def test_to_df_drop_empty(ifp):
Expand All @@ -238,7 +238,7 @@ def test_to_df_no_interaction_in_first_frame(ifp_single):
def test_to_df_count(ifp_count):
df = to_dataframe(ifp_count, ["A", "B", "C"], count=True)
assert df[df > 1].any().any()
value = df[("LIG", "ALA1", "A")][0]
value = df["LIG", "ALA1", "A"][0]
assert value.dtype == np.uint8
assert value == 2

Expand Down

0 comments on commit 899f74b

Please sign in to comment.