Skip to content

Commit 1be482d

Browse files
authored
Merge pull request #163 from mfastudillo/fix_iotable_backend
fix iterator over exchanges
2 parents 02abbcf + 9273da8 commit 1be482d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

bw2data/backends/iotable/proxies.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def _raw_technosphere_iterator(self, negative=True):
228228
yield (row, col, value)
229229

230230
def _raw_biosphere_iterator(self):
231-
bm = lambda x: any(obj["matrix"] == "biosphere_matrix" for obj in x.values())
231+
bm = lambda x: any(obj.get("matrix") == "biosphere_matrix" for obj in x.values())
232232
for resource in filter(bm, self.resources):
233233
for (row, col), value in zip(
234234
resource["indices"]["array"], resource["data"]["array"]

tests/iotable.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,10 @@ def test_iotable_filtered_datapackage(iotable_fixture):
489489
IOTableExchanges(datapackage=dp, target=get_node(code="b"))
490490
with pytest.raises(InvalidDatapackage):
491491
IOTableExchanges(datapackage=dp, target=get_node(code="a"))
492+
493+
494+
def test_iotable_readonlyexchange_iterator(iotable_fixture):
495+
496+
act = get_activity(('cat','b'))
497+
498+
list(act.exchanges())

0 commit comments

Comments
 (0)