Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apply pytest suggestions from scientific python #371

Merged
merged 1 commit into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading