当前位置: 首页>>代码示例>>Python>>正文


Python SessionConfiguration.remove_all_datasets方法代码示例

本文整理汇总了Python中opus_core.session_configuration.SessionConfiguration.remove_all_datasets方法的典型用法代码示例。如果您正苦于以下问题:Python SessionConfiguration.remove_all_datasets方法的具体用法?Python SessionConfiguration.remove_all_datasets怎么用?Python SessionConfiguration.remove_all_datasets使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在opus_core.session_configuration.SessionConfiguration的用法示例。


在下文中一共展示了SessionConfiguration.remove_all_datasets方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: SimulationState

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import remove_all_datasets [as 别名]
    
    SimulationState().set_cache_directory(cache_directory)
#        SimulationState().set_current_time(year)
    
    SessionConfiguration(new_instance=True,
                         package_order=package_order,
                         in_storage=AttributeCache())
    
    for year in range(base_year+1, end_year+1, 1):
        SimulationState().set_current_time(year)
    
#        SessionConfiguration(new_instance=True,
#                             package_order=package_order,
#                             in_storage=AttributeCache())
    
        dataset_pool=SessionConfiguration().get_dataset_pool()
        dataset_pool.remove_all_datasets()
    #    dataset_pool = DatasetPool(
    #        package_order=['psrc','urbansim','opus_core'],
    #        storage=AttributeCache())
    
        proposal_set = dataset_pool.get_dataset("development_project_proposal")
        template_component = dataset_pool.get_dataset("development_template_component")
    
        from urbansim_parcel.datasets.development_project_proposal_component_dataset import create_from_proposals_and_template_components
        proposal_component = create_from_proposals_and_template_components(proposal_set, 
                                                                           template_component, 
                                                                           dataset_pool=dataset_pool)
    
        proposal_component.write_dataset(out_storage=AttributeCache().get_flt_storage_for_year(year),
                                         out_table_name="development_project_proposal_components")
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:33,代码来源:create_development_proposal_components.py

示例2: TestDoingRefinement

# 需要导入模块: from opus_core.session_configuration import SessionConfiguration [as 别名]
# 或者: from opus_core.session_configuration.SessionConfiguration import remove_all_datasets [as 别名]

#.........这里部分代码省略.........
        self.assert_(os.path.exists(backup_dir))
        
        expected_dataset_names = [ os.path.basename(p) for p in glob( os.path.join(self.cache_dir, '2020', '*')) ]
        dataset_names = [ os.path.basename(p) for p in glob(os.path.join(backup_dir, '*'))]
        self.assert_(set(dataset_names).issubset(set(expected_dataset_names)))
        self.assertEqual(set(dataset_names).symmetric_difference( set(expected_dataset_names) ), set([]) )

    def test_doing_refinements_from_specified_refinement_dataset(self):
        self.prepare_cache()
        os.system("%(python)s %(script)s -c %(cache_directory)s -s %(start_year)s -e %(end_year)s --refinements-directory=%(refinement_directory)s" % 
                  {'python': sys.executable, 'script': self.script, 'cache_directory': self.cache_dir,
                   'start_year': 2021, 'end_year': 2022,
                   'refinement_directory': os.path.join(self.cache_dir, '2000')}
                  )
        
        simulation_state = SimulationState()
        
        ## test refinement for 2021
        simulation_state.set_current_time(2021)
        jobs = self.dataset_pool.get_dataset('job')
        buildings = self.dataset_pool.get_dataset('building')
        jobs13_raz3 = jobs.compute_variables('numpy.logical_and(job.sector_id==13, job.disaggregate(parcel.raz_id==3, intermediates=[building]))', 
                                                  dataset_pool=self.dataset_pool)
        jobs13_raz4 = jobs.compute_variables('numpy.logical_and(job.sector_id==13, job.disaggregate(parcel.raz_id, intermediates=[building])==4)', 
                                                  dataset_pool=self.dataset_pool)
        jobs13_raz5 = jobs.compute_variables('numpy.logical_and(job.sector_id==13, job.disaggregate(parcel.raz_id, intermediates=[building])==5 )', 
                                                  dataset_pool=self.dataset_pool)
        jobs_raz5 = jobs.compute_variables('job.disaggregate(parcel.raz_id, intermediates=[building])==5', 
                                                dataset_pool=self.dataset_pool)
        
        #check results
        self.assertEqual(jobs13_raz3.sum(), 0)
        self.assertEqual(jobs13_raz4.sum(), 0)
        self.assertEqual(jobs13_raz5.sum() >= 5, True)
        self.assertEqual(jobs_raz5.sum(), 7)
        expected_nr_sqft = array([6, 0, 3, 6, 1, 6, 5, 0])
        ## was             array([6, 2, 3, 6, 1, 2, 5, 0]),
        self.assert_(allclose(buildings.get_attribute('non_residential_sqft'),  expected_nr_sqft))
        
        self.dataset_pool.remove_all_datasets()
        
        
        ## test refinement for 2022
        simulation_state.set_current_time(2022)
        hhs = self.dataset_pool.get_dataset('household')
        buildings = self.dataset_pool.get_dataset('building')
        
        hhs_raz6 = hhs.compute_variables('household.disaggregate(building.disaggregate(parcel.raz_id)==6)', 
                                              dataset_pool=self.dataset_pool)
        hhs_bldg = buildings.compute_variables('building.number_of_agents(household)', 
                                                    dataset_pool=self.dataset_pool)
        
        #check results
        self.assertEqual(hhs_raz6.sum(), 7)
        self.assert_(hhs_bldg.sum(),  7 )
        self.assert_((hhs_bldg!=0).sum(),  2)
        self.assert_(buildings.get_attribute('residential_units').sum(),  7)
        
        self.dataset_pool.remove_all_datasets()        
        
        
    def test_doing_other_refinements(self):
        self.prepare_cache()
        os.system("%(python)s  %(script)s -c %(cache_directory)s -s %(start_year)s -e %(end_year)s" % 
                  {'python': sys.executable, 'script': self.script, 'cache_directory':self.cache_dir,
                   'start_year': 2023, 'end_year': 2027 }
                  )        
        
        
        simulation_state = SimulationState()
                
        ## test refinement for 2023
        simulation_state.set_current_time(2023)
        hhs = self.dataset_pool.get_dataset('household')
        
        hhs_p5 = hhs.compute_variables('household.persons>5')
        
        #check results
        self.assert_(hhs.size(),  2)
        self.assertEqual(hhs_p5.sum(), 0)
        
        self.dataset_pool.remove_all_datasets()
        
        ## test refinement for 2027
        simulation_state.set_current_time(2027)
        hhs = self.dataset_pool.get_dataset('household')
        buildings = self.dataset_pool.get_dataset('building')
        persons = self.dataset_pool.get_dataset('person')
        
        
        hhs_raz6 = hhs.compute_variables('household.disaggregate(building.disaggregate(parcel.raz_id)==6)', 
                                              dataset_pool=self.dataset_pool)
        hhs_bldg = buildings.compute_variables('building.number_of_agents(household)', 
                                                    dataset_pool=self.dataset_pool)
        
        #check results
        self.assertEqual(hhs_raz6.sum(), 3)
        self.assert_(hhs_bldg.sum(),  3 )
        self.assert_((hhs_bldg!=0).sum(),  2)
        self.assert_(allclose(persons.get_attribute('job_id'), array([-1,  -1, -1, -1,  3,  4,  7])))
开发者ID:psrc,项目名称:urbansim,代码行数:104,代码来源:test_doing_refinement.py


注:本文中的opus_core.session_configuration.SessionConfiguration.remove_all_datasets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。