Skip to content

Commit 76b07f8

Browse files
committed
refactor(fuzzy_overlay)
1 parent 9a5e7a0 commit 76b07f8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

eis_toolkit/prediction/fuzzy_overlay.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ def sum_overlay(data: Union[Sequence[np.ndarray], np.ndarray]) -> np.ndarray:
9494
InvalidParameterValueException: If data values are not in range [0, 1].
9595
"""
9696
data = _prepare_data_for_fuzzy_overlay(data)
97-
return 1 - np.prod(1 - data, axis=0)
97+
product_term = np.prod(1 - data, axis=0)
98+
fuzzy_sum = 1 - product_term
99+
return fuzzy_sum
98100

99101

100102
@beartype
@@ -120,6 +122,7 @@ def gamma_overlay(data: Union[Sequence[np.ndarray], np.ndarray], gamma: float =
120122
if gamma < 0 or gamma > 1:
121123
raise InvalidParameterValueException("The gamma parameter must be in range [0, 1]")
122124

123-
product = np.prod(data, axis=0)
124-
sum = 1 - np.prod(1 - data, axis=0)
125-
return product ** (1 - gamma) * sum**gamma
125+
fuzzy_product = np.prod(data, axis=0)
126+
product_term_for_sum = np.prod(1 - data, axis=0)
127+
fuzzy_sum = 1 - product_term_for_sum
128+
return fuzzy_product ** (1 - gamma) * fuzzy_sum**gamma

0 commit comments

Comments
 (0)