Skip to content

Commit

Permalink
v0.5.0 (#58)
Browse files Browse the repository at this point in the history
* Feature/dict for invs (#35)

Inventory restoration tau can now be given as a dict containing all sectors.

* Code improving (#36)

* Flood dottori (#37)

* fix problem in impact distrib

* fixed rebuilding sectors

* documentation update + small fixes

* Feature/no file records (#39)

* optional records

* no-file-record indicators update

* better names

* Reset records (#40)

* doc in master

* Feature/dict for invs (#35)

* better inv init

* better psi init

* better float management

* custom monetary_factor

* Added model/event monetary factor.

Note that default behavior is now to consider that the event impact is defined
with the same monetary factor as the model and not as unitary.

* added "step" axis name in dataframe

* stock crash better dumping

* try catch in next_step

* better logging

* differentiate k_stock to recover and rebuilding demand

* added separate household rebuilding demand (#45)

* small fix for array existence condition

* fix float comparison

* Feature/arbitrary shocks (#48)

* fix breaking error with multi events (?)

* Minor Upgrade

- :refactor: Switched back from "productive_capital_impact" to "impact" keyword
in events objects.
- :refactor: Put recovery functions in own file
- :refactor: Using CategoricalIndex for regions, sectors, ...
- :refactor: Switched events to fully keyword args
- :refactor: Switched None attributes to 0-length array/index/...
- :feat: ArbitraryProdEvent implemented !
- :fix: Fixed an error where model would take the minimum prod delta when
using both delta from capital destroyed and arbitrary decrease
- :style: Shorter pymrio MRIO printing in log
- :refactor: Cleanup of no longer used methods
- :feat: add_event*s* method !
- :test: initiating test directory

* ✅ Adding tests

* :build: poetry init

* ✅ working simulation test suite

* 📖 (manual sources) few updates + new chronology + ipynb

* 📖 (auto-source) update from code source

* ✅ init Event testing

* 🤖 📦 pyright conf update

* 🚑 print summary on empty list

* ✅ 🌟 additional checks on inputs + really abstract Event

* 📖 better literature chronology

* 📦 (poetry): ipykernel dependency

* ✅ (event) additionnal tests

* ✅ 🚧 (event) Better init tests + some simulation test

* ✅ 🚑 (event) Some test + trying to debug 'gdp' case

* 🚑 (Event) : Fix of CategoricalIndex with one region affected

* 🚑 (Event) trying to debug households impact

* 🚑 (Event) : Better regexp (not matching NPISH)

* downgraded numpy to <1.24 for climada

* 🚑 (Simulation) Case where n_temporal_units_to_sim is numpy int

* 🚧 (ArioPsiModel) : Changed default psi to 0.80

* 🚑 (Event) : trying to debug negative values with climada

* 🚑 (Event) Select != 0 values in impact Series
    - Also tries to squeeze dataframe to series early on.

* 🚑 (Event) : Fix a bug with the regexp for rebuilding demand cata

- Rebuilding demand category regexp matched two index in EORA26
- Added a warning for future cases

* 💄 (event) : Non hard threshold for demand values

* 🚑 (Event) : Fixed problem with index when "gdp" distrib.

* 🚑 (Model/Event) : Fix gva_df not set + better VA<0 warning

* 🚑 (model) : Small fixes/improvements

- Better warning for negatives in VA
- Better selection of the value_added for the Event cls init
- Fixed a problem raised by using older version of numpy when initializing matrix_stock_gap

* 🚑 (Events): Warning for too low damage events

* 🚧 (Simulation) : Better logging.

* 📖 (Simulation) : Doc update

* 🤖 (gitignore) : update

* 🚧 💄  📖 (Model) : Cleanup pre v0.5.0

* 🚑 fixes #57

* 🚑 (Event) Avoid uninformative by zero division error

* 💄 🚧 🚑 📖 pre 0.5.0 cleanup

- __init__ cleanup
- internal variables name improvement
- several type hint fixes
- (Event): documentation of new instantiating methods
- fix #53 (Not certain ?)
- some lsp #ignore
- better imports

* ✅ (Simulation) additionnal tests

* Pre-release

* 🤖 (Documentation build) vstudio esbonio compat ? + poetry dep

* 📖 Doc update for 0.5.0

* 📖 Doc update for v0.5.0 (2)
  • Loading branch information
spjuhel authored Jun 7, 2023
1 parent 9618477 commit 388ca88
Show file tree
Hide file tree
Showing 109 changed files with 17,040 additions and 24,350 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
typings/*
boario/archive.py
archive.py
*.el
*.lprof
*.prof
*.zip
Expand Down Expand Up @@ -162,3 +165,5 @@ workflow/config_full.json

DOC_BUILDING_REMINDER
new_docs
pyproject.toml.bak
.vscode/settings.json
99 changes: 99 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,102 @@ Contributing
################

.. _contributions:

Contributions are welcome, and they are greatly appreciated!
Every little bit helps, and credit will always be given.
If you are interested in contributing, please read all this section
before doing anything and in case of doubt, `contact the developer`_!

.. _contact the developer: [email protected]

----------------------
Types of Contributions
----------------------

You can contribute in many ways:

Report Bugs
===========

Before reporting a bug, **Ensure the bug was not already reported** by searching on GitHub under `Issues <https://github.com/spjuhel/BoARIO/issues>`_.

If you are reporting a bug, please use the "Bug report template" `here <https://github.com/spjuhel/BoARIO/issues/new/choose>`_, and include:

* Your operating system name and version.
* Any details about your local setup that might be helpful in troubleshooting.
* Detailed steps to reproduce the bug.


Fix Bugs
========

Look through the Github `issues <https://github.com/spjuhel/BoARIO/issues>`_ for bugs.
If you want to start working on a bug then please write short message on the issue tracker to prevent duplicate work.


Implement Features
==================

Look through the Github issues for features or add your own request
using the Code feature request template `here <https://github.com/spjuhel/BoARIO/issues/new/choose>`_
and assign yourself.

Write Documentation
===================

BoARIO could always use more documentation, whether as part of the official documentation website, in docstrings, in Jupyter Notebook examples,
or even on the web in blog posts, articles, and such.

BoARIO uses `Sphinx <https://sphinx-doc.org>`_ for the user manual (that you are currently reading).


Submit Feedback
===============

The best way to send feedback is to file an issue at `here <https://github.com/spjuhel/BoARIO/issues/new/choose>`_

If you are proposing a feature:

* Explain in detail how it would work.
* Keep the scope as narrow as possible, to make it easier to implement.
* Remember that this is a volunteer-driven project, and that contributions are welcome :)

-----------------------
Pull Request Guidelines
-----------------------

To update the documentation, fix bugs or add new features you need to create a Pull Request.
A PR is a change you make to your local copy of the code for us to review and potentially integrate into the code base.

To create a Pull Request you need to do these steps:

1. Create a Github account.
2. Fork the repository.
3. Clone your fork locally.
4. Go to the created BoARIO folder with :code:`cd boario`.
5. Create a new branch with :code:`git checkout -b <descriptive_branch_name>`.
6. Make your changes to the code or documentation.
7. Run :code:`git add .` to add all the changed files to the commit (to see what files will be added you can run :code:`git add . --dry-run`).
8. To commit the added files use :code:`git commit`. (This will open a command line editor to write a commit message. These should have a descriptive 80 line header, followed by an empty line, and then a description of what you did and why. To use your command line text editor of choice use (for example) :code:`export GIT_EDITOR=vim` before running :code:`git commit`).
9. Now you can push your changes to your Github copy of BoARIO by running :code:`git push origin <descriptive_branch_name>`.
10. If you now go to the webpage for your Github copy of BoARIO you should see a link in the sidebar called "Create Pull Request".
11. Now you need to choose your PR from the menu and click the "Create pull request" button. Be sure to change the pull request target branch to <descriptive_branch_name>!

If you want to create more pull requests, first run :code:`git checkout main` and then start at step 5. with a new branch name.

Feel free to ask questions about this if you want to contribute to BoARIO :)

------------------
Testing Guidelines
------------------

To ensure that you do not introduce bugs into BoARIO, you should test your code thouroughly.

From the base BoARIO folder you call :code:`pytest` to run all the tests, or choose one specific test:

.. code-block:: console
$ pytest
$ pytest tests/tests.py::test_log_input
If you introduce a new feature you should add a new test to the tests directory. See the folder for examples.
29 changes: 21 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ BoARIO

BoARIO : The Adaptative Regional Input Output model in python.

.. _`Documentation Website`: https://spjuhel.github.io/BoARIO/boario-what-is.html

Disclaimer
===========

This work is in progress. The code has not been extensively tested. Any results produced with the model should be interpreted with great care.
Do not hesitate to contact the author when using the model !

What is BoARIO ?
=================

Expand All @@ -23,18 +31,22 @@ It is still an ongoing project (in parallel of a PhD project).
.. _`Hallegatte 2013`: https://doi.org/10.1111/j.1539-6924.2008.01046.x
.. _`Pymrio`: https://pymrio.readthedocs.io/en/latest/intro.html

Here is a non-exhaustive chronology of academic works with or about the ARIO model :
You can find most academic literature using ARIO or related models :ref:`here <references>`

.. image:: https://raw.githubusercontent.com/spjuhel/BoARIO/master/imgs/chronology.svg?sanitize=true
:width: 900
:alt: ARIO academic work chronology

What is ARIO ?
===============

ARIO stands for Adaptive Regional Input-Output. It is an hybrid input-output / agent-based economic model, designed to compute indirect costs from economic shocks. Its first version dates back to 2008 and has originally been developed to assess the indirect costs of natural disasters (Hallegatte 2008).
ARIO stands for Adaptive Regional Input-Output. It is an hybrid input-output / agent-based economic model,
designed to compute indirect costs from economic shocks. Its first version dates back to 2008 and has originally
been developed to assess the indirect costs of natural disasters (Hallegatte 2008).

In ARIO, the economy is modelled as a set of economic sectors and a set of regions. Each economic sector produces its generic product and draws inputs from an inventory. Each sector answers to a total demand consisting of a final demand (household consumption, public spending and private investments) of all regions (local demand and exports) and intermediate demand (through inputs inventory resupply). An initial equilibrium state of the economy is built based on multi-regional input-output tables (MRIO tables).
In ARIO, the economy is modelled as a set of economic sectors and a set of regions.
Each economic sector produces its generic product and draws inputs from an inventory.
Each sector answers to a total demand consisting of a final demand (household consumption,
public spending and private investments) of all regions (local demand and exports) and
intermediate demand (through inputs inventory resupply). An initial equilibrium state of
the economy is built based on multi-regional input-output tables (MRIO tables).


Where to get BoARIO ?
Expand Down Expand Up @@ -92,7 +104,7 @@ This work was supported by the French Environment and Energy Management Agency
Development
------------

* Samuel Juhel
* Samuel Juhel ([email protected])

Contributions
---------------
Expand All @@ -102,4 +114,5 @@ All :ref:`contributions<contributions>` to the project are welcome !
Acknowledgements
------------------

I would like to thank Vincent Viguie, Fabio D'Andrea my PhD supervisors as well as Célian Colon and Alessio Ciulo for their inputs during the model implementation.
I would like to thank Vincent Viguie, Fabio D'Andrea my PhD supervisors as well as Célian Colon, Alessio Ciulo and Adrien Delahais
for their inputs during the model implementation.
17 changes: 6 additions & 11 deletions boario/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,11 @@
else:
_has_coloredlogs = True

try:
import pygit2
except:
pass

import pathlib
import logging
from functools import lru_cache

__version__ = "v0.4.1b0"
__version__ = "v0.5.0a"
__author__ = "sjuhel <[email protected]>"

# __minimum_python_version__ = "3.8"
Expand All @@ -49,13 +44,13 @@
datefmt="%H:%M:%S",
)


try:
import pygit2

__git_branch__ = pygit2.Repository(__file__).head.name
except Exception:
pass
else:
logger.info(f"You are using boario from branch {__git_branch__}")
logger.info("You are using boario from branch %s", __git_branch__)
except ModuleNotFoundError:
logger.info("Unable to tell git branch as pygit2 was not found.")


@lru_cache(10)
Expand Down
Loading

0 comments on commit 388ca88

Please sign in to comment.