Skip to content

Commit

Permalink
Clean up unused imports (#319)
Browse files Browse the repository at this point in the history
See #318. This gets almost all the LGTM issues.
  • Loading branch information
sdmccabe committed Dec 17, 2020
1 parent 9bac711 commit fc807bb
Show file tree
Hide file tree
Showing 18 changed files with 6 additions and 34 deletions.
3 changes: 0 additions & 3 deletions netrd/distance/dmeasure.py
Expand Up @@ -109,9 +109,6 @@ def dist(self, G1, G2, w1=0.45, w2=0.45, w3=0.10, niter=50):
second_term = 0
third_term = 0

N1 = G1.number_of_nodes()
N2 = G2.number_of_nodes()

if w1 + w2 > 0:
g1_nnd, g1_pdfs = network_node_dispersion(G1)
g2_nnd, g2_pdfs = network_node_dispersion(G2)
Expand Down
2 changes: 0 additions & 2 deletions netrd/distance/ipsen_mikhailov.py
Expand Up @@ -58,8 +58,6 @@ def dist(self, G1, G2, hwhm=0.08):
.. [1] https://journals.aps.org/pre/abstract/10.1103/PhysRevE.66.046109
"""
N = len(G1)

# get the adjacency matrices
adj1 = nx.to_numpy_array(G1)
adj2 = nx.to_numpy_array(G2)
Expand Down
4 changes: 0 additions & 4 deletions netrd/distance/nbd.py
Expand Up @@ -384,8 +384,4 @@ def euclidean_distance(x, y):
if status not in [solver.OPTIMAL, solver.FEASIBLE]:
raise Exception("Unable to find feasible solution")

for ((x, y), variable) in variables.items():
if variable.solution_value() != 0:
cost = euclidean_distance(x, y) * variable.solution_value()

return objective.Value()
1 change: 0 additions & 1 deletion netrd/distance/netsimile.py
Expand Up @@ -92,7 +92,6 @@ def feature_extraction(G):
node_degree_dict = dict(G.degree())
node_clustering_dict = dict(nx.clustering(G))
egonets = [nx.ego_graph(G, n) for n in node_list]
egonet_dict = {node: egonet for node, egonet in zip(node_list, egonets)}

# node degrees
degs = [node_degree_dict[n] for n in node_list]
Expand Down
1 change: 0 additions & 1 deletion netrd/distance/onion_divergence.py
Expand Up @@ -132,7 +132,6 @@ def _onion_decomposition(G):
def _update_sparse_matrix(dictionary, values, key, index):
# Creates entry if it doesn't exist or else update the corresponding value
if not key in dictionary:
index_i = index
dictionary[key] = index
values.append(1)
index += 1
Expand Down
2 changes: 1 addition & 1 deletion netrd/distance/portrait_divergence.py
Expand Up @@ -39,7 +39,7 @@
from collections import Counter
import numpy as np
import networkx as nx
from ..utilities import entropy, unweighted
from ..utilities import entropy


class PortraitDivergence(BaseDistance):
Expand Down
10 changes: 4 additions & 6 deletions netrd/dynamics/branching_process.py
Expand Up @@ -20,9 +20,6 @@
class BranchingModel(BaseDynamics):
"""A sand-pile-like branching process."""

def __init__(self):
self.results = {}

def simulate(
self,
G,
Expand Down Expand Up @@ -115,7 +112,6 @@ def simulate(
active_edges = G.out_edges(nbunch=active_nodes, data=True)

if len(active_edges) != 0:
current_sources = list(list(zip(*active_edges))[0])
current_targets = list(list(zip(*active_edges))[1])
weights_array = np.array([j[2]['weight'] for j in active_edges])

Expand Down Expand Up @@ -174,14 +170,16 @@ def initialize_history(N, L, initial_fraction, m, target_Ahat, noise):

# maybe also here initialize TS_init with external drives?
if m != 1.0:
N_nodes = 1000
if N > 1000:
N_nodes = N
else:
N_nodes = 1000
h_vals = np.random.poisson(target_Ahat * N_nodes * np.abs(1 - m), L)
else:
N_nodes = 100
if N > 100:
N_nodes = N
else:
N_nodes = 100
h_vals = np.random.poisson(0.01, L)
# h_vals = np.random.poisson(target_Ahat*N_nodes * 0.01, L)

Expand Down
1 change: 0 additions & 1 deletion netrd/reconstruction/correlation_matrix.py
Expand Up @@ -8,7 +8,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
from ..utilities import create_graph, threshold


Expand Down
2 changes: 0 additions & 2 deletions netrd/reconstruction/correlation_spanning_tree.py
Expand Up @@ -103,8 +103,6 @@ def fit(self, TS, distance='root_inv', **kwargs):
topology of stock markets. Quantitative Finance 1, 372–374.
"""
N, L = TS.shape

C = np.corrcoef(TS) # Empirical correlation matrix

D = (
Expand Down
2 changes: 0 additions & 2 deletions netrd/reconstruction/free_energy_minimization.py
Expand Up @@ -8,8 +8,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
import scipy as sp
from scipy import linalg
from ..utilities import create_graph, threshold

Expand Down
1 change: 0 additions & 1 deletion netrd/reconstruction/maximum_likelihood_estimation.py
Expand Up @@ -8,7 +8,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
from ..utilities import create_graph, threshold


Expand Down
2 changes: 0 additions & 2 deletions netrd/reconstruction/mean_field.py
Expand Up @@ -8,8 +8,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
import scipy as sp
from scipy import linalg
from scipy.integrate import quad
from scipy.optimize import fsolve
Expand Down
1 change: 0 additions & 1 deletion netrd/reconstruction/mutual_information_matrix.py
Expand Up @@ -14,7 +14,6 @@

from .base import BaseReconstructor
import numpy as np
import networkx as nx
from ..utilities import create_graph, threshold


Expand Down
3 changes: 1 addition & 2 deletions netrd/reconstruction/ou_inference.py
Expand Up @@ -14,9 +14,8 @@
"""

from .base import BaseReconstructor
import networkx as nx
import numpy as np
from scipy.linalg import eig, inv
from scipy.linalg import eig
from ..utilities import create_graph, threshold


Expand Down
1 change: 0 additions & 1 deletion netrd/reconstruction/partial_correlation_matrix.py
Expand Up @@ -11,7 +11,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
from scipy import stats, linalg
from ..utilities import create_graph, threshold

Expand Down
2 changes: 0 additions & 2 deletions netrd/reconstruction/thouless_anderson_palmer.py
Expand Up @@ -9,8 +9,6 @@
"""
from .base import BaseReconstructor
import numpy as np
import networkx as nx
import scipy as sp
from scipy import linalg
from ..utilities import create_graph, threshold

Expand Down
1 change: 0 additions & 1 deletion netrd/utilities/cluster.py
Expand Up @@ -10,7 +10,6 @@
Submitted as part of the 2019 NetSI Collabathon.
"""
import numpy as np
import networkx as nx
from scipy.cluster.hierarchy import dendrogram, linkage

Expand Down
1 change: 0 additions & 1 deletion netrd/utilities/read.py
Expand Up @@ -10,7 +10,6 @@
"""
import numpy as np
import networkx as nx


def read_time_series(filename, delimiter=','):
Expand Down

0 comments on commit fc807bb

Please sign in to comment.