Repository: projectmesa/mesa
Pull request #423 (2017-11-09 13:30:16)

Batchrunfixedparameters
Added ability to include fixed parameters in get_model_vars_dataframe() function. See #422 


Patch:
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index eec69b75..28b83d5e 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -11,7 +11,7 @@ In no particular order, examples include:
 - Documentation improvements
 - Tutorials
 
-No contribution is too small. Although, contributions can be too big, so let's discuss via the `email list`_ OR `an issue`_.
+No contribution is too small. Although, contributions can be too big, so let's discuss via the `dev email list`_ OR `an issue`_.
 
 **To submit a contribution**
 
@@ -24,7 +24,7 @@ No contribution is too small. Although, contributions can be too big, so let's d
 - Submit as a pull request.
 - Describe the change w/ ticket number(s) that the code fixes.
 
-.. _`email list` : https://groups.google.com/forum/#!forum/projectmesa
+.. _`dev email list` : https://groups.google.com/forum/#!forum/projectmesa-dev
 .. _`an issue` : https://github.com/projectmesa/mesa/issues
 .. _`Travis build` : https://travis-ci.org/projectmesa/mesa
 
diff --git a/README.rst b/README.rst
index 3a0773d6..6fb6916e 100644
--- a/README.rst
+++ b/README.rst
@@ -52,12 +52,12 @@ For more help on using Mesa, check out the following resources:
 
 * `Intro to Mesa Tutorial`_
 * `Docs`_
-* `Email list`_
+* `Email list for users`_
 * `PyPI`_
 
 .. _`Intro to Mesa Tutorial` : http://mesa.readthedocs.org/en/latest/tutorials/intro_tutorial.html
 .. _`Docs` : http://mesa.readthedocs.org/en/latest/
-.. _`Email list` : https://groups.google.com/d/forum/projectmesa
+.. _`Email list for users` : https://groups.google.com/d/forum/projectmesa
 .. _`PyPI` : https://pypi.python.org/pypi/Mesa/
 
 Contributing back to Mesa
@@ -65,12 +65,12 @@ Contributing back to Mesa
 
 If you run into an issue, please file a `ticket`_ for us to discuss. If possible, follow up with a pull request.
 
-If you would like to add a feature, please reach out via `ticket`_ or the `email list`_ for discussion. A feature is most likely to be added if you build it!
+If you would like to add a feature, please reach out via `ticket`_ or the `dev email list`_ for discussion. A feature is most likely to be added if you build it!
 
 * `Contributors guide`_
 * `Github`_
 
 .. _`ticket` : https://github.com/projectmesa/mesa/issues
-.. _`email list` : https://groups.google.com/d/forum/projectmesa
+.. _`dev email list` : https://groups.google.com/forum/#!forum/projectmesa-dev
 .. _`Contributors guide` : https://github.com/projectmesa/mesa/blob/master/CONTRIBUTING.rst
 .. _`Github` : https://github.com/projectmesa/mesa/
diff --git a/mesa/batchrunner.py b/mesa/batchrunner.py
index e5f23652..c10a4570 100644
--- a/mesa/batchrunner.py
+++ b/mesa/batchrunner.py
@@ -82,6 +82,7 @@ class BatchRunner:
         self.model_cls = model_cls
         self.variable_parameters = self._process_parameters(variable_parameters)
         self.fixed_parameters = fixed_parameters or {}
+        self._include_fixed = len(self.fixed_parameters.keys()) > 0
         self.iterations = iterations
         self.max_steps = max_steps
 
@@ -193,4 +194,7 @@ class BatchRunner:
         rest_cols = set(df.columns) - set(index_cols)
         ordered = df[index_cols + list(sorted(rest_cols))]
         ordered.sort_values(by='Run', inplace=True)
+        if self._include_fixed:
+            for param in self.fixed_parameters.keys():
+                ordered[param] = self.fixed_parameters[param]
         return ordered


Test patch:
diff --git a/tests/test_batchrunner.py b/tests/test_batchrunner.py
index e9b9904b..d815f30b 100644
--- a/tests/test_batchrunner.py
+++ b/tests/test_batchrunner.py
@@ -155,6 +155,7 @@ class TestBatchRunner(unittest.TestCase):
         batch = self.launch_batch_processing()
         model_vars = batch.get_model_vars_dataframe()
         expected_cols = (len(self.variable_params) +
+                         len(self.fixed_params) +
                          len(self.model_reporters) +
                          1)
         self.assertEqual(model_vars.shape, (self.model_runs, expected_cols))