Skip to content

Commit

Permalink
Merge pull request #163 from mfastudillo/fix_iotable_backend
Browse files Browse the repository at this point in the history
fix iterator over exchanges
  • Loading branch information
BenPortner authored Mar 15, 2024
2 parents 02abbcf + 9273da8 commit 1be482d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion bw2data/backends/iotable/proxies.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _raw_technosphere_iterator(self, negative=True):
yield (row, col, value)

def _raw_biosphere_iterator(self):
bm = lambda x: any(obj["matrix"] == "biosphere_matrix" for obj in x.values())
bm = lambda x: any(obj.get("matrix") == "biosphere_matrix" for obj in x.values())
for resource in filter(bm, self.resources):
for (row, col), value in zip(
resource["indices"]["array"], resource["data"]["array"]
Expand Down
7 changes: 7 additions & 0 deletions tests/iotable.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,3 +489,10 @@ def test_iotable_filtered_datapackage(iotable_fixture):
IOTableExchanges(datapackage=dp, target=get_node(code="b"))
with pytest.raises(InvalidDatapackage):
IOTableExchanges(datapackage=dp, target=get_node(code="a"))


def test_iotable_readonlyexchange_iterator(iotable_fixture):

act = get_activity(('cat','b'))

list(act.exchanges())

0 comments on commit 1be482d

Please sign in to comment.