Skip to content

Commit a5f1844

Browse files
committed
faster c2 call
1 parent 422960f commit a5f1844

File tree

1 file changed

+7
-6
lines changed
  • src/cytools/vector_config

1 file changed

+7
-6
lines changed

src/cytools/vector_config/fan.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -623,18 +623,19 @@ def c2(self, eps: float = 1e-4, digits: int = 4) -> "ArrayLike":
623623

624624
for two_cone in itertools.combinations(s, 2):
625625
two_cones.add(two_cone)
626+
two_cones = np.array(list(two_cones))-1
626627

627628
# get the intersection numbers
628629
kappa = self.intersection_numbers(
629-
pushed_down=True, symmetrize=False, eps=eps, digits=4
630+
pushed_down=True, as_np_array=True, eps=eps, digits=4
630631
)
631-
632+
632633
# compute c2
633634
out = []
634-
for a in range(1, max_ind + 1):
635-
out.append(
636-
round(sum(kappa.get(tuple(sorted(c + (a,))), 0) for c in two_cones))
637-
)
635+
for a in range(max_ind):
636+
vals = kappa[two_cones[:,0], two_cones[:,1], a]
637+
total = vals.sum()
638+
out.append( round(vals.sum()) )
638639

639640
return out
640641

0 commit comments

Comments
 (0)