mirror of
https://github.com/ANL-CEEESA/MIPLearn.git
synced 2025-12-06 09:28:51 -06:00
AlvLouWeh2017: Remove slow loop in M3
This commit is contained in:
@@ -356,17 +356,8 @@ class FeaturesExtractor:
|
|||||||
push(np.abs(v))
|
push(np.abs(v))
|
||||||
|
|
||||||
def maxmin(M: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
|
def maxmin(M: np.ndarray) -> Tuple[np.ndarray, np.ndarray]:
|
||||||
# Compute max using regular numpy operations
|
|
||||||
M_max = np.ravel(M.max(axis=0).todense())
|
M_max = np.ravel(M.max(axis=0).todense())
|
||||||
|
M_min = np.ravel(M.min(axis=0).todense())
|
||||||
# Compute min by iterating through the sparse matrix data, so that
|
|
||||||
# we skip non-zero entries
|
|
||||||
M_min = np.array(
|
|
||||||
[
|
|
||||||
0.0 if len(M[:, j].data) == 0 else M[:, j].data.min()
|
|
||||||
for j in range(M.shape[1])
|
|
||||||
]
|
|
||||||
)
|
|
||||||
return M_max, M_min
|
return M_max, M_min
|
||||||
|
|
||||||
with np.errstate(divide="ignore", invalid="ignore"):
|
with np.errstate(divide="ignore", invalid="ignore"):
|
||||||
|
|||||||
Reference in New Issue
Block a user