def test_attribute_with_duplicate_values(self): # Load the default network sf = safe.SAFE(verbose=False) sf.load_network() f = '/Users/abaryshnikova/Lab/Datasets/safe-data/tests/attribute_file_with_unmatched_duplicated_labels.txt' sf.load_attributes(attribute_file=f)
def test_euclidean(self): # Load the default network sf = safe.SAFE(verbose=False) sf.load_network() sf.define_neighborhoods(node_distance_metric='euclidean') num_neighbors = np.sum(sf.neighborhoods, axis=1) num_neighbors_avg = np.mean(num_neighbors) num_neighbors_std = np.std(num_neighbors) self.assertAlmostEqual(num_neighbors_avg, 148.44, delta=0.5, msg="Should be 148.44.") self.assertAlmostEqual(num_neighbors_std, 40.99, delta=0.5, msg="Should be 40.99.")
def test_default(self): # Load the default network sf = safe.SAFE(verbose=False) sf.load_network() sf.define_neighborhoods() num_neighbors = np.sum(sf.neighborhoods, axis=1) num_neighbors_avg = np.mean(num_neighbors) num_neighbors_std = np.std(num_neighbors) self.assertAlmostEqual(num_neighbors_avg, 37.5, delta=0.5, msg="Should be 37.5.") self.assertAlmostEqual(num_neighbors_std, 56.74, delta=0.5, msg="Should be 56.74.")
def test_shortpath(self): # Load the default network sf = safe.SAFE(verbose=False) sf.load_network() sf.define_neighborhoods(node_distance_metric='shortpath', neighborhood_radius=1) num_neighbors = np.sum(sf.neighborhoods, axis=1) num_neighbors_avg = np.mean(num_neighbors) num_neighbors_std = np.std(num_neighbors) self.assertAlmostEqual(num_neighbors_avg, 15.20, delta=0.5, msg="Should be 15.20.") self.assertAlmostEqual(num_neighbors_std, 18.32, delta=0.5, msg="Should be 18.32.")
MZ = mp.Array(ctypes.c_double,FN*(chunk-v*window),lock=False) S = mp.Array(ctypes.c_float,FN*(chunk-window),lock=False) SZ1 = mp.Array(ctypes.c_float,FN*(chunk-v*window),lock=False) ST = mp.Array(ctypes.c_float,FN*(tiles),lock=False) STZ1 = mp.Array(ctypes.c_float,FN*(tiles-v),lock=False) STZ2 = mp.Array(ctypes.c_float,FN*(disjoint_tiles),lock=False) T = mp.Array(ctypes.c_float,FN*FN*(chunk-window-1),lock=False) TZ = mp.Array(ctypes.c_float, FN*FN*(chunk-v*window-1)) bins = range(0,max_depth,max_depth/FN)+[np.uint32(-1)] B = mp.Array(ctypes.c_float,bins,lock=False) s = safe.SAFE() #testing results here core.sliding_moments(I,0,chunk,window,window*10,M) core.sliding_spectrum_bin(I,0,chunk,window,B,S) core.sliding_transitions_bin(I,0,chunk,window,B,T) start = time.time() core.merge_sliding_moments_target(M,MZ,t=v*window) stop = time.time() start = time.time() x = 0 for i in range(tiles): core.spectrum_bin(I,x,x+window,B,ST,FN,FN*i) x += window stop = time.time()
def test_default(self): # Load the default network sf = safe.SAFE(verbose=False) sf.load_network() sf.load_attributes()