diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f63e628..335ee99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -56,13 +56,13 @@ jobs: - uses: actions/checkout@v2 - name: Install python version - uses: gabrielfalcao/pyenv-action@v7 + uses: gabrielfalcao/pyenv-action@v13 with: - default: 3.9.0 + default: 3.10.6 command: pip install -U pip # upgrade pip after installing python - name: create environment - run: pyenv local 3.9.0 && python -mvenv .venv390 + run: pyenv local 3.10.6 && python -mvenv .venv390 - name: Install dependencies run: | @@ -88,7 +88,7 @@ jobs: fail-fast: false matrix: os: [ "ubuntu-latest" ] - python-version: [ "3.9" ] + python-version: [ "3.10" ] steps: - uses: actions/checkout@v2 - uses: conda-incubator/setup-miniconda@v2 diff --git a/carculator_truck/inventory.py b/carculator_truck/inventory.py index d546a94..5ccaa86 100644 --- a/carculator_truck/inventory.py +++ b/carculator_truck/inventory.py @@ -2,12 +2,14 @@ inventory.py contains Inventory which provides all methods to solve inventories. """ +import warnings + import numpy as np from carculator_utils.inventory import Inventory from . import DATA_DIR -np.warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning) +warnings.filterwarnings("ignore", category=np.VisibleDeprecationWarning) IAM_FILES_DIR = DATA_DIR / "IAM" diff --git a/carculator_truck/model.py b/carculator_truck/model.py index 044d460..ccc7d34 100644 --- a/carculator_truck/model.py +++ b/carculator_truck/model.py @@ -24,7 +24,6 @@ def finite(array, mask_value=0): class TruckModel(VehicleModel): - """ This class represents the entirety of the vehicles considered, with useful attributes, such as an array that stores all the vehicles parameters. @@ -163,9 +162,9 @@ def set_cargo_mass_and_annual_mileage(self): for s in self.array.coords["size"].values: cycle = self.cycle if isinstance(self.cycle, str) else "Urban delivery" - self.array.loc[ - dict(size=s, parameter="kilometers per year") - ] = annual_mileage[cycle][s] + self.array.loc[dict(size=s, parameter="kilometers per year")] = ( + annual_mileage[cycle][s] + ) def adjust_cost(self): """ @@ -958,9 +957,11 @@ def remove_energy_consumption_from_unavailable_vehicles(self): # as a result of curb mass being too large vals = np.asarray( [ - np.round(v[2][0], 1) - if (v[0][0] - v[1][0]) > 0 - else f"-{np.round(v[2][0])}-" + ( + np.round(v[2][0], 1) + if (v[0][0] - v[1][0]) > 0 + else f"-{np.round(v[2][0])}-" + ) for v in ( self.array.sel( parameter=["gross mass", "driving mass", "cargo mass"], @@ -978,9 +979,11 @@ def remove_energy_consumption_from_unavailable_vehicles(self): parameter="is_available", powertrain=pt, year=y, - value="reference" - if "reference" in self.array.coords["value"] - else 0, + value=( + "reference" + if "reference" in self.array.coords["value"] + else 0 + ), ).values, vals, "/", diff --git a/conda/conda_build_config.yaml b/conda/conda_build_config.yaml index 8d03891..30c7120 100644 --- a/conda/conda_build_config.yaml +++ b/conda/conda_build_config.yaml @@ -1,2 +1,2 @@ python: - - 3.9 \ No newline at end of file + - 3.10 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index f9a1274..d07f474 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -carculator-utils==1.2.0.dev0 +carculator-utils>=1.2.0.dev5 prettytable \ No newline at end of file diff --git a/setup.py b/setup.py index f7b59db..9ceecc8 100644 --- a/setup.py +++ b/setup.py @@ -40,7 +40,8 @@ def package_files(directory): package_data={ "carculator_truck": package_files(os.path.join("carculator_truck", "data")) }, - install_requires=["carculator_utils==1.2.0.dev0", "prettytable"], + python_requires=">=3.10", + install_requires=["carculator_utils>=1.2.0.dev5", "prettytable"], url="https://github.com/romainsacchi/carculator_truck", description="Prospective environmental and economic life cycle assessment" "of medium and heavy goods vehicles", diff --git a/tests/test_inventory.py b/tests/test_inventory.py index c880ee8..72f6428 100644 --- a/tests/test_inventory.py +++ b/tests/test_inventory.py @@ -63,13 +63,13 @@ def test_fuel_blend(): "share": [0.93, 0.93, 0.93, 0.93, 0.93, 0.93], }, "secondary": { - "type": "biodiesel - cooking oil", + "type": "diesel - biodiesel - cooking oil", "share": [0.07, 0.07, 0.07, 0.07, 0.07, 0.07], }, }, - "cng": { + "methane": { "primary": { - "type": "biogas - sewage sludge", + "type": "methane - biomethane - sewage sludge", "share": [1, 1, 1, 1, 1, 1], } }, @@ -88,37 +88,36 @@ def test_fuel_blend(): tm.fuel_blend["diesel"]["secondary"]["share"], [0.07, 0.07, 0.07, 0.07, 0.07, 0.07], ) - assert np.allclose(tm.fuel_blend["cng"]["primary"]["share"], [1, 1, 1, 1, 1, 1]) - # assert np.sum(ic.fuel_blends["cng"]["secondary"]["share"]) == 0 + assert np.allclose(tm.fuel_blend["methane"]["primary"]["share"], [1, 1, 1, 1, 1, 1]) ic.calculate_impacts() for fuels in [ - ("diesel", "electrolysis", "cng"), + ("diesel", "hydrogen - electrolysis - PEM", "methane"), ( - "biodiesel - palm oil", - "smr - natural gas", - "biogas - sewage sludge", + "diesel - biodiesel - palm oil", + "hydrogen - smr - natural gas", + "methane - biomethane - sewage sludge", ), ( - "biodiesel - rapeseed oil", - "smr - natural gas with CCS", - "biogas - biowaste", + "diesel - biodiesel - rapeseed oil", + "hydrogen - smr - natural gas with CCS", + "methane - synthetic - coal", ), ( - "biodiesel - cooking oil", - "wood gasification with EF with CCS", - "biogas - biowaste", + "diesel - biodiesel - cooking oil", + "hydrogen - wood gasification", + "methane - synthetic - biological", ), ( - "biodiesel - algae", - "atr - biogas", - "biogas - biowaste", + "diesel - synthetic - FT - coal - economic allocation", + "hydrogen - atr - biogas", + "methane - synthetic - biological - MSWI", ), ( - "synthetic diesel - energy allocation", - "wood gasification with EF with CCS", - "syngas", + "diesel - synthetic - methanol - cement - economic allocation", + "hydrogen - wood gasification with CCS", + "methane - synthetic - electrochemical - MSWI", ), ]: fb = { @@ -126,7 +125,7 @@ def test_fuel_blend(): "primary": {"type": fuels[0], "share": [1, 1, 1, 1, 1, 1]}, }, "hydrogen": {"primary": {"type": fuels[1], "share": [1, 1, 1, 1, 1, 1]}}, - "cng": {"primary": {"type": fuels[2], "share": [1, 1, 1, 1, 1, 1]}}, + "methane": {"primary": {"type": fuels[2], "share": [1, 1, 1, 1, 1, 1]}}, } tm = TruckModel(array, cycle="Long haul", country="CH", fuel_blend=fb) @@ -163,12 +162,7 @@ def test_endpoint(): def test_sulfur_concentration(): ic = InventoryTruck(tm, method="recipe", indicator="endpoint") - ic.get_sulfur_content("RER", "diesel", 2000) - ic.get_sulfur_content("foo", "diesel", 2000) - - with pytest.raises(ValueError) as wrapped_error: - ic.get_sulfur_content("FR", "diesel", "jku") - assert wrapped_error.type == ValueError + ic.get_sulfur_content("RER", "diesel") def test_custom_electricity_mix():