From c9c2daff4b151d64df93e0039ded390c2cbb9ca0 Mon Sep 17 00:00:00 2001 From: ConnectedSystems Date: Thu, 28 Nov 2019 20:31:08 +1100 Subject: [PATCH 1/2] initial commit of getting started guide --- docs/getting_started.rst | 2 ++ docs/index.rst | 19 +------------------ 2 files changed, 3 insertions(+), 18 deletions(-) create mode 100644 docs/getting_started.rst diff --git a/docs/getting_started.rst b/docs/getting_started.rst new file mode 100644 index 0000000..f2afae6 --- /dev/null +++ b/docs/getting_started.rst @@ -0,0 +1,2 @@ +A quick start guide +------------------- \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index ffe93b2..d04b7c0 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -4,24 +4,6 @@ agtor This is the documentation of **agtor**. -.. note:: - - This is the main page of your project's `Sphinx`_ documentation. - It is formatted in `reStructuredText`_. Add additional pages - by creating rst-files in ``docs`` and adding them to the `toctree`_ below. - Use then `references`_ in order to link them from this page, e.g. - :ref:`authors` and :ref:`changes`. - - It is also possible to refer to the documentation of other Python packages - with the `Python domain syntax`_. By default you can reference the - documentation of `Sphinx`_, `Python`_, `NumPy`_, `SciPy`_, `matplotlib`_, - `Pandas`_, `Scikit-Learn`_. You can add more by extending the - ``intersphinx_mapping`` in your Sphinx's ``conf.py``. - - The pretty useful extension `autodoc`_ is activated by default and lets - you include documentation from docstrings. Docstrings can be written in - `Google style`_ (recommended!), `NumPy style`_ and `classical style`_. - Contents ======== @@ -32,6 +14,7 @@ Contents License Authors Changelog + Getting Started Module Reference From d8db06df7fdc0d94bbac014471e20a7d22aed441 Mon Sep 17 00:00:00 2001 From: ConnectedSystems Date: Thu, 28 Nov 2019 23:33:42 +1100 Subject: [PATCH 2/2] Move to a more usable scenario result logging approach --- src/agtor/Zone.py | 7 ++++--- tests/test_run.py | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/agtor/Zone.py b/src/agtor/Zone.py index 83127e5..6658d31 100644 --- a/src/agtor/Zone.py +++ b/src/agtor/Zone.py @@ -275,9 +275,10 @@ def run_timestep(self, farmer: Manager, dt: object): # print("------------------\n") results[f.name] = { - 'datetime': dt, - 'income': income, - 'irrigated_area': f.irrigated_area + dt: { + 'income': income, + 'irrigated_area': f.irrigated_area + } } f.set_next_crop() diff --git a/tests/test_run.py b/tests/test_run.py index 05aaeea..8c7e721 100644 --- a/tests/test_run.py +++ b/tests/test_run.py @@ -68,7 +68,7 @@ def test_short_run(): time_sequence = z1.climate.time_steps start = timer() - result_set = [] + result_set = {f.name: {} for f in z1.fields} for dt_i in time_sequence[0:(365*5)]: if (dt_i.month == 5) and (dt_i.day == 15): # reset allocation for test @@ -79,11 +79,20 @@ def test_short_run(): res = z1.run_timestep(farmer, dt_i) if res is not None: - result_set += [res] + for f in z1.fields: + result_set[f.name].update(res[f.name]) + # End for + # End if # End for end = timer() - print(result_set) + scenario_result = {} + for f in z1.fields: + scenario_result[f.name] = pd.DataFrame.from_dict(result_set[f.name], + orient='index') + # End for + + print(scenario_result) print("Finished in:", timedelta(seconds=end-start)) # End test_short_run()