Changeset 3345
- Timestamp:
- 05/14/08 14:47:26 (2 months ago)
- Files:
-
- 1 modified
-
trunk/opus_core/allocation_model.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/opus_core/allocation_model.py
r3298 r3345 15 15 16 16 from opus_core.model import Model 17 from opus_core.datasets.dataset import Dataset Subset17 from opus_core.datasets.dataset import Dataset, DatasetSubset 18 18 from opus_core.logger import logger 19 19 from numpy import where, ones, zeros, logical_and, clip, round_ … … 31 31 given by the attribute 'control_total_attribute' of the 'control_totals' Dataset. If it is not given, it is assumed 32 32 to have the same name as 'outcome_attribute'. The 'weight_attribute' of 'dataset' determines the allocation weights. 33 The 'control_totals' Dataset contains an attribute 'year' (or alternatively, an attribute given by the 'year_attribute' argument)33 The 'control_totals' Dataset contains an attribute 'year' (or alternatively, an attribute given by the 'year_attribute' argument) 34 34 and optionally other attributes that must be known to the 'dataset' (such as a geography). For each row of the control_totals dataset 35 35 for which year matches the 'current_year', the total amount is distributed among the corresponding members of 'dataset' according to weights. … … 56 56 attrs_to_compute.append(capacity_attribute) 57 57 for attr in attrs_to_compute: 58 dataset.compute_one_variable_with_unknown_package(attr, dataset_pool=dataset_pool) 58 try: 59 dataset.compute_variables(attr, dataset_pool=dataset_pool) 60 except: 61 dataset.compute_one_variable_with_unknown_package(attr, dataset_pool=dataset_pool) 59 62 60 63 # create subset of control totals for the current year … … 103 106 logger.log_status('New values stored into attribute %s of dataset %s.' % (outcome_attribute, dataset.get_dataset_name())) 104 107 return outcome 108 109 def prepare_for_run(self, storage, table_name, id_name, dataset_name='control_totals'): 110 control_totals = Dataset(in_storage=storage, in_table_name=table_name, id_name=id_name, dataset_name=dataset_name) 111 return control_totals 105 112 106 113 from opus_core.tests import opus_unittest
