Skip to content

Commit 262236a

Browse files
authored
Bumping to v0.5.5
* bumping version * removed numpyencoder dependency (#75) * Fixed groupby(axis=1) FutureWarning (except for pymrio dep) * Removed indicators.py for the time being (not used currently) * updated poetry.lock * Presumably fixes #73 * CI/CD update - update black action to run only on master during pull request - Improved caching of venv * Badges ! * updated documentation * Created dependabot.yml
1 parent 170c308 commit 262236a

File tree

94 files changed

+3991
-10500
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+3991
-10500
lines changed

.github/dependabot.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "pip" # See documentation for possible values
9+
directory: "/pyproject.toml" # Location of package manifests
10+
schedule:
11+
interval: "weekly"
12+
13+
- package-ecosystem: "github-actions"
14+
# Workflow files stored in the default location of `.github/workflows`. (You don't need to specify `/.github/workflows` for `directory`. You can use `directory: "/"`.)
15+
directory: "/"
16+
schedule:
17+
# Check for updates to GitHub Actions every weekday
18+
interval: "daily"

.github/workflows/CI.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: CI
2+
on: pull_request
3+
4+
jobs:
5+
ci:
6+
strategy:
7+
fail-fast: false
8+
matrix:
9+
python-version: ["3.9", "3.10", "3.11"]
10+
os: [ubuntu-latest, macos-latest, windows-latest]
11+
runs-on: ${{ matrix.os }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Install poetry
15+
run: pipx install poetry
16+
- uses: actions/setup-python@v5
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
cache: 'poetry'
20+
- name: Install the project dependencies
21+
run: poetry install
22+
- name: Run black
23+
run: poetry run black --check --verbose ./boario
24+
- name: Run the automated tests (for example)
25+
run: poetry run pytest -v

.github/workflows/black.yml

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.rst

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,32 @@
55
BoARIO
66
#######
77

8+
9+
.. image:: https://img.shields.io/github/actions/workflow/status/spjuhel/boario/CI.yml
10+
:target: https://github.com/spjuhel/BoARIO/actions/workflows/CI.yml
11+
:alt: GitHub Actions Workflow Status
12+
13+
.. image:: https://img.shields.io/badge/code%20style-black-000000
14+
:target: https://github.com/psf/black
15+
:alt: Code Style - Black
16+
17+
.. image:: https://img.shields.io/badge/contributions-welcome-brightgreen.svg?style=flat
18+
:target: https://github.com/spjuhel/BoARIO/issues
19+
:alt: Contribution - Welcome
20+
21+
.. image:: https://img.shields.io/badge/License-GPLv3-blue
22+
:target: https://www.gnu.org/licenses/gpl-3.0
23+
:alt: Licence - GPLv3
24+
25+
.. image:: https://img.shields.io/pypi/v/boario
26+
:target: https://pypi.org/project/boario/
27+
:alt: PyPI - Version
28+
29+
.. image:: https://img.shields.io/pypi/pyversions/boario
30+
:target: https://pypi.org/project/boario/
31+
:alt: PyPI - Python Version
32+
33+
834
`BoARIO` : The Adaptative Regional Input Output model in python.
935

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

boario/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,12 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
try:
17-
import coloredlogs as coloredlogs
17+
import coloredlogs as coloredlogs # noqa: F401
1818
except ImportError:
1919
_has_coloredlogs = False
2020
else:
2121
_has_coloredlogs = True
2222

23-
import pathlib
2423
import importlib.metadata
2524
import logging
2625
from functools import lru_cache
@@ -53,7 +52,7 @@
5352
logger.info("You are using boario from branch %s", __git_branch__)
5453
except pygit2.GitError:
5554
logger.info(
56-
f"Could not find git branch, this is normal if you installed boario from pip."
55+
"Could not find git branch, this is normal if you installed boario from pip."
5756
)
5857
except ModuleNotFoundError:
5958
logger.info("Unable to tell git branch as pygit2 was not found.")

boario/event.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,22 +14,24 @@
1414
# You should have received a copy of the GNU General Public License
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616
from __future__ import annotations
17+
18+
import inspect
19+
import math
20+
import warnings
1721
from abc import ABC, abstractmethod
18-
from typing import Callable, Optional, Union, List, Tuple, get_origin, get_args
19-
import numpy.typing as npt
22+
from functools import partial
23+
from typing import Callable, List, Optional, Tuple, Union
24+
2025
import numpy as np
26+
import numpy.typing as npt
2127
import pandas as pd
22-
import math
23-
import inspect
24-
from functools import partial
25-
import warnings
2628

2729
from boario import logger
2830
from boario.utils.recovery_functions import (
2931
concave_recovery,
3032
convexe_recovery,
31-
linear_recovery,
3233
convexe_recovery_scaled,
34+
linear_recovery,
3335
)
3436

3537
__all__ = [
@@ -334,10 +336,10 @@ def from_scalar_industries(
334336
Event: An Event object or one of its subclass.
335337
"""
336338
if impact <= 0:
337-
raise ValueError(f"Impact is null")
339+
raise ValueError("Impact is null")
338340

339341
if len(industries) < 1:
340-
raise ValueError(f"Null sized affected industries ?")
342+
raise ValueError("Null sized affected industries ?")
341343

342344
if isinstance(industries, list):
343345
industries = pd.MultiIndex.from_tuples(
@@ -403,7 +405,7 @@ def from_scalar_regions_sectors(
403405
Event: An Event object or one of its subclass
404406
"""
405407
if impact <= 0:
406-
raise ValueError(f"Impact is null")
408+
raise ValueError("Impact is null")
407409

408410
if isinstance(regions, str):
409411
regions = [regions]
@@ -415,10 +417,10 @@ def from_scalar_regions_sectors(
415417
_sectors = pd.Index(sectors, name="sector")
416418

417419
if len(_regions) < 1:
418-
raise ValueError(f"Null sized affected regions ?")
420+
raise ValueError("Null sized affected regions ?")
419421

420422
if len(_sectors) < 1:
421-
raise ValueError(f"Null sized affected sectors ?")
423+
raise ValueError("Null sized affected sectors ?")
422424

423425
if _sectors.duplicated().any():
424426
warnings.warn(
@@ -687,7 +689,8 @@ def impact_industries_distrib(self) -> pd.Series:
687689
def impact_industries_distrib(self, value: pd.Series):
688690
self._impact_industries_distrib = value
689691
self._impact_regional_distrib = self._impact_industries_distrib.groupby(
690-
"region"
692+
"region",
693+
observed=False,
691694
).sum()
692695

693696
def __repr__(self):

boario/extended_models.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,17 @@
1515
# along with this program. If not, see <https://www.gnu.org/licenses/>.
1616

1717
from __future__ import annotations
18+
1819
from typing import Dict, Optional
20+
1921
import numpy as np
2022
import pandas as pd
21-
from boario import logger
22-
from boario.model_base import *
23-
from boario.event import *
2423
from pymrio.core.mriosystem import IOSystem
2524

25+
from boario import logger
26+
27+
from boario.model_base import ARIOBaseModel, INV_THRESHOLD
28+
2629
__all__ = ["ARIOPsiModel"]
2730

2831

@@ -90,9 +93,11 @@ def __init__(
9093

9194
if isinstance(inventory_restoration_tau, int):
9295
restoration_tau = [
93-
(self.n_temporal_units_by_step / inventory_restoration_tau)
94-
if v >= INV_THRESHOLD
95-
else v
96+
(
97+
(self.n_temporal_units_by_step / inventory_restoration_tau)
98+
if v >= INV_THRESHOLD
99+
else v
100+
)
96101
for v in self.inventories
97102
] # for sector with no inventory TODO: reflect on that.
98103
elif isinstance(inventory_restoration_tau, dict):

0 commit comments

Comments
 (0)