Skip to content

Commit d70ab7a

Browse files
committed
more fixes
1 parent bc3cffb commit d70ab7a

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

xgi/drawing/draw.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from ..convert import to_bipartite_edgelist
2525
from ..core import DiHypergraph, Hypergraph, SimplicialComplex
2626
from ..exception import XGIError
27-
from ..utils import subfaces, crest_r
27+
from ..utils import crest_r, subfaces
2828
from .draw_utils import (
2929
_CCW_sort,
3030
_draw_arg_to_arr,

xgi/utils/tensor.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
## Tensor times same vector in all but one (TTSV1) and all but two (TTSV2)
2+
import math
23
from collections import defaultdict
34
from itertools import combinations
4-
from math import factorial
55

66
import numpy as np
7-
from numpy import prod
8-
from scipy.signal import convolve
9-
from scipy.sparse import coo_array
10-
from scipy.special import binom as binomial
117

128
__all__ = [
139
"pairwise_incidence",
@@ -78,9 +74,10 @@ def banerjee_coeff(size, max_size):
7874
Sinan Aksoy, Ilya Amburg, Stephen Young,
7975
https://doi.org/10.1137/23M1584472
8076
"""
77+
from scipy.special import binom
78+
8179
return sum(
82-
((-1) ** j) * binomial(size, j) * (size - j) ** max_size
83-
for j in range(size + 1)
80+
((-1) ** j) * binom(size, j) * (size - j) ** max_size for j in range(size + 1)
8481
)
8582

8683

@@ -119,15 +116,15 @@ def ttsv1(node_dict, edge_dict, r, a):
119116
"""
120117
n = len(node_dict)
121118
s = np.zeros(n)
122-
r_minus_1_factorial = factorial(r - 1)
119+
r_minus_1_factorial = math.factorial(r - 1)
123120
for node, edges in node_dict.items():
124121
c = 0
125122
for e in edges:
126123
l = len(edge_dict[e])
127124
alpha = banerjee_coeff(l, r)
128125
edge_without_node = [v for v in edge_dict[e] if v != node]
129126
if l == r:
130-
gen_fun_coef = prod(a[edge_without_node])
127+
gen_fun_coef = np.prod(a[edge_without_node])
131128
elif 2 ** (l - 1) < r * (l - 1):
132129
gen_fun_coef = _get_gen_coef_subset_expansion(
133130
a[edge_without_node], a[node], r - 1
@@ -175,6 +172,9 @@ def ttsv2(pair_dict, edge_dict, r, a, n):
175172
Sinan Aksoy, Ilya Amburg, Stephen Young,
176173
https://doi.org/10.1137/23M1584472
177174
"""
175+
from scipy.signal import convolve
176+
from scipy.sparse import coo_array
177+
178178
s = {}
179179
r_minus_2_factorial = factorial(r - 2)
180180
for (v1, v2), edges in pair_dict.items():
@@ -317,6 +317,8 @@ def _get_gen_coef_fft_fast_array(edge_without_node, a, node, l, r):
317317
Sinan Aksoy, Ilya Amburg, Stephen Young,
318318
https://doi.org/10.1137/23M1584472
319319
"""
320+
from scipy.signal import convolve
321+
320322
coefs = [1]
321323
for i in range(1, r):
322324
coefs.append(coefs[-1] * a[node] / i)

xgi/utils/utilities.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"crest_r",
3232
]
3333

34+
3435
class IDDict(dict):
3536
"""A dict that holds (node or edge) IDs.
3637
@@ -593,5 +594,9 @@ def geometric(p):
593594

594595

595596
def crest_r():
596-
palette = [(0.17363177, 0.19076859, 0.44549087), (0.20350004, 0.5231837, 0.55370601), (0.6468274, 0.80289262, 0.56592265)]
597-
return LinearSegmentedColormap.from_list("crest_r", palette)
597+
palette = [
598+
(0.17363177, 0.19076859, 0.44549087),
599+
(0.20350004, 0.5231837, 0.55370601),
600+
(0.6468274, 0.80289262, 0.56592265),
601+
]
602+
return LinearSegmentedColormap.from_list("crest_r", palette)

0 commit comments

Comments
 (0)