def _write_data_to_year(self, data, cache_dir, year): """Writes this data to this year of the cache. Returns dataset. """ # Import in unit test, so that circular dependency is avoided. from opus_core.datasets.dataset import Dataset SimulationState().set_cache_directory(cache_dir) storage = dict_storage() storage.write_table(table_name=self._table_name, table_data=data) ds = Dataset(id_name=self._id_name, in_storage=storage, in_table_name=self._table_name) ds.load_dataset() self._write_dataset_to_cache(ds, cache_dir, year)
def setUp(self): self.storage = dict_storage() self.storage.write_table( table_name='development_type_groups', table_data={ "group_id":array([1,2,3,4]), "name":array(['residential', 'commercial', 'industrial', 'governmental']), } ) run_configuration = AbstractUrbansimConfiguration() self.model_configuration = run_configuration['models_configuration'] SessionConfiguration(new_instance=True, package_order=run_configuration['dataset_pool_configuration'].package_order, in_storage=self.storage)
def setUp(self): self.storage = dict_storage() self.storage.write_table( table_name="development_type_groups", table_data={ "group_id": array([1, 2, 3, 4]), "name": array(["residential", "commercial", "industrial", "governmental"]), }, ) run_configuration = AbstractUrbansimConfiguration() self.model_configuration = run_configuration["models_configuration"] SessionConfiguration( new_instance=True, package_order=run_configuration["dataset_pool_configuration"].package_order, in_storage=self.storage, )
def setUp(self): self.base_table_name = 'base_table' self.base_id = 'base_table_id' self.exogenous_attribute1 = 'some_attribute' self.exogenous_attribute2 = 'some_other_attribute' base_table = { self.base_id:array([2,1]), } self.weather_exogenous_table_name = 'weather_exogenous' weather_exogenous = { 'id':array([1,2,3,4,5,6]), 'year':array([1980,1981,1982,1980,1981,1982]), self.base_id:array([1,1,1,2,2,2]), self.exogenous_attribute1:array([40,50,600,70,80,900]), self.exogenous_attribute2:array([700,800,90,1000,1100,120]), } SimulationState().set_current_time(1980) self.expected_exogenous_attribute_1980_1 = array([70,40]) self.expected_exogenous_attribute_1980_2 = array([1000,700]) self.expected_exogenous_attribute_1981_1 = array([80,50]) self.expected_exogenous_attribute_1981_2 = array([1100,800]) self.expected_exogenous_attribute_1982_1 = array([900,600]) self.expected_exogenous_attribute_1982_2 = array([120,90]) self.exogenous_relationships_table_name = 'exogenous_relationships' exogenous_relationships = { 'exogenous_id':array([1]), 'base_table':array([self.base_table_name]), 'exogenous_table':array([self.weather_exogenous_table_name]), } self.storage = dict_storage() for table_name, table_values in [ (self.base_table_name, base_table), (self.weather_exogenous_table_name, weather_exogenous), (self.exogenous_relationships_table_name, exogenous_relationships) ]: self.storage.write_table(table_name=table_name, table_data=table_values)
def _write_data_to_year(self, data, cache_dir, year): """Writes this data to this year of the cache. Returns dataset. """ # Import in unit test, so that circular dependency is avoided. from opus_core.datasets.dataset import Dataset SimulationState().set_cache_directory(cache_dir) storage = dict_storage() storage.write_table( table_name=self._table_name, table_data=data, ) ds = Dataset(id_name=self._id_name, in_storage=storage, in_table_name=self._table_name) ds.load_dataset() self._write_dataset_to_cache(ds, cache_dir, year)
def setUp(self): self.storage = dict_storage() self.storage.write_table(table_name='development_type_groups', table_data={ "group_id": array([1, 2, 3, 4]), "name": array([ 'residential', 'commercial', 'industrial', 'governmental' ]), }) run_configuration = AbstractUrbansimConfiguration() self.model_configuration = run_configuration['models_configuration'] SessionConfiguration( new_instance=True, package_order=run_configuration['dataset_pool_configuration']. package_order, in_storage=self.storage)
def setUp(self): self.base_table_name = 'base_table' self.base_id = 'base_table_id' self.exogenous_attribute1 = 'some_attribute' self.exogenous_attribute2 = 'some_other_attribute' base_table = { self.base_id: array([2, 1]), } self.weather_exogenous_table_name = 'weather_exogenous' weather_exogenous = { 'id': array([1, 2, 3, 4, 5, 6]), 'year': array([1980, 1981, 1982, 1980, 1981, 1982]), self.base_id: array([1, 1, 1, 2, 2, 2]), self.exogenous_attribute1: array([40, 50, 600, 70, 80, 900]), self.exogenous_attribute2: array([700, 800, 90, 1000, 1100, 120]), } SimulationState().set_current_time(1980) self.expected_exogenous_attribute_1980_1 = array([70, 40]) self.expected_exogenous_attribute_1980_2 = array([1000, 700]) self.expected_exogenous_attribute_1981_1 = array([80, 50]) self.expected_exogenous_attribute_1981_2 = array([1100, 800]) self.expected_exogenous_attribute_1982_1 = array([900, 600]) self.expected_exogenous_attribute_1982_2 = array([120, 90]) self.exogenous_relationships_table_name = 'exogenous_relationships' exogenous_relationships = { 'exogenous_id': array([1]), 'base_table': array([self.base_table_name]), 'exogenous_table': array([self.weather_exogenous_table_name]), } self.storage = dict_storage() for table_name, table_values in [ (self.base_table_name, base_table), (self.weather_exogenous_table_name, weather_exogenous), (self.exogenous_relationships_table_name, exogenous_relationships) ]: self.storage.write_table(table_name=table_name, table_data=table_values)