Showing 2 of 3 files from the diff.

@@ -116,7 +116,6 @@
Loading
116 116
117 117
        self.display_progress = display_progress
118 118
119 -
    @property
120 119
    def _make_model_args(self):
121 120
        """Prepare all combinations of parameter values for `run_all`
122 121
@@ -128,8 +127,8 @@
Loading
128 127
        all_kwargs = []
129 128
        all_param_values = []
130 129
131 -
        _count = len(self.parameters_list)
132 -
        if _count:
130 +
        count = len(self.parameters_list)
131 +
        if count:
133 132
            for params in self.parameters_list:
134 133
                kwargs = params.copy()
135 134
                kwargs.update(self.fixed_parameters)
@@ -137,12 +136,12 @@
Loading
137 136
                all_param_values.append(list(params.values()))
138 137
139 138
        elif len(self.fixed_parameters):
140 -
            _count = 1
139 +
            count = 1
141 140
            kwargs = self.fixed_parameters.copy()
142 141
            all_kwargs.append(kwargs)
143 142
            all_param_values.append(list(kwargs.values()))
144 143
145 -
        total_iterations *= _count
144 +
        total_iterations *= count
146 145
147 146
        return total_iterations, all_kwargs, all_param_values
148 147
@@ -178,7 +177,7 @@
Loading
178 177
    def run_all(self):
179 178
        """ Run the model at all parameter combinations and store results. """
180 179
        run_count = count()
181 -
        total_iterations, all_kwargs, all_param_values = self._make_model_args
180 +
        total_iterations, all_kwargs, all_param_values = self._make_model_args()
182 181
183 182
        with tqdm(total_iterations, disable=not self.display_progress) as pbar:
184 183
            for i, kwargs in enumerate(all_kwargs):
@@ -188,8 +187,7 @@
Loading
188 187
                    pbar.update()
189 188
190 189
    def run_iteration(self, kwargs, param_values, run_count):
191 -
        kwargs_copy = copy.deepcopy(kwargs)
192 -
        model = self.model_cls(**kwargs_copy)
190 +
        model = self.model_cls(**kwargs)
193 191
        results = self.run_model(model)
194 192
        if param_values is not None:
195 193
            model_key = tuple(param_values) + (run_count,)
@@ -215,7 +213,7 @@
Loading
215 213
                getattr(self, "datacollector_agent_reporters", None))
216 214
217 215
    @staticmethod
218 -
    def run_wrappermp(iter_args):
216 +
    def _run_wrappermp(iter_args):
219 217
        """
220 218
        Based on requirement of Python multiprocessing requires @staticmethod decorator;
221 219
        this is primarily to ensure functionality on Windows OS and doe not impact MAC or Linux distros
@@ -498,7 +496,7 @@
Loading
498 496
        super().__init__(model_cls, **kwargs)
499 497
        self.pool = Pool(self.processes)
500 498
501 -
    def result_prep_mp(self, results):
499 +
    def _result_prep_mp(self, results):
502 500
        """
503 501
        Helper Function
504 502
        :param results: Takes results dictionary from Processpool and single processor debug run and fixes format to
@@ -539,18 +537,18 @@
Loading
539 537
540 538
        if self.processes > 1:
541 539
            with tqdm(total_iterations, disable=not self.display_progress) as pbar:
542 -
                for params, model in self.pool.imap_unordered(self.run_wrappermp, run_iter_args):
540 +
                for params, model in self.pool.imap_unordered(self._run_wrappermp, run_iter_args):
543 541
                    results[params] = model
544 542
                    pbar.update()
545 543
546 -
                self.result_prep_mp(results)
544 +
                self._result_prep_mp(results)
547 545
        # For debugging model due to difficulty of getting errors during multiprocessing
548 546
        else:
549 547
            for run in run_iter_args:
550 -
                params, model_data = self.run_wrappermp(run)
548 +
                params, model_data = self._run_wrappermp(run)
551 549
                results[params] = model_data
552 550
553 -
            self.result_prep_mp(results)
551 +
            self._result_prep_mp(results)
554 552
555 553
        # Close multi-processing
556 554
        self.pool.close()

@@ -85,14 +85,14 @@
Loading
85 85
            If your model includes a large number of agents, you should *only*
86 86
            use attribute names for the agent reporter, it will be much faster.
87 87
88 -
            Model reporters can take three types of arguments:
88 +
            Model reporters can take four types of arguments:
89 89
            lambda like above:
90 90
            {"agent_count": lambda m: m.schedule.get_agent_count() }
91 91
            method with @property decorators
92 92
            {"agent_count": schedule.get_agent_count()
93 93
            class attributes of model
94 94
            {"model_attribute": "model_attribute"}
95 -
            functions with paramters that have placed in a list
95 +
            functions with parameters that have placed in a list
96 96
            {"Model_Function":[function, [param_1, param_2]]}
97 97
98 98
        """
@@ -186,14 +186,7 @@
Loading
186 186
                elif isinstance(reporter, list):
187 187
                    self.model_vars[var].append(reporter[0](*reporter[1]))
188 188
                else:
189 -
                    try:
190 -
                        self.model_vars[var].append(reporter)
191 -
                    except TypeError:
192 -
                        print("Reporters must be in dictionary in one of the following forms: /n\
193 -
                        - key_name: <class attribute> /n \
194 -
                        - key_name: function (e.g schedule.get_agent_count) /n \
195 -
                        - key_name: lambda function /n \
196 -
                        - key_name: [function, [<arguments for function>]")
189 +
                    self.model_vars[var].append(reporter)
197 190
198 191
        if self.agent_reporters:
199 192
            agent_records = self._record_agents(model)
Files Coverage
mesa 91.17%
Project Totals (20 files) 91.17%
1865.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
1864.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux
1864.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1864.1
TRAVIS_PYTHON_VERSION=3.6
TRAVIS_OS_NAME=linux
1865.3
TRAVIS_PYTHON_VERSION=3.8
TRAVIS_OS_NAME=linux
1865.2
TRAVIS_PYTHON_VERSION=3.7
TRAVIS_OS_NAME=linux

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading