Skip to content

Commit

Permalink
Update to ruff 0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ffl096 committed Dec 3, 2024
1 parent 3540143 commit 6142b71
Show file tree
Hide file tree
Showing 21 changed files with 69 additions and 67 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.7.0
rev: v0.8.1
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ select = [
"SLOT", # slot rules
"SIM", # code simplifications
"TID", # tidy imports
"TCH", # type checking rules
"TC", # type checking rules
"PTH", # use pathlib
"PD", # pandas rules
"PLC", # pylint conventions
Expand Down
6 changes: 3 additions & 3 deletions toponetx/algorithms/components.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
from toponetx.classes.combinatorial_complex import CombinatorialComplex

__all__ = [
"s_connected_components",
"s_component_subcomplexes",
"connected_components",
"connected_component_subcomplexes",
"connected_components",
"s_component_subcomplexes",
"s_connected_components",
]

# In this module, only cell complexes, combinatorial complexes and colored
Expand Down
2 changes: 1 addition & 1 deletion toponetx/algorithms/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from toponetx.classes.hyperedge import HyperEdge
from toponetx.exception import TopoNetXNoPath

__all__ = ["distance", "cell_distance"]
__all__ = ["cell_distance", "distance"]

# In this module, only cell complexes, combinatorial complexes and colored
# hypergraphs are supported.
Expand Down
2 changes: 1 addition & 1 deletion toponetx/algorithms/distance_measures.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from toponetx.classes.colored_hypergraph import ColoredHyperGraph
from toponetx.classes.combinatorial_complex import CombinatorialComplex

__all__ = ["node_diameters", "cell_diameters", "diameter", "cell_diameter"]
__all__ = ["cell_diameter", "cell_diameters", "diameter", "node_diameters"]

# In this module, only cell complexes, combinatorial complexes and colored
# hypergraphs are supported.
Expand Down
18 changes: 9 additions & 9 deletions toponetx/algorithms/spectrum.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@
from toponetx.classes.simplicial_complex import SimplicialComplex

__all__ = [
"hodge_laplacian_eigenvectors",
"set_hodge_laplacian_eigenvector_attrs",
"_normalize",
"cell_complex_adjacency_spectrum",
"cell_complex_hodge_laplacian_spectrum",
"combinatorial_complex_adjacency_spectrum",
"hodge_laplacian_eigenvectors",
"laplacian_beltrami_eigenvectors",
"laplacian_spectrum",
"cell_complex_hodge_laplacian_spectrum",
"simplicial_complex_hodge_laplacian_spectrum",
"cell_complex_adjacency_spectrum",
"set_hodge_laplacian_eigenvector_attrs",
"simplicial_complex_adjacency_spectrum",
"combinatorial_complex_adjacency_spectrum",
"simplicial_complex_hodge_laplacian_spectrum",
]


Expand All @@ -42,11 +42,11 @@ def _normalize(f: dict[Any, Any]) -> dict[Any, Any]:
minf = min(f.values())
maxf = max(f.values())
f_normalized = {}
for v in f:
for key, value in f.items():
if minf == maxf:
f_normalized[v] = 0
f_normalized[key] = 0
else:
f_normalized[v] = (f[v] - minf) / (maxf - minf)
f_normalized[key] = (value - minf) / (maxf - minf)

return f_normalized

Expand Down
18 changes: 9 additions & 9 deletions toponetx/classes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,22 +21,22 @@
from .simplicial_complex import SimplicialComplex

__all__ = [
"CellComplex",
"Cell",
"CombinatorialComplex",
"ColoredHyperGraph",
"Atom",
"AtomView",
"Cell",
"CellComplex",
"CellView",
"ColoredHyperEdgeView",
"ColoredHyperGraph",
"CombinatorialComplex",
"Complex",
"HyperEdge",
"HyperEdgeView",
"ColoredHyperEdgeView",
"CellView",
"SimplexView",
"NodeView",
"Path",
"PathComplex",
"PathView",
"Simplex",
"SimplexView",
"SimplicialComplex",
"Path",
"PathComplex",
]
6 changes: 3 additions & 3 deletions toponetx/classes/reportviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@

__all__ = [
"AtomView",
"HyperEdgeView",
"ColoredHyperEdgeView",
"CellView",
"SimplexView",
"ColoredHyperEdgeView",
"HyperEdgeView",
"NodeView",
"PathView",
"SimplexView",
]

T_Atom = TypeVar("T_Atom", bound=Atom)
Expand Down
2 changes: 1 addition & 1 deletion toponetx/datasets/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from toponetx.classes.simplicial_complex import SimplicialComplex
from toponetx.transform.graph_to_simplicial_complex import graph_to_clique_complex

__all__ = ["karate_club", "coauthorship"]
__all__ = ["coauthorship", "karate_club"]

DIR = Path(__file__).parent

Expand Down
2 changes: 1 addition & 1 deletion toponetx/datasets/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from toponetx.classes.cell_complex import CellComplex
from toponetx.classes.simplicial_complex import SimplicialComplex

__all__ = ["stanford_bunny", "shrec_16", "coseg"]
__all__ = ["coseg", "shrec_16", "stanford_bunny"]

DIR = Path(__file__).parent
SHREC_DS_MAP = {
Expand Down
4 changes: 2 additions & 2 deletions toponetx/exception.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Base errors and exceptions for TopoNetX."""

__all__ = [
"TopoNetXException",
"TopoNetXAlgorithmError",
"TopoNetXUnfeasible",
"TopoNetXException",
"TopoNetXNoPath",
"TopoNetXUnfeasible",
]


Expand Down
2 changes: 1 addition & 1 deletion toponetx/generators/classic_cell_complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from toponetx.classes import CellComplex
from toponetx.classes.cell import Cell

__all__ = ["single_cell_complex", "pyrmaid_complex"]
__all__ = ["pyrmaid_complex", "single_cell_complex"]


def single_cell_complex(n: int) -> CellComplex:
Expand Down
2 changes: 1 addition & 1 deletion toponetx/generators/random_simplicial_complexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

__all__ = [
"linial_meshulam_complex",
"random_clique_complex",
"multiparameter_linial_meshulam_complex",
"random_clique_complex",
]


Expand Down
2 changes: 1 addition & 1 deletion toponetx/readwrite/atomlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

__all__ = [
"generate_atomlist",
"write_atomlist",
"load_from_atomlist",
"parse_atomlist",
"write_atomlist",
]


Expand Down
2 changes: 1 addition & 1 deletion toponetx/readwrite/serialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pickle
from pathlib import Path

__all__ = ["to_pickle", "load_from_pickle"]
__all__ = ["load_from_pickle", "to_pickle"]


def to_pickle(obj, filename: str) -> None:
Expand Down
14 changes: 7 additions & 7 deletions toponetx/utils/normalization.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
from scipy.sparse import csr_matrix, diags

__all__ = [
"compute_laplacian_normalized_matrix",
"compute_x_laplacian_normalized_matrix",
"compute_kipf_adjacency_normalized_matrix",
"compute_xu_asymmetric_normalized_matrix",
"compute_bunch_normalized_matrices",
"_compute_B1_normalized_matrix",
"_compute_B1T_normalized_matrix",
"_compute_B2_normalized_matrix",
"_compute_B1_normalized_matrix",
"_compute_B2T_normalized_matrix",
"_compute_B2_normalized_matrix",
"_compute_D1",
"_compute_D2",
"_compute_D3",
"_compute_D5",
"compute_bunch_normalized_matrices",
"compute_kipf_adjacency_normalized_matrix",
"compute_laplacian_normalized_matrix",
"compute_x_laplacian_normalized_matrix",
"compute_xu_asymmetric_normalized_matrix",
]


Expand Down
6 changes: 3 additions & 3 deletions toponetx/utils/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
from scipy.sparse import csr_matrix

__all__ = [
"sparse_array_to_neighborhood_list",
"compute_set_incidence",
"incidence_to_adjacency",
"neighborhood_list_to_neighborhood_dict",
"sparse_array_to_neighborhood_dict",
"incidence_to_adjacency",
"compute_set_incidence",
"sparse_array_to_neighborhood_list",
]


Expand Down
6 changes: 3 additions & 3 deletions tutorials/01_simplicial_complexes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "1d48b70e",
"metadata": {},
"outputs": [],
"source": [
"from IPython import display\n",
"from IPython.display import Image\n",
"\n",
"display.Image(\"sc.png\")"
"Image(\"sc.png\")"
]
},
{
Expand Down
16 changes: 8 additions & 8 deletions tutorials/02_cell_complexes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "b4b84db3",
"metadata": {},
"outputs": [],
"source": [
"from IPython import display\n",
"from IPython.display import Image\n",
"\n",
"import toponetx\n",
"import toponetx as tnx\n",
"\n",
"display.Image(\"cc.png\")"
"Image(\"cc.png\")"
]
},
{
Expand Down Expand Up @@ -141,12 +141,12 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": null,
"id": "a48e579f",
"metadata": {},
"outputs": [],
"source": [
"example_1 = toponetx.CellComplex()\n",
"example_1 = tnx.CellComplex()\n",
"print(example_1)\n",
"\n",
"example_1.add_cell([1, 2], rank=1)\n",
Expand Down Expand Up @@ -180,12 +180,12 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "866efb53",
"metadata": {},
"outputs": [],
"source": [
"example_2 = toponetx.CellComplex()\n",
"example_2 = tnx.CellComplex()\n",
"print(example_2)\n",
"\n",
"example_2.add_cell([1, 2, 3], rank=2)\n",
Expand Down
12 changes: 6 additions & 6 deletions tutorials/03_combinatorial_complexes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "8cd070d7",
"metadata": {},
"outputs": [
Expand All @@ -35,11 +35,11 @@
}
],
"source": [
"from IPython import display\n",
"from IPython.display import Image\n",
"\n",
"import toponetx\n",
"import toponetx as tnx\n",
"\n",
"display.Image(\"ccc.png\")"
"Image(\"ccc.png\")"
]
},
{
Expand Down Expand Up @@ -135,7 +135,7 @@
},
{
"cell_type": "code",
"execution_count": 3,
"execution_count": null,
"id": "0ce2f1f7",
"metadata": {},
"outputs": [
Expand All @@ -152,7 +152,7 @@
}
],
"source": [
"example = toponetx.CombinatorialComplex()\n",
"example = tnx.CombinatorialComplex()\n",
"\n",
"example.add_cell([1, 2], rank=1)\n",
"print(example)\n",
Expand Down
10 changes: 6 additions & 4 deletions tutorials/04_colored_hypergraphs.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"id": "8cd070d7",
"metadata": {},
"outputs": [
Expand All @@ -35,9 +35,9 @@
}
],
"source": [
"from IPython import display\n",
"from IPython.display import Image\n",
"\n",
"display.Image(\"chg.png\")"
"Image(\"chg.png\")"
]
},
{
Expand All @@ -54,7 +54,9 @@
"id": "24d69d5e",
"metadata": {},
"outputs": [],
"source": "import toponetx as tnx"
"source": [
"import toponetx as tnx"
]
},
{
"cell_type": "markdown",
Expand Down

0 comments on commit 6142b71

Please sign in to comment.