def test_dtype(): X = rs.randn(100, 2) X32 = X.astype(np.float32) X64 = X.astype(np.float64) m1 = APM(n_macrostates=3, metric='euclidean', lag_time=1).fit([X32]) m2 = APM(n_macrostates=3, metric='euclidean', lag_time=1).fit([X64]) eq(m1.labels_[0], m2.labels_[0]) eq(m1.MacroAssignments_[0], m2.MacroAssignments_[0]) eq(m1.fit_predict([X32])[0], m2.fit_predict([X64])[0]) eq(m1.fit_predict([X32])[0], m1.MacroAssignments_[0])
def test_rmsd(): # test for predict using euclidean distance m1 = APM(n_macrostates=4, metric='rmsd', lag_time=1) m2 = APM(n_macrostates=4, metric='rmsd', lag_time=1) labels1 = m1.fit_predict([trj]) labels2 = m2.fit([trj]).MacroAssignments_ eq(labels1[0], labels2[0])
def test_euclidean_10000(): # test for predict using euclidean distance m1 = APM(n_macrostates=2, metric='euclidean', lag_time=10) m2 = APM(n_macrostates=2, metric='euclidean', lag_time=10) data = rs.randn(10000, 2) labels1 = m1.fit_predict([data]) labels2 = m2.fit([data]).MacroAssignments_ eq(labels1[0], labels2[0])
def test_euclidean_10000(): # test for predict using euclidean distance m1 = APM(n_macrostates=2, metric='euclidean', lag_time=10) m2 = APM(n_macrostates=2, metric='euclidean', lag_time=10) data = np.random.randn(10000, 2) labels1 = m1.fit_predict([data]) labels2 = m2.fit([data]).MacroAssignments_ eq(labels1[0], labels2[0])
def test_rmsd(): # test for predict using rmsd m1 = APM(n_macrostates=4, metric='rmsd', lag_time=1, random_state=rs) m2 = APM(n_macrostates=4, metric='rmsd', lag_time=1, random_state=rs) labels1 = m1.fit_predict([trj]) labels2 = m2.fit([trj]).MacroAssignments_ eq(labels1[0], labels2[0])
def test_dtype(): X = np.random.RandomState(1).randn(100, 2) X32 = X.astype(np.float32) X64 = X.astype(np.float64) m1 = APM(n_macrostates=3, metric='euclidean', lag_time=1).fit([X32]) m2 = APM(n_macrostates=3, metric='euclidean', lag_time=1).fit([X64]) eq(m1.labels_[0], m2.labels_[0]) eq(m1.MacroAssignments_[0], m2.MacroAssignments_[0]) eq(m1.fit_predict([X32])[0], m2.fit_predict([X64])[0]) eq(m1.fit_predict([X32])[0], m1.MacroAssignments_[0]) #Testing #if __name__ == "__main__": # test_shapes() # test_euclidean() # test_euclidean_10000() # test_rmsd()
def test_euclidean(): # test for predict using euclidean distance data = rs.randn(100, 2) m1 = APM(n_macrostates=2, metric='euclidean', lag_time=1, random_state=rs) m2 = APM(n_macrostates=2, metric='euclidean', lag_time=1, random_state=rs) labels1 = m1.fit_predict([data]) labels2 = m2.fit([data]).MacroAssignments_ eq(labels1[0], labels2[0])