优化管道权重处理,增加非有限权重检查
This commit is contained in:
@@ -403,7 +403,7 @@ def cal_signature_pipe_multi_pf(
|
||||
wn, leak_mag, candidate_center[i], sensor_name
|
||||
)
|
||||
# leak_or_not_list.append(leak_or_not)
|
||||
pressure_leak.loc[candidate_center[i]].loc[:, :] = pressure_output
|
||||
pressure_leak.loc[(candidate_center[i], slice(None)), :] = pressure_output.to_numpy()
|
||||
# flow_leak.loc[candidate_center[i]].loc[:, :] = flow_output
|
||||
sys.stdout.write("\r" + "已经完成计算" + str(i + 1) + "个特征中心")
|
||||
return pressure_leak, candidate_center
|
||||
|
||||
@@ -12,6 +12,14 @@ from scipy.sparse import coo_matrix, csr_matrix
|
||||
from scipy.sparse.csgraph import connected_components
|
||||
|
||||
|
||||
def _to_metis_edge_weight(edge_weight):
|
||||
weight = float(edge_weight)
|
||||
if not math.isfinite(weight):
|
||||
raise ValueError(f"Invalid non-finite METIS edge weight: {edge_weight}")
|
||||
# pymetis expects integer edge weights.
|
||||
return max(1, int(round(weight)))
|
||||
|
||||
|
||||
def pick_center_pipe(node_x, node_y, candidate_pipe, pipe_start_node, pipe_end_node):
|
||||
data_set_t = pd.DataFrame(dtype=object)
|
||||
data_set_t["x"] = (
|
||||
@@ -98,10 +106,10 @@ def metis_grouping_pipe_weight(
|
||||
elif edge_data.get("weight") is not None:
|
||||
edge_weight = float(edge_data["weight"])
|
||||
else:
|
||||
raise KeyError(
|
||||
f"Missing edge weight for partition edge '{edge_key}' in burst locator."
|
||||
)
|
||||
w_temp.append(edge_weight)
|
||||
# Ignore graph edges that are outside candidate pipes and have no usable
|
||||
# partition weight (e.g. some non-pipe links in mixed network graphs).
|
||||
continue
|
||||
w_temp.append(_to_metis_edge_weight(edge_weight))
|
||||
n_t.append(node_dict[neighbor_name])
|
||||
w.append(w_temp)
|
||||
correspond_dic[n_t[0]] = count_node
|
||||
|
||||
Reference in New Issue
Block a user