Chris Mutel committed 3f9c56d

0.9.1: Technosphere matrix builder copies params before modifying to keep sign correct

Comments (0)

Files changed (3)

     def rebuild_characterization_matrix(self, vector):
         self.characterization_matrix = MatrixBuilder.build_diagonal_matrix(
-            self.cf_params, self.biosphere_dict, "index", new_data=vector)
+            self.cf_params, self.biosphere_dict,
+            "index", "index", new_data=vector)
     def redo_lci(self, demand):
         """Redo LCI with same databases but different demand"""


     def build_diagonal_matrix(cls, array, row_dict, index_label,
                               data_label=None, new_data=None):
         """Build diagonal sparse matrix."""
-        return cls.build_matrix(array, row_dict, row_dict, index_label, index_label, data_label)
+        return cls.build_matrix(array, row_dict, row_dict, index_label, index_label, data_label, new_data)
 class TechnosphereBiosphereMatrixBuilder(MatrixBuilder):
     def fix_supply_use(cls, array, vector):
         """Make technosphere inputs negative."""
         # Inputs are consumed, so are negative
-        # Operates in place
         mask = cls.get_technosphere_inputs_mask(array)
         vector[mask] = -1 * vector[mask]
+        return vector
     def build_technosphere_matrix(cls, array, tech_dict, new_data=None):
         vector = array["amount"] if new_data is None else new_data
-        cls.fix_supply_use(array, vector)
+        vector = cls.fix_supply_use(array, vector.copy())
         return cls.build_matrix(array, tech_dict, tech_dict, "row", "col", "amount", vector)
-    version="0.9.0-alpha3",
+    version="0.9.1",
     packages=["bw2calc", "bw2calc.tests"],
     author="Chris Mutel",