matrix-utils 0.8__tar.gz → 0.9__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {matrix_utils-0.8 → matrix_utils-0.9}/CHANGELOG.md +4 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/PKG-INFO +2 -2
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/__init__.py +1 -1
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/resource_group.py +20 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils.egg-info/PKG-INFO +2 -2
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils.egg-info/requires.txt +1 -1
- {matrix_utils-0.8 → matrix_utils-0.9}/pyproject.toml +1 -1
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/mapped_matrix.py +58 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/.gitignore +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/.pre-commit-config.yaml +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/CODE_OF_CONDUCT.md +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/LICENSE +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/MANIFEST.in +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/README.md +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/binder/Brightway 2.5 demonstration.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/binder/environment.yml +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Brightway 2.5 - Linking with IAMs.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Brightway 2.5 demonstration.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Graph traversal with modification.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Indexing speed tests.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Interfaces which produce results for multiple matrices.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Mapping speed tests.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Multifunctionality with Brightway 2.5.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Real-time modification of hybrid databases.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Supply chain modification.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/Untitled.ipynb +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw2.prof +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw2.svg +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw25.prof +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw25.svg +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw25_profile.txt +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw25_profiling.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw2_profile.txt +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/bw2_profiling.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/profiling/profiling-versus-bw2.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/speed_test_unique_indices.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/dev/speed_tests.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/Makefile +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/conf.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/index.rst +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/loading.rst +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/make.bat +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/saving.rst +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/docs/utilities.rst +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/aggregation.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/array_mapper.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/errors.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/indexers.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/mapped_matrix.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/mapped_matrix_dict.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils/utils.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils.egg-info/SOURCES.txt +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils.egg-info/dependency_links.txt +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/matrix_utils.egg-info/top_level.txt +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/setup.cfg +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/array_mapper.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/__init__.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/a-first.zip +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/b-second.zip +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/basic.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/create_static_fixtures.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/sa-1.zip +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/fixtures/sa-2.zip +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/indexers.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/integration.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/interfaces.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/masking.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/monte_carlo.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/ordering.py +0 -0
- {matrix_utils-0.8 → matrix_utils-0.9}/tests/utils.py +0 -0
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.9] - 2026-07-12
|
|
4
|
+
|
|
5
|
+
* Merge [#45](https://github.com/brightway-lca/matrix_utils/pull/45): Expose reference (production) exchange arrays from [bw_processing #108](https://github.com/brightway-lca/bw_processing/pull/108). New `ResourceGroup` properties `has_reference`, `reference`, and `reference_current`. Requires `bw_processing>=1.6`.
|
|
6
|
+
|
|
3
7
|
## [0.8] - 2026-06-04
|
|
4
8
|
|
|
5
9
|
* Merge [#42](https://github.com/brightway-lca/matrix_utils/pull/42): Rename `scale_array` to `rescale_array`, tracking [bw_processing #104](https://github.com/brightway-lca/bw_processing/pull/104). Adds `ResourceGroup.rescale_current` and `MappedMatrix.input_rescale_vector()`.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: matrix_utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9
|
|
4
4
|
Summary: Tools to create matrices from data packages
|
|
5
5
|
Author-email: Chris Mutel <cmutel@gmail.com>
|
|
6
6
|
Maintainer-email: Chris Mutel <cmutel@gmail.com>
|
|
@@ -28,7 +28,7 @@ License-File: LICENSE
|
|
|
28
28
|
Requires-Dist: numpy
|
|
29
29
|
Requires-Dist: scipy>=1.10
|
|
30
30
|
Requires-Dist: pandas
|
|
31
|
-
Requires-Dist: bw_processing>=1.
|
|
31
|
+
Requires-Dist: bw_processing>=1.6
|
|
32
32
|
Requires-Dist: stats_arrays
|
|
33
33
|
Provides-Extra: testing
|
|
34
34
|
Requires-Dist: matrix_utils; extra == "testing"
|
|
@@ -135,6 +135,14 @@ class ResourceGroup:
|
|
|
135
135
|
except KeyError:
|
|
136
136
|
return False
|
|
137
137
|
|
|
138
|
+
@property
|
|
139
|
+
def has_reference(self) -> bool:
|
|
140
|
+
try:
|
|
141
|
+
self.get_resource_by_suffix("reference")
|
|
142
|
+
return True
|
|
143
|
+
except KeyError:
|
|
144
|
+
return False
|
|
145
|
+
|
|
138
146
|
@property
|
|
139
147
|
def has_params(self) -> bool:
|
|
140
148
|
try:
|
|
@@ -205,6 +213,18 @@ class ResourceGroup:
|
|
|
205
213
|
return self.rescale
|
|
206
214
|
return None
|
|
207
215
|
|
|
216
|
+
@property
|
|
217
|
+
def reference(self):
|
|
218
|
+
"""The reference (production) exchange boolean array, with masks applied (if necessary)."""
|
|
219
|
+
return self.apply_masks(self.get_resource_by_suffix("reference"))
|
|
220
|
+
|
|
221
|
+
@property
|
|
222
|
+
def reference_current(self) -> Optional[np.ndarray]:
|
|
223
|
+
"""Current reference flags with masks applied, or ``None`` if no reference array exists."""
|
|
224
|
+
if self.has_reference:
|
|
225
|
+
return self.reference
|
|
226
|
+
return None
|
|
227
|
+
|
|
208
228
|
def get_indices_data(self):
|
|
209
229
|
"""The source data for the indices array."""
|
|
210
230
|
indices = self.get_resource_by_suffix("indices")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: matrix_utils
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.9
|
|
4
4
|
Summary: Tools to create matrices from data packages
|
|
5
5
|
Author-email: Chris Mutel <cmutel@gmail.com>
|
|
6
6
|
Maintainer-email: Chris Mutel <cmutel@gmail.com>
|
|
@@ -28,7 +28,7 @@ License-File: LICENSE
|
|
|
28
28
|
Requires-Dist: numpy
|
|
29
29
|
Requires-Dist: scipy>=1.10
|
|
30
30
|
Requires-Dist: pandas
|
|
31
|
-
Requires-Dist: bw_processing>=1.
|
|
31
|
+
Requires-Dist: bw_processing>=1.6
|
|
32
32
|
Requires-Dist: stats_arrays
|
|
33
33
|
Provides-Extra: testing
|
|
34
34
|
Requires-Dist: matrix_utils; extra == "testing"
|
|
@@ -1154,6 +1154,64 @@ def test_has_rescale_true():
|
|
|
1154
1154
|
assert mm.group("sv").has_rescale is True
|
|
1155
1155
|
|
|
1156
1156
|
|
|
1157
|
+
# ── has_reference / reference ──────────────────────────────────────────────────
|
|
1158
|
+
|
|
1159
|
+
|
|
1160
|
+
def test_has_reference_false():
|
|
1161
|
+
mm = MappedMatrix(
|
|
1162
|
+
packages=[basic_mm()], matrix="foo", use_arrays=False, use_distributions=False
|
|
1163
|
+
)
|
|
1164
|
+
assert mm.group("vector").has_reference is False
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
def test_has_reference_true():
|
|
1168
|
+
dp = bwp.create_datapackage()
|
|
1169
|
+
dp.add_persistent_vector(
|
|
1170
|
+
matrix="foo",
|
|
1171
|
+
name="sv",
|
|
1172
|
+
indices_array=np.array([(0, 0), (1, 1)], dtype=bwp.INDICES_DTYPE),
|
|
1173
|
+
data_array=np.array([1.0, 2.0]),
|
|
1174
|
+
reference_array=np.array([True, False], dtype=bool),
|
|
1175
|
+
)
|
|
1176
|
+
mm = MappedMatrix(packages=[dp], matrix="foo", use_arrays=False, use_distributions=False)
|
|
1177
|
+
assert mm.group("sv").has_reference is True
|
|
1178
|
+
|
|
1179
|
+
|
|
1180
|
+
def test_reference_values():
|
|
1181
|
+
dp = bwp.create_datapackage()
|
|
1182
|
+
dp.add_persistent_vector(
|
|
1183
|
+
matrix="foo",
|
|
1184
|
+
name="sv",
|
|
1185
|
+
indices_array=np.array([(0, 0), (1, 1)], dtype=bwp.INDICES_DTYPE),
|
|
1186
|
+
data_array=np.array([1.0, 2.0]),
|
|
1187
|
+
reference_array=np.array([True, False], dtype=bool),
|
|
1188
|
+
)
|
|
1189
|
+
mm = MappedMatrix(packages=[dp], matrix="foo", use_arrays=False, use_distributions=False)
|
|
1190
|
+
group = mm.group("sv")
|
|
1191
|
+
assert group.reference.dtype == bool
|
|
1192
|
+
assert list(group.reference) == [True, False]
|
|
1193
|
+
|
|
1194
|
+
|
|
1195
|
+
def test_reference_current_none_when_absent():
|
|
1196
|
+
mm = MappedMatrix(
|
|
1197
|
+
packages=[basic_mm()], matrix="foo", use_arrays=False, use_distributions=False
|
|
1198
|
+
)
|
|
1199
|
+
assert mm.group("vector").reference_current is None
|
|
1200
|
+
|
|
1201
|
+
|
|
1202
|
+
def test_reference_current_returns_masked_values():
|
|
1203
|
+
dp = bwp.create_datapackage()
|
|
1204
|
+
dp.add_persistent_vector(
|
|
1205
|
+
matrix="foo",
|
|
1206
|
+
name="sv",
|
|
1207
|
+
indices_array=np.array([(0, 0), (1, 1)], dtype=bwp.INDICES_DTYPE),
|
|
1208
|
+
data_array=np.array([1.0, 2.0]),
|
|
1209
|
+
reference_array=np.array([False, True], dtype=bool),
|
|
1210
|
+
)
|
|
1211
|
+
mm = MappedMatrix(packages=[dp], matrix="foo", use_arrays=False, use_distributions=False)
|
|
1212
|
+
assert list(mm.group("sv").reference_current) == [False, True]
|
|
1213
|
+
|
|
1214
|
+
|
|
1157
1215
|
# ── n_elements_dropped ─────────────────────────────────────────────────────────────────
|
|
1158
1216
|
|
|
1159
1217
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|