From 76c95e4b126ce20483ecb2fd7f3c297b368840c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20NAVARRETE=20GUTI=C3=89RREZ?= Date: Thu, 12 Sep 2024 14:20:49 +0200 Subject: [PATCH 1/2] :bug: fix: namespaced methods get right units Previously the namespaced methods didn't get the units correctly because the units_mapping was missing the namespace. d[-_-]b --- bw2io/__init__.py | 2 +- bw2io/ecoinvent.py | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/bw2io/__init__.py b/bw2io/__init__.py index e28e4a7c..a557dbc9 100644 --- a/bw2io/__init__.py +++ b/bw2io/__init__.py @@ -48,7 +48,7 @@ "useeio20", ] -__version__ = "0.9.DEV37" +__version__ = "0.9.DEV38" from .backup import ( backup_data_directory, diff --git a/bw2io/ecoinvent.py b/bw2io/ecoinvent.py index e8ad9785..8ca472ad 100644 --- a/bw2io/ecoinvent.py +++ b/bw2io/ecoinvent.py @@ -294,10 +294,21 @@ def import_ecoinvent_release( } cf_col_label = CF_COLUMN_LABELS.get(version, "cf") units_col_label = pick_a_unit_label_already(units[0]) - units_mapping = { - (row["method"], row["category"], row["indicator"]): row[units_col_label] - for row in units - } + if namespace_lcia_methods: + units_mapping = { + ( + f"ecoinvent-{version}", + row["method"], + row["category"], + row["indicator"], + ): row[units_col_label] + for row in units + } + else: + units_mapping = { + (row["method"], row["category"], row["indicator"]): row[units_col_label] + for row in units + } biosphere_mapping = {} for flow in bd.Database(biosphere_name): From 25e44a1de6d80e95470075150f94766a6baab76e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1s=20NAVARRETE=20GUTI=C3=89RREZ?= Date: Thu, 12 Sep 2024 14:29:47 +0200 Subject: [PATCH 2/2] chore: udpate CHANGES.md --- CHANGES.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 740ad808..ea55b5cc 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ * Add `create_products_as_new_nodes` strategy +### 0.9.DEV38 (2024-09-12) + +* Fix #274: correctly set units for namespaced methods when importing ecoinvent with ecoinvent_interface + ### 0.9.DEV37 (2024-09-04) * Fix out of order but with `create_randonneur_excel_template_for_unlinked`