Skip to content

Commit

Permalink
fixed issue for looplessness
Browse files Browse the repository at this point in the history
  • Loading branch information
peach-lucien committed Nov 29, 2021
1 parent 6718b34 commit b185118
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion hcga/features/looplessness.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@


@lru_cache(maxsize=None)

def looplessness(graph): # pylint: disable=too-many-locals
"""Looplessness measure class
Expand Down Expand Up @@ -95,18 +96,24 @@ def looplessness(graph): # pylint: disable=too-many-locals
for i in non_basal:
equations.append(sp.Eq(LHS[i], RHS[i]))

sols = list(sp.linsolve(equations, s))[0]
linear_solution = list(sp.linsolve(equations, s))

sols = linear_solution[0]


# Replace symbols with their trophic level value
for i, j in enumerate(non_basal):
trophic[j] = sols[i]

trophic = [float(t) for t in trophic]

# Compute trophic difference matrix
trophic_diff = np.zeros([n, n])
for i in range(n):
for j in range(n):
trophic_diff[i, j] = trophic[i] - trophic[j]
trophic_diff_sq = np.square(trophic_diff)

# Compute incoherence parameter
incoherence_parameter = np.sqrt((np.sum(np.multiply(a, trophic_diff_sq)) - 1) / e)

Expand Down

0 comments on commit b185118

Please sign in to comment.