Skip to content
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
14 changes: 10 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,16 @@ name: Python package

on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ "3.9", "3.10", "3.11", "3.12", "3.13", "3.14", "3.15" ]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15"]

steps:
- uses: actions/checkout@v3
Expand All @@ -39,6 +38,13 @@ jobs:
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude env/
# exit-zero treats all errors as warnings
flake8 . --count --exit-zero --max-complexity=15 --max-line-length=120 --statistics --exclude env/
- name: Type checking with mypy
# numpy no longer supports <3.12, so typing is unreliable
if: ${{ !contains(fromJSON('["3.10", "3.11"]'), matrix.python-version) }}
run: |
source env/bin/activate
python -m pip install mypy
python -m mypy utilities/ --install-types --non-interactive
- name: Test with pytest
run: |
source env/bin/activate
Expand Down
12 changes: 12 additions & 0 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[mypy]
strict = True
disallow_any_explicit = True
files = utilities/*.py, tests/*.py

[mypy-sklearn.*,igraph.*,leidenalg.*]
ignore_missing_imports = True

# tests are untyped, but we want to check their usage is correct
[mypy-tests.*]
allow_untyped_defs = True
allow_untyped_calls = True
9 changes: 6 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ name = "modularitypruning"
version = "1.5.1"
description = "Pruning tool to identify small subsets of network partitions that are significant from the perspective of stochastic block model inference."
readme = "README.md"
requires-python = ">=3.9"
requires-python = ">=3.10"
license = "MIT"
authors = [
{ name = "Ryan Gibson", email = "ryan.alex.gibson@gmail.com" }
Expand All @@ -17,14 +17,14 @@ classifiers = [
"Development Status :: 5 - Production/Stable",
"Topic :: Scientific/Engineering :: Information Analysis",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
"Programming Language :: Python :: 3.15",
"Programming Language :: Python :: 3 :: Only"
"Programming Language :: Python :: 3 :: Only",
"Typing :: Typed"
]
dependencies = [
"leidenalg",
Expand All @@ -44,5 +44,8 @@ packages = ["modularitypruning"]
[tool.setuptools.package-dir]
modularitypruning = "utilities"

[tool.setuptools.package-data]
modularitypruning = ["py.typed"]

[tool.autopep8]
max_line_length = 120
2 changes: 1 addition & 1 deletion tests/shared_testing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def generate_multilayer_intralayer_SBM(copying_probability, p_in, p_out, first_l
if random() < p_out:
intralayer_edges.append((u, v))

G_intralayer = ig.Graph(intralayer_edges, directed=False)
G_intralayer = ig.Graph(n=len(combined_community_labels), edges=intralayer_edges, directed=False)

return G_intralayer, layer_membership

Expand Down
2 changes: 1 addition & 1 deletion tests/test_documentation_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_plot_multiplex_community(self):
ax = plot_multiplex_community(np.array(membership), np.array(layer_vec))
ax.set_xticks(np.linspace(0, num_layers, 2 * num_layers + 1))
ax.set_xticklabels(["", "Advice", "", "Coworker", "", "Friend", ""], fontsize=14)
plt.title(f"Multiplex Communities", fontsize=14)
plt.title("Multiplex Communities", fontsize=14)
plt.ylabel("Node ID", fontsize=14)
plt.close() # closing this these figures instead of showing

Expand Down
4 changes: 2 additions & 2 deletions tests/test_parallel_leiden_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ def determine_target_parallelization_speedup(num_calculations=32):
cpu_utilization = psutil.cpu_percent(interval=5)
if cpu_utilization > 20:
PERFORMANCE_TARGET_RELATIVE_TO_PERFECT_SCALING = 0.5
warnings.warn(f"System CPU utilization is non-negligible during parallel performance test! "
f"Dropping performance scaling target to 50%.")
warnings.warn("System CPU utilization is non-negligible during parallel performance test! "
"Dropping performance scaling target to 50%.")

start_time = time()
_ = [mock_calculation(i) for i in range(num_calculations)]
Expand Down
1 change: 1 addition & 0 deletions tests/test_temporal_multilevel_parameter_estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ def retry_test_across_graph_sizes(self, test_fn, sizes=[50, 100, 250, 500], retr
if not isinstance(e, AssertionError):
# test failed in unusual way (perhaps keyboard interrupt?), raising immediately
raise e
assert last_error is not None
raise last_error

def test_temporal_SBM_correct_convergence_varying_copying_probabilty(self):
Expand Down
7 changes: 6 additions & 1 deletion utilities/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
# this makes prune_to_stable_partitions and prune_to_multilayer_stable_partitions importable from the top-level package
from .parameter_estimation_utilities import prune_to_stable_partitions, prune_to_multilayer_stable_partitions # noqa
from .parameter_estimation_utilities import (
prune_to_multilayer_stable_partitions as prune_to_multilayer_stable_partitions,
prune_to_stable_partitions as prune_to_stable_partitions,
)

__all__ = ["prune_to_stable_partitions", "prune_to_multilayer_stable_partitions"]
Loading
Loading