Skip to content

Commit

Permalink
update name dynamic_biomatrix to dynamic_biosphere_matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Jakobs committed Jan 31, 2025
1 parent c8198c9 commit c67700e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 15 deletions.
8 changes: 4 additions & 4 deletions bw_timex/dynamic_biosphere_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def build_dynamic_biosphere_matrix(
Returns
-------
dynamic_biomatrix : scipy.sparse.csr_matrix
dynamic_biosphere_matrix : scipy.sparse.csr_matrix
A sparse matrix with the dimensions (bio_flows at a specific time step) x (processes).
"""

Expand Down Expand Up @@ -273,10 +273,10 @@ def build_dynamic_biosphere_matrix(
else:
ncols = len(self.activity_time_mapping_dict)
shape = (max(self.rows) + 1, ncols)
dynamic_biomatrix = sp.coo_matrix((self.values, (self.rows, self.cols)), shape)
self.dynamic_biomatrix = dynamic_biomatrix.tocsr()
dynamic_biosphere_matrix = sp.coo_matrix((self.values, (self.rows, self.cols)), shape)
self.dynamic_biosphere_matrix = dynamic_biosphere_matrix.tocsr()

return self.dynamic_biomatrix, temporal_market_lci_dict
return self.dynamic_biosphere_matrix, temporal_market_lci_dict

def demand_from_timeline(self, row, original_db):
"""
Expand Down
4 changes: 2 additions & 2 deletions dev/Example_long_timeline_dev_version.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
}
],
"source": [
"tlca.dynamic_biomatrix"
"tlca.dynamic_biosphere_matrix"
]
},
{
Expand Down Expand Up @@ -829,7 +829,7 @@
}
],
"source": [
"tlca.dynamic_biomatrix"
"tlca.dynamic_biosphere_matrix"
]
},
{
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .fixtures.dynamic_biomatrix_db_fixture import dynamic_biomatrix_db
from .fixtures.dynamic_biosphere_matrix_db_fixture import dynamic_biosphere_matrix_db
from .fixtures.nonunitary_db_fixture import nonunitary_db
from .fixtures.process_at_base_database_time_db_fixture import (
process_at_base_database_time_db,
Expand Down
4 changes: 2 additions & 2 deletions tests/fixtures/dynamic_biomatrix_db_fixture.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

@pytest.fixture
@bw2test
def dynamic_biomatrix_db():
bd.projects.set_current("__test_dynamic_biomatrix__")
def dynamic_biosphere_matrix_db():
bd.projects.set_current("__test_dynamic_biosphere_matrix__")
bd.Database("bio").write(
{
("bio", "CO2"): {
Expand Down
12 changes: 6 additions & 6 deletions tests/test_dynamic_biomatrix_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@


# make sure the test db is loaded
def test_dynamic_biomatrix_fixture(dynamic_biomatrix_db):
def test_dynamic_biosphere_matrix_fixture(dynamic_biosphere_matrix_db):
assert len(bd.databases) == 3


@pytest.mark.usefixtures("dynamic_biomatrix_db")
class TestClass_dynamic_biomatrix:
@pytest.mark.usefixtures("dynamic_biosphere_matrix_db")
class TestClass_dynamic_biosphere_matrix:

@pytest.fixture(autouse=True)
def setup_method(self):
Expand Down Expand Up @@ -42,14 +42,14 @@ def test_identical_time_mapped_producers_exist_in_timeline(self):
duplicates = self.tlca.timeline["time_mapped_producer"].duplicated().any()
assert duplicates, "No duplicates found in column time_mapped_producer"

def test_dynamic_biomatrix_for_multiple_identical_time_mapped_producers_in_timeline(
def test_dynamic_biosphere_matrix_for_multiple_identical_time_mapped_producers_in_timeline(
self,
):

expected_dynamic_biomatrix_as_array = np.array(
expected_dynamic_biosphere_matrix_as_array = np.array(
[[0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.5]]
) # 1.5 CO2 is only added once for the time_mapped producer, depsite it occuring twice in the timeline! Before #78, it was added twice , resulting in 3.0

assert np.array_equal(
self.tlca.dynamic_biomatrix.toarray(), expected_dynamic_biomatrix_as_array
self.tlca.dynamic_biosphere_matrix.toarray(), expected_dynamic_biosphere_matrix_as_array
), "Arrays are not equal"

0 comments on commit c67700e

Please sign in to comment.