Skip to content

Commit

Permalink
Merge pull request #371 from pyt-team/frantzen/pytest-recommendations
Browse files Browse the repository at this point in the history
Apply pytest suggestions from scientific python
  • Loading branch information
ffl096 authored Jun 21, 2024
2 parents af01e73 + b7139d0 commit f7982d2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.14
rev: v0.4.10
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
11 changes: 10 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ dependencies=[
"networkx",
"numpy",
"pandas",
"pyarrow",
"requests",
"scipy",
"trimesh",
Expand Down Expand Up @@ -125,7 +126,15 @@ disable_error_code = ["import-untyped"]
plugins = "numpy.typing.mypy_plugin"

[tool.pytest.ini_options]
addopts = "--capture=no"
minversion = "7.0"
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config"]
xfail_strict = true
filterwarnings = [
"error",
"ignore::scipy.sparse._base.SparseEfficiencyWarning",
]
log_cli_level = "info"
testpaths = ["test"]

[tool.coverage.report]
exclude_lines = ["pragma: not covered", "@overload"]
Expand Down
17 changes: 8 additions & 9 deletions test/classes/test_simplex.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ def test_simplex_creation(self):

def test_simplex_sign(self):
"""Test simplex sign method."""
s = Simplex(
[
1,
]
)
s = Simplex([1])
with pytest.raises(NotImplementedError):
s.sign(face=1)

Expand Down Expand Up @@ -73,15 +69,18 @@ def test__contains__(self):

def test_construct_tree(self):
"""Test the construct_tree property of the simplex."""
s = Simplex((1, 2, 3), construct_tree=True)
assert len(s.boundary) == 3
with pytest.warns(DeprecationWarning):
s = Simplex((1, 2, 3), construct_tree=True)
with pytest.warns(DeprecationWarning):
assert len(s.boundary) == 3

s = Simplex((1, 2, 3), construct_tree=False)
assert len(s.boundary) == 3
with pytest.warns(DeprecationWarning):
assert len(s.boundary) == 3

def test_getting_and_setting_items(self):
"""Test getting and setting items in the simplex."""
s = Simplex((1, 2, 3), construct_tree=True)
s = Simplex((1, 2, 3))
s["weight"] = 1
assert s["weight"] == 1

Expand Down
4 changes: 1 addition & 3 deletions toponetx/classes/cell_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -790,9 +790,7 @@ def add_cell(
if not isinstance(cell, list):
cell = list(cell)

if self.is_insertable_cycle(
cell, check_skeleton=check_skeleton, warnings_dis=True
):
if self.is_insertable_cycle(cell, check_skeleton):
edges_cell = set(zip_longest(cell, cell[1:] + [cell[0]]))
self._G.add_edges_from(edges_cell)
self._insert_cell(Cell(cell, regular=self._regular), **attr)
Expand Down
3 changes: 1 addition & 2 deletions toponetx/classes/simplicial_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,12 +463,11 @@ def remove_maximal_simplex(self, simplex: Collection) -> None:
if simplex_ in self._simplex_set.faces_dict[len(simplex_) - 1]:
if self.is_maximal(simplex):
del self._simplex_set.faces_dict[len(simplex_) - 1][simplex_]
faces = Simplex(simplex_).faces
faces = self.get_boundaries([simplex_])
for s in faces:
if len(s) == len(simplex_):
continue

s = s.elements
self._simplex_set.faces_dict[len(s) - 1][s]["membership"] -= {
simplex_
}
Expand Down

0 comments on commit f7982d2

Please sign in to comment.