Skip to content

Commit

Permalink
Merge pull request #5 from romainsacchi/update
Browse files Browse the repository at this point in the history
Migration to ei39
  • Loading branch information
romainsacchi committed Feb 11, 2024
2 parents de2a37f + 3ef076c commit 66e460f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 35 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion conda/conda_build_config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
python:
- 3.9
- 3.10
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
carculator-utils==1.2.0.dev0
carculator-utils>=1.2.0.dev5
prettytable
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
50 changes: 22 additions & 28 deletions tests/test_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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],
}
},
Expand All @@ -88,45 +88,44 @@ 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 = {
"diesel": {
"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)
Expand Down Expand Up @@ -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():
Expand Down

0 comments on commit 66e460f

Please sign in to comment.