我想编辑一个对象数组,这些对象通过import matplotlib.pyplot as plt
import seaborn as sns
import numpy as np
import pandas as pd
from scipy.cluster.hierarchy import dendrogram, linkage
%matplotlib inline
#Test Data
DF_sim = DF_c93tom.iloc[:10,:10] #Similarity Matrix
DF_sim.columns = DF_sim.index = range(10)
#print(DF_test)
# 0 1 2 3 4 5 6 7 8 9
# 0 1.000000 0 0.395833 0.083333 0 0 0 0 0 0
# 1 0.000000 1 0.000000 0.000000 0 0 0 0 0 0
# 2 0.395833 0 1.000000 0.883792 0 0 0 0 0 0
# 3 0.083333 0 0.883792 1.000000 0 0 0 0 0 0
# 4 0.000000 0 0.000000 0.000000 1 0 0 0 0 0
# 5 0.000000 0 0.000000 0.000000 0 1 0 0 0 0
# 6 0.000000 0 0.000000 0.000000 0 0 1 0 0 0
# 7 0.000000 0 0.000000 0.000000 0 0 0 1 0 0
# 8 0.000000 0 0.000000 0.000000 0 0 0 0 1 0
# 9 0.000000 0 0.000000 0.000000 0 0 0 0 0 1
#Dissimilarity Matrix
DF_dissm = 1 - DF_sim
#Redundant Matrix
#np.tril(DF_dissm).T == np.triu(DF_dissm)
#True for all values
#Hierarchical Clustering for square and triangle matrices
fig_1 = plt.figure(1)
plt.title("Square")
Z_square = linkage((DF_dissm.values),method="average")
dendrogram(Z_square)
fig_2 = plt.figure(2)
plt.title("Triangle Upper")
Z_triu = linkage(np.triu(DF_dissm.values),method="average")
dendrogram(Z_triu)
fig_3 = plt.figure(3)
plt.title("Triangle Lower")
Z_tril = linkage(np.tril(DF_dissm.values),method="average")
dendrogram(Z_tril)
plt.show()
绑定到视图。
在修改完整数组之前,如何避免更新范围?
这是一个简单的例子:
我想更新数组中的每个obj,然后只更新$ scope。由于数组包含对象,我不能简单地将它们复制到另一个变量中。
ng-repeat
答案 0 :(得分:0)
我想你唯一的可能就是编辑另一个数组,并在完成所有更新后立即将其设置为原始数组。