def test_backwards_compatibility(self): # Test only makes sense with python 2.7 or lower old_pypet_traj = Trajectory() module_path, init_file = os.path.split(pypet.__file__) filename= os.path.join(module_path, 'tests','testdata','pypet_v0_1b_6.hdf5') old_pypet_traj.f_load(index=-1, load_data=2, force=True, filename=filename) self.assertTrue(old_pypet_traj.v_version=='0.1b.6') self.assertTrue(old_pypet_traj.par.x==0) self.assertTrue(len(old_pypet_traj)==9) self.assertTrue(old_pypet_traj.res.runs.r_4.z==12) nexplored = len(old_pypet_traj._explored_parameters) self.assertGreater(nexplored, 0) for param in old_pypet_traj.f_get_explored_parameters(): self.assertTrue(old_pypet_traj.f_contains(param))
def test_not_getting_links(self): traj = Trajectory() traj.f_add_parameter_group('test.test3') traj.f_add_parameter_group('test2') traj.test.f_add_link('circle1', traj.test2) traj.test2.f_add_link('circle2', traj.test) self.assertTrue(traj.test.circle1 is traj.test2) traj.v_with_links = False with self.assertRaises(AttributeError): traj.test.circle1 found = False for item in traj.test.f_iter_nodes(recursive=True, with_links=True): if item is traj.test2: found = True self.assertTrue(found) for item in traj.test.f_iter_nodes(recursive=True, with_links=False): if item is traj.test2: self.assertTrue(False) traj.v_with_links = True self.assertTrue('circle1' in traj) self.assertFalse(traj.f_contains('circle1', with_links=False)) self.assertTrue('circle1' in traj.test) self.assertFalse(traj.test.f_contains('circle1', with_links=False)) self.assertTrue(traj.test2.test3 is traj.par.test.test3) traj.v_with_links = False with self.assertRaises(AttributeError): traj.test2.test3 traj.v_with_links = True self.assertTrue(traj['test2.test3'] is traj.test3) with self.assertRaises(AttributeError): traj.f_get('test2.test3', with_links=False)
def test_not_getting_links(self): traj = Trajectory() traj.f_add_parameter_group('test.test3') traj.f_add_parameter_group('test2') traj.test.f_add_link('circle1' , traj.test2) traj.test2.f_add_link('circle2' , traj.test) self.assertTrue(traj.test.circle1 is traj.test2) traj.v_with_links = False with self.assertRaises(AttributeError): traj.test.circle1 found = False for item in traj.test.f_iter_nodes(recursive=True, with_links=True): if item is traj.test2: found=True self.assertTrue(found) for item in traj.test.f_iter_nodes(recursive=True, with_links=False): if item is traj.test2: self.assertTrue(False) traj.v_with_links=True self.assertTrue('circle1' in traj) self.assertFalse(traj.f_contains('circle1', with_links=False)) self.assertTrue('circle1' in traj.test) self.assertFalse(traj.test.f_contains('circle1', with_links=False)) self.assertTrue(traj.test2.test3 is traj.par.test.test3) traj.v_with_links = False with self.assertRaises(AttributeError): traj.test2.test3 traj.v_with_links = True self.assertTrue(traj['test2.test3'] is traj.test3) with self.assertRaises(AttributeError): traj.f_get('test2.test3', with_links=False)
def test_backwards_compatibility(self): # Test only makes sense with python 2.7 or lower old_pypet_traj = Trajectory() module_path, init_file = os.path.split(pypet.__file__) filename = os.path.join(module_path, 'tests', 'testdata', 'pypet_v0_1b_6.hdf5') old_pypet_traj.f_load(index=-1, load_data=2, force=True, filename=filename) self.assertTrue(old_pypet_traj.v_version == '0.1b.6') self.assertTrue(old_pypet_traj.par.x == 0) self.assertTrue(len(old_pypet_traj) == 9) self.assertTrue(old_pypet_traj.res.runs.r_4.z == 12) nexplored = len(old_pypet_traj._explored_parameters) self.assertGreater(nexplored, 0) for param in old_pypet_traj.f_get_explored_parameters(): self.assertTrue(old_pypet_traj.f_contains(param))
if algorithm == 'bMI': network_analysis = BivariateMI() if algorithm == 'mMI_greedy': network_analysis = MultivariateMI() if algorithm == 'bTE_greedy': network_analysis = BivariateTE() if algorithm == 'mTE_greedy': network_analysis = MultivariateTE() #settings['add_conditionals'] = [(35, 3), (26, 1), (17, 5), (25, 4)] # Add optional settings optional_settings_keys = {'config.debug', 'config.max_mem_frac'} for key in optional_settings_keys: if traj.f_contains(key, shortcuts=True): key_last = key.rpartition('.')[-1] settings[key_last] = traj[key] print('Using optional setting \'{0}\'={1}\n'.format( key_last, traj[key])) print('settings = {0}\n'.format(settings)) # Run analysis res = network_analysis.analyse_single_target(settings=settings, data=dat, target=target_id) # Save results dictionary using pickle save_obj( res, traj_dir,