Skip to content

Commit

Permalink
Resolve linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ragibson committed Sep 24, 2022
1 parent 382f6e0 commit 420574e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ jobs:
source env/bin/activate
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude env/
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --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: Test with pytest
run: |
source env/bin/activate
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@

def plot_and_exit(G, ranges):
layout = ig.Graph.layout_fruchterman_reingold(G, niter=1000)
print(f"plotting network...")
print("plotting network...")
ig.plot(G, layout=layout).save("network.png")

print(f"plotting CHAMP domains and gamma estimates...")
print("plotting CHAMP domains and gamma estimates...")
gamma_estimates = ranges_to_gamma_estimates(G, ranges)
plt.rc('text', usetex=True)
plt.rc('font', family='serif')
Expand Down
3 changes: 2 additions & 1 deletion tests/test_monolayer_parameter_estimation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from .shared_testing_functions import assert_almost_equal_or_both_none_or_nan, generate_igraph_famous, generate_random_partition
from .shared_testing_functions import assert_almost_equal_or_both_none_or_nan, generate_igraph_famous, \
generate_random_partition
import igraph as ig
from math import log
from numpy import mean
Expand Down
19 changes: 14 additions & 5 deletions utilities/parameter_estimation_utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,9 @@ def gamma_estimate(G, partition):


def gamma_estimate_from_parameters(omega_in, omega_out):
"""Compute the "correct" value of gamma as in :meth:`~modularitypruning.parameter_estimation_utilities.gamma_estimate` from SBM parameters.
"""
Compute the "correct" value of gamma as in
:meth:`~modularitypruning.parameter_estimation_utilities.gamma_estimate` from SBM parameters.
:param omega_in: within-community edge propensity of a degree-corrected, planted partition SBM
:type omega_in: float
Expand Down Expand Up @@ -361,11 +363,14 @@ def gamma_omega_estimate(G_intralayer, G_interlayer, layer_vec, membership, omeg


def ranges_to_gamma_estimates(G, ranges):
"""Compute gamma estimates as in :meth:`~modularitypruning.parameter_estimation_utilities.gamma_estimate`, given domains of optimality from :meth:`~modularitypruning.champ_utilities.CHAMP_2D`.
"""
Compute gamma estimates as in :meth:`~modularitypruning.parameter_estimation_utilities.gamma_estimate`, given
domains of optimality from :meth:`~modularitypruning.champ_utilities.CHAMP_2D`.
:param G: graph of interest
:type G: igraph.Graph
:param ranges: list of ``(gamma_start, gamma_end, membership)`` tuples as returned from :meth:`~modularitypruning.champ_utilities.CHAMP_2D`
:param ranges: list of ``(gamma_start, gamma_end, membership)`` tuples as returned from
:meth:`~modularitypruning.champ_utilities.CHAMP_2D`
:type ranges: list of tuple[float, float, tuple[int]]
:return: a copy of input ranges with the corresponding gamma estimate appended to each tuple
:rtype: list of tuple[float, float, tuple[int], float]
Expand Down Expand Up @@ -393,15 +398,19 @@ def gamma_estimates_to_stable_partitions(gamma_estimates):


def domains_to_gamma_omega_estimates(G_intralayer, G_interlayer, layer_vec, domains, model='temporal'):
"""Compute (gamma, omega) estimates as in :meth:`~modularitypruning.parameter_estimation_utilities.gamma_omega_estimate`, given domains of optimality from :meth:`~modularitypruning.champ_utilities.CHAMP_3D`.
"""
Compute (gamma, omega) estimates as in
:meth:`~modularitypruning.parameter_estimation_utilities.gamma_omega_estimate`, given domains of optimality from
:meth:`~modularitypruning.champ_utilities.CHAMP_3D`.
:param G_intralayer: intralayer graph of interest
:type G_intralayer: igraph.Graph
:param G_interlayer: interlayer graph of interest
:type G_interlayer: igraph.Graph
:param layer_vec: list of each vertex's layer membership
:type layer_vec: list[int]
:param domains: list of ``(domain_vertices, membership)`` tuples as returned from :meth:`~modularitypruning.champ_utilities.CHAMP_3D`
:param domains: list of ``(domain_vertices, membership)`` tuples as returned from
:meth:`~modularitypruning.champ_utilities.CHAMP_3D`
:type domains: list of tuple[list[float], tuple[int]]
:param model: network layer topology (temporal, multilevel, multiplex)
:type model: str
Expand Down

0 comments on commit 420574e

Please sign in to comment.