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


Python misc.DebugPrinter类代码示例

本文整理汇总了Python中opus_core.misc.DebugPrinter的典型用法代码示例。如果您正苦于以下问题:Python DebugPrinter类的具体用法?Python DebugPrinter怎么用?Python DebugPrinter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: __init__

    def __init__(self, resources=None, in_storage=None, out_storage=None,
                  in_table_name=None, attributes=None,
                  out_table_name=None, id_name=None,
                  nchunks=None, other_in_table_names=None,
                  debuglevel=0):
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating DevelopmentGroupDataset object.",2)
        resources = ResourceCreatorDevelopmentGroups().get_resources_for_dataset(
            resources = resources,
            in_storage = in_storage,
            out_storage = out_storage,
            in_table_name = in_table_name,
            out_table_name = out_table_name,
            attributes = attributes,
            id_name = id_name,
            id_name_default = self.id_name_default,
            nchunks = nchunks,
            debug = debug
            )

        Dataset.__init__(self,resources = resources)

        if isinstance(other_in_table_names,list):
            for place_name in other_in_table_names: #load other tables
                ds = Dataset(resources = resources)
                ds.load_dataset(in_table_name=place_name)
                self.connect_datasets(ds)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:27,代码来源:development_group_dataset.py

示例2: __init__

 def __init__(self):
     self.dependencies_list = None
     self.dataset = None
     self.number_of_compute_runs = 0
     try:
         self.debug = SessionConfiguration().get('debuglevel', 0)
     except:
         self.debug = 0
     if isinstance(self.debug, int):
         self.debug = DebugPrinter(self.debug)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:10,代码来源:variable.py

示例3: __init__

 def __init__(self, resources=None, dataset1=None, dataset2=None, index1 = None, index2 = None, 
             debuglevel=0):
     debug = DebugPrinter(debuglevel)
     debug.print_debug("Creating object %s.%s" % (self.__class__.__module__, self.__class__.__name__), 2)
     
     local_resources = Resources(resources)
     local_resources.merge_if_not_None({"dataset1":dataset1, 
         "dataset2":dataset2, "debug":debug, 
         "index1":index1, "index2":index2})
     CoreInteractionDataset.__init__(self, resources = local_resources)
     
     
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:10,代码来源:interactions.py

示例4: __init__

    def __init__(
        self,
        categories=array([1]),
        resources=None,
        what=None,
        attribute_name=None,
        data=None,
        names=None,
        in_storage=None,
        out_storage=None,
        in_table_name=None,
        attributes=None,
        out_table_name=None,
        id_name=None,
        nchunks=None,
        debuglevel=0,
    ):
        """
        'what' must be a string, such as 'residential' or 'commercial'.
        """
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating DevelopmentProjectDataset object for %s projects." % what, 2)

        self.categories = categories
        self.what = what
        self.attribute_name = attribute_name
        attributes_default = AttributeType.PRIMARY
        dataset_name = "development_project"
        nchunks_default = 1

        if data <> None:
            in_storage = StorageFactory().get_storage("dict_storage")

            in_storage.write_table(table_name="development_projects", table_data=data)
            in_table_name = "development_projects"

        resources = ResourceFactory().get_resources_for_dataset(
            dataset_name,
            resources=resources,
            in_storage=in_storage,
            out_storage=out_storage,
            in_table_name_pair=(in_table_name, None),
            out_table_name_pair=(out_table_name, None),
            attributes_pair=(attributes, attributes_default),
            id_name_pair=(id_name, self.id_name_default),
            nchunks_pair=(nchunks, nchunks_default),
            debug_pair=(debug, None),
        )

        self.category_variable_name = resources.get("category_variable_name", self.category_variable_name_default)
        Dataset.__init__(self, resources=resources)
开发者ID:psrc,项目名称:urbansim,代码行数:51,代码来源:development_project_dataset.py

示例5: run

    def run(self, projects, types, units, year=0, location_id_name="grid_id", debuglevel=0):
        debug = DebugPrinter(debuglevel)
        grid_ids_for_any_project = array([], dtype=int32)
        grid_ids_by_project_type = {}
        for project_type in types:
            grid_ids_by_project_type[project_type] = array([], dtype=int32)
            if projects[project_type] <> None:
                grid_ids_by_project_type[project_type] = projects[project_type].get_attribute(location_id_name)
            grid_ids_for_any_project = unique(concatenate((grid_ids_for_any_project, 
                                                                  grid_ids_by_project_type[project_type])))
        grid_ids_for_any_project = grid_ids_for_any_project[where(grid_ids_for_any_project>0)]
        if not len(grid_ids_for_any_project): return
        
        result_data = {location_id_name: grid_ids_for_any_project, 
                       "scheduled_year":(year*ones((grid_ids_for_any_project.size,))).astype(int32)}
        for unit in units:
            result_data[unit] = zeros((grid_ids_for_any_project.size,), dtype=int32)
        for project_type in types:
            result_data["%s_improvement_value" % project_type] = zeros((grid_ids_for_any_project.size,), dtype=int32)
            
        grid_idx=0
        for grid_id in grid_ids_for_any_project:
            for i in range(0,len(types)):
                project_type = types[i]
                my_projects = projects[project_type]
                w = where(my_projects.get_attribute(location_id_name) == grid_id)[0]
                if w.size>0:
                    unit_variable = units[i]
                    result_data[unit_variable][grid_idx] = \
                        my_projects.get_attribute_by_index( 
                            my_projects.get_attribute_name(), w).sum()
                    result_data["%s_improvement_value" % project_type][grid_idx] = \
                        my_projects.get_attribute_by_index( 
                            "improvement_value", w).sum()
            grid_idx += 1  
        
        storage = StorageFactory().get_storage('dict_storage')

        eventset_table_name = 'development_events_generated'        
        storage.write_table(table_name=eventset_table_name, table_data=result_data)

        eventset = DevelopmentEventDataset(
            in_storage = storage, 
            in_table_name = eventset_table_name, 
            id_name = [location_id_name, "scheduled_year"],
            ) 
                                      
        debug.print_debug("Number of events: " + str(grid_ids_for_any_project.size), 3)
        return eventset
开发者ID:psrc,项目名称:urbansim,代码行数:49,代码来源:development_event_transition_model.py

示例6: __init__

    def __init__(self, regression_procedure="opus_core.linear_regression",
                  submodel_string=None,
                  run_config=None, estimate_config=None, debuglevel=0, dataset_pool=None):
 
        self.debug = DebugPrinter(debuglevel)

        self.dataset_pool = self.create_dataset_pool(dataset_pool)

        self.regression = RegressionModelFactory().get_model(name=regression_procedure)
        if self.regression == None:
            raise StandardError, "No regression procedure given."

        self.submodel_string = submodel_string

        self.run_config = run_config
        if self.run_config == None:
            self.run_config = Resources()
        if not isinstance(self.run_config,Resources) and isinstance(self.run_config, dict):
            self.run_config = Resources(self.run_config)

        self.estimate_config = estimate_config
        if self.estimate_config == None:
            self.estimate_config = Resources()
        if not isinstance(self.estimate_config,Resources) and isinstance(self.estimate_config, dict):
            self.estimate_config = Resources(self.estimate_config)
            
        self.data = {}
        self.coefficient_names = {}
        ChunkModel.__init__(self)
        self.get_status_for_gui().initialize_pieces(3, pieces_description = array(['initialization', 'computing variables', 'submodel: 1']))
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:30,代码来源:regression_model.py

示例7: __init__

 def __init__(self, location_id_name=None, variable_package=None, dataset_pool=None, debuglevel=0):
     self.debug = DebugPrinter(debuglevel)
     self.location_id_name = self.location_id_name_default
     self.variable_package = self.variable_package_default
     if location_id_name is not None:
         self.location_id_name = location_id_name
     if variable_package is not None:
         self.variable_package = variable_package
     self.dataset_pool = self.create_dataset_pool(dataset_pool, ["urbansim", "opus_core"])
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:9,代码来源:employment_transition_model.py

示例8: __init__

    def __init__(self, resources=None, what="household", in_storage=None,
                 in_table_name=None, out_storage=None, out_table_name=None, 
                 id_name=None, nchunks=None, debuglevel=0):
        ## TODO remove "what" arguement
        
        debug = DebugPrinter(debuglevel)
        debug.print_debug("Creating ControlTotalDataset object for "+what+".",2)
        
        if not self.in_table_name_default:
            self.in_table_name_default = "annual_" + what + "_control_totals"
        if not self.out_table_name_default:         
            self.out_table_name_default = "annual_" + what + "_control_totals"
            
        attributes_default = AttributeType.PRIMARY
        #dataset_name = "control_total"
        nchunks_default = 1

        resources = ResourceFactory().get_resources_for_dataset(
            self.dataset_name,
            resources=resources,
            in_storage=in_storage,
            out_storage=out_storage,
            in_table_name_pair=(in_table_name,self.in_table_name_default),
            attributes_pair=(None, attributes_default),
            out_table_name_pair=(out_table_name, self.out_table_name_default),
            id_name_pair=(id_name,self.id_name_default),
            nchunks_pair=(nchunks,nchunks_default),
            debug_pair=(debug,None)
            )
        
        table_name = resources["in_table_name"]
        if resources['id_name'] is None or len(resources['id_name'])== 0:
            #if both self.id_name_default and id_name argument in __init__ is unspecified, 
            #ControlTotalDataset would use all attributes not beginning with "total"
            #as id_name
            id_names = []
            column_names = resources["in_storage"].get_column_names(table_name)
            for column_name in column_names:
                if not re.search('^total', column_name):
                    id_names.append(column_name)
            resources.merge({"id_name":resources["id_name"] + id_names})

        Dataset.__init__(self, resources = resources)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:43,代码来源:control_total_dataset.py

示例9: __init__

 def __init__(self, utility_class=None, probability_class=None, choice_class=None, resources=None, debuglevel=0):
     """utility_class, probability_class, choice_class are objects of the corresponding classes.
         They must have a method 'run'.
     """
     self.utility_class = utility_class
     self.probability_class = probability_class
     self.choice_class = choice_class
     self.resources = resources
     if self.resources == None:
         self.resources = Resources()
     self.utilities = None
     self.probabilities = None
     self.choices = None
     self.debug = DebugPrinter(debuglevel)
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:14,代码来源:upc_sequence.py

示例10: __init__

 def __init__(self,
              probabilities = "opus_core.upc.rate_based_probabilities",
              choices = "opus_core.random_choices",
              model_name = None,
              debuglevel=0,
              resources=None
              ):
     if model_name is not None:
         self.model_name = model_name
     self.debug = DebugPrinter(debuglevel)
     self.upc_sequence = None
     if probabilities is not None:
         self.upc_sequence = UPCFactory().get_model(utilities=None,
                                                    probabilities=probabilities,
                                                    choices=choices,
                                                    debuglevel=debuglevel)
     self.resources = merge_resources_if_not_None(resources)
开发者ID:psrc,项目名称:urbansim,代码行数:17,代码来源:rate_based_model.py

示例11: __init__

 def __init__(self,
              probabilities = "urbansim.rate_based_probabilities",
              choices = "opus_core.random_choices",
              location_id_name="grid_id",
              model_name = "Agent Relocation Model",
              debuglevel=0,
              resources=None
              ):
     self.model_name = model_name
     self.location_id_name = location_id_name
     self.debug = DebugPrinter(debuglevel)
     self.upc_sequence = None
     if probabilities is not None:
         self.upc_sequence = UPCFactory().get_model(utilities=None,
                                                    probabilities=probabilities,
                                                    choices=choices,
                                                    debuglevel=debuglevel)
     self.resources = merge_resources_if_not_None(resources)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:18,代码来源:agent_relocation_model.py

示例12: __init__

 def __init__(self, group_member=None, 
              agents_grouping_attribute = 'job.building_type', 
              filter = None, 
              model_name=None,
              model_short_name=None,
              variable_package=None,
              dataset_pool=None,
              debuglevel=0):
     self.group_member = group_member
     if self.group_member:
         self.group_member.set_agents_grouping_attribute(agents_grouping_attribute)
     self.filter = filter
     self.dataset_pool = self.create_dataset_pool(dataset_pool, ["urbansim", "opus_core"])
     self.debug = DebugPrinter(debuglevel)
     
     if model_name is not None:
         self.model_name = model_name
     if model_short_name is not None:
         self.model_short_name = model_short_name
     if variable_package is not None:
         self.variable_package = variable_package
开发者ID:psrc,项目名称:urbansim,代码行数:21,代码来源:scaling_jobs_model.py

示例13: BusinessTransitionModel

class BusinessTransitionModel(Model):
    """Creates and removes businesses from business_set."""
    
    model_name = "Business Transition Model"
    location_id_name = "building_id"
    variable_package = "sanfrancisco"
    
    def __init__(self, debuglevel=0):
        self.debug = DebugPrinter(debuglevel)
        
    def run(self, year, business_set, 
            control_totals, 
            dataset_pool=None, 
            resources=None):
        self.business_id_name = business_set.get_id_name()[0]
        control_for_businesses = False # If this is False, it is controlled for jobs
        if "total_number_of_businesses" in control_totals.get_known_attribute_names():
            control_for_businesses = True
            control_totals.get_attribute("total_number_of_businesses")
        else:
            control_totals.get_attribute("total_number_of_jobs")
        idx = where(control_totals.get_attribute("year")==year)
        sectors = unique(control_totals.get_attribute_by_index("sector_id", idx))
        self.max_id = business_set.get_id_attribute().max()
        business_size = business_set.size()
        self.new_businesses = {self.location_id_name:array([], dtype='int32'), 
                          "sector_id":array([], dtype='int32'),
                          self.business_id_name:array([], dtype='int32'), 
                          "sqft":array([], dtype=int32),
                          "employment":array([], dtype='int32'),
                          "activity_id":array([], dtype='int32')}

        business_set.compute_variables(
            map(lambda x: "%s.%s.is_of_sector_%s" 
                    % (self.variable_package, business_set.get_dataset_name(), x), sectors), 
                dataset_pool=dataset_pool, resources = resources)
        self.remove_businesses = array([], dtype='int32')
            
        for sector in sectors:
            b_is_in_sector = business_set.get_attribute("is_of_sector_%s" % sector)
            if control_for_businesses:
                total_businesses = control_totals.get_data_element_by_id((year,sector)).total_number_of_businesses
                diff = int(total_businesses - b_is_in_sector.astype(int8).sum())
                self._do_sector_for_businesses(sector, diff, business_set, b_is_in_sector)
            else:
                total_jobs = control_totals.get_data_element_by_id((year,sector)).total_number_of_jobs
                diff = int(total_jobs - business_set.get_attribute_by_index("employment", b_is_in_sector).sum())
                self._do_sector_for_jobs(sector, diff, business_set, b_is_in_sector)
             
        business_set.remove_elements(self.remove_businesses)
        business_set.add_elements(self.new_businesses, require_all_attributes=False)
        difference = business_set.size()-business_size
        self.debug.print_debug("Difference in number of businesses: %s (original %s,"
            " new %s, created %s, deleted %s)" 
                % (difference, 
                   business_size, 
                   business_set.size(), 
                   self.new_businesses[self.business_id_name].size, 
                   self.remove_businesses.size), 
            3)
        self.debug.print_debug("Number of unplaced businesses: %s" 
            % where(business_set.get_attribute(self.location_id_name) <=0)[0].size, 
            3)
        return difference
    
    def _do_sector_for_businesses(self, sector, diff, business_set, is_in_sector):
        available_business_index = where(is_in_sector)[0]
        if diff < 0: #
            sample_array, non_placed, size_non_placed = \
                get_array_without_non_placed_agents(business_set, available_business_index, -1*diff, 
                                                     self.location_id_name)
            self.remove_businesses = concatenate((self.remove_businesses, non_placed, 
                                       sample_noreplace(sample_array, max(0,abs(diff)-size_non_placed))))
                            
        if diff > 0: #
            self.new_businesses[self.location_id_name]=concatenate((self.new_businesses[self.location_id_name],zeros((diff,))))
            self.new_businesses["sector_id"]=concatenate((self.new_businesses["sector_id"], sector*ones((diff,))))
            sampled_business = probsample_replace(available_business_index, diff, None)
            self.new_businesses["sqft"] = concatenate((self.new_businesses["sqft"],
                                                 business_set.get_attribute("sqft")[sampled_business]))
            self.new_businesses["employment"] = concatenate((self.new_businesses["employment"],
                                                       business_set.get_attribute("employment")[sampled_business]))
            self.new_businesses["activity_id"] = concatenate((self.new_businesses["activity_id"],
                                                       business_set.get_attribute("activity_id")[sampled_business]))
            
            new_max_id = self.max_id+diff
            self.new_businesses[self.business_id_name]=concatenate((self.new_businesses[self.business_id_name], 
                                                                    arange(self.max_id+1, new_max_id+1)))
            self.max_id = new_max_id
                
    def _do_sector_for_jobs(self, sector, diff, business_set, b_is_in_sector):
        # diff is a difference in jobs (not businesses)
        employment = business_set.get_attribute('employment')
        available_business_index = where(b_is_in_sector)[0]
        if diff < 0: #
            placed, non_placed, size_non_placed = \
                get_array_without_non_placed_agents(business_set, available_business_index, -1*available_business_index.size, 
                                                     self.location_id_name)
            consider_for_removing = concatenate((permutation(non_placed), permutation(placed)))
            empl_cumsum = cumsum(employment[consider_for_removing])
#.........这里部分代码省略.........
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:101,代码来源:business_transition_model.py

示例14: upc_sequence

class upc_sequence(object):
    """
        Invokes computation of utilities, probabilities and choices.
    """

    def __init__(self, utility_class=None, probability_class=None, choice_class=None, resources=None, debuglevel=0):
        """utility_class, probability_class, choice_class are objects of the corresponding classes.
            They must have a method 'run'.
        """
        self.utility_class = utility_class
        self.probability_class = probability_class
        self.choice_class = choice_class
        self.resources = resources
        if self.resources == None:
            self.resources = Resources()
        self.utilities = None
        self.probabilities = None
        self.choices = None
        self.debug = DebugPrinter(debuglevel)

    def run(self, data=None, coefficients=None, resources=None):
        local_resources = Resources()
        if resources:
            local_resources.merge(resources)
        last_result = self.compute_utilities(data=data, coefficients=coefficients, resources=local_resources)
        this_result = self.compute_probabilities(resources=local_resources)
        if this_result <> None:
            last_result = this_result
        this_result = self.compute_choices(resources=local_resources)
        if this_result <> None:
            last_result = this_result
        return last_result

    def compute_utilities(self, data=None, coefficients=None, resources=None):
        if self.utility_class is None:
            self.debug.print_debug("No utilities class given.", 10)
            return None
        self.debug.print_debug("compute_utilities ...", 3)
        self.utilities = self.utility_class.run(data, coefficients, resources=resources)
        return self.utilities

    def compute_probabilities(self, resources=None):
        if self.probability_class is None:
            self.debug.print_debug("No probabilities class given.", 10)
            return None
        self.debug.print_debug("compute_probabilities ...", 3)
        self.probabilities = self.probability_class.run(self.utilities, resources=resources)
        return self.probabilities

    def compute_choices(self, resources=None):
        if self.choice_class is None:
            self.debug.print_debug("No choices class given.", 10)
            return None
        self.debug.print_debug("compute_choices ...", 3)
        self.choices = self.choice_class.run(self.probabilities, resources=resources)
        return self.choices

    def get_utilities(self):
        return self.utilities

    def get_probabilities(self):
        return self.probabilities

    def write_probability_sums(self):
        self.probability_class.check_sum(self.probabilities)

    def get_choices(self):
        return self.choices

    def get_choice_histogram(self, min=None, max=None, bins=None):
        """Give an array that represents a histogram of choices."""
        if max == None:
            max = self.choices.max() + 1
        if min == None:
            min = self.choices.min()
        if bins == None:
            bins = max - min
        return histogram(self.get_choices(), min, max, bins)

    def get_probabilities_sum(self):
        """Return probabilities sum along the first axis.
        """
        probs = self.get_probabilities()
        if probs.ndim < 2:
            return probs.sum()
        return reshape(sum(probs, 0), probs.shape[1])

    def plot_choice_histograms(self, capacity, main=""):
        self.plot_histogram(numrows=2)
        self.plot_histogram_with_capacity(capacity)

    def plot_histogram(self, main="", numrows=1, numcols=1, fignum=1):
        """Plot a histogram of choices and probability sums. Expects probabilities as (at least) a 2D array.
        """
        from matplotlib.pylab import bar, xticks, yticks, title, text, axis, figure, subplot

        probabilities = self.get_probabilities()
        if probabilities.ndim < 2:
            raise StandardError, "probabilities must have at least 2 dimensions."
        alts = probabilities.shape[1]
#.........这里部分代码省略.........
开发者ID:apdjustino,项目名称:DRCOG_Urbansim,代码行数:101,代码来源:upc_sequence.py

示例15: __init__

 def __init__(self, debuglevel=0):
     self.debug = DebugPrinter(debuglevel)
开发者ID:christianurich,项目名称:VIBe2UrbanSim,代码行数:2,代码来源:business_transition_model.py


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