bw-processing 1.1__tar.gz → 1.1.1__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.
Files changed (54) hide show
  1. {bw_processing-1.1/src/bw_processing.egg-info → bw_processing-1.1.1}/PKG-INFO +1 -1
  2. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/__init__.py +1 -1
  3. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/matrix_entry.py +16 -0
  4. {bw_processing-1.1 → bw_processing-1.1.1/src/bw_processing.egg-info}/PKG-INFO +1 -1
  5. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_matrix_entry.py +21 -1
  6. {bw_processing-1.1 → bw_processing-1.1.1}/LICENSE +0 -0
  7. {bw_processing-1.1 → bw_processing-1.1.1}/MANIFEST.in +0 -0
  8. {bw_processing-1.1 → bw_processing-1.1.1}/README.md +0 -0
  9. {bw_processing-1.1 → bw_processing-1.1.1}/pyproject.toml +0 -0
  10. {bw_processing-1.1 → bw_processing-1.1.1}/setup.cfg +0 -0
  11. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/array_creation.py +0 -0
  12. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/constants.py +0 -0
  13. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/datapackage.py +0 -0
  14. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/errors.py +0 -0
  15. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/__init__.py +0 -0
  16. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/another name.indices.parquet +0 -0
  17. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.data.parquet +0 -0
  18. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.distributions.parquet +0 -0
  19. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.flip.parquet +0 -0
  20. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/sa-data-vector-from-dict.indices.parquet +0 -0
  21. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/some name.data.parquet +0 -0
  22. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/some name.flip.parquet +0 -0
  23. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_1/some name.indices.parquet +0 -0
  24. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/datapackage_2.zip +0 -0
  25. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/interfaces.py +0 -0
  26. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/parquet_files.py +0 -0
  27. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/examples/simple.zip +0 -0
  28. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/filesystem.py +0 -0
  29. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/indexing.py +0 -0
  30. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/io_helpers.py +0 -0
  31. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/io_parquet_helpers.py +0 -0
  32. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/io_pyarrow_helpers.py +0 -0
  33. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/merging.py +0 -0
  34. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/proxies.py +0 -0
  35. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/unique_fields.py +0 -0
  36. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing/utils.py +0 -0
  37. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing.egg-info/SOURCES.txt +0 -0
  38. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing.egg-info/dependency_links.txt +0 -0
  39. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing.egg-info/requires.txt +0 -0
  40. {bw_processing-1.1 → bw_processing-1.1.1}/src/bw_processing.egg-info/top_level.txt +0 -0
  41. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_array_creation.py +0 -0
  42. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_datapackage.py +0 -0
  43. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_filesystem.py +0 -0
  44. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_filtered_datapackage.py +0 -0
  45. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_indexing.py +0 -0
  46. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_integration.py +0 -0
  47. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_interfaces.py +0 -0
  48. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_io_parquet_helpers.py +0 -0
  49. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_io_pyarrow_helpers.py +0 -0
  50. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_loading.py +0 -0
  51. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_merging.py +0 -0
  52. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_proxies.py +0 -0
  53. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_unique_fields.py +0 -0
  54. {bw_processing-1.1 → bw_processing-1.1.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw_processing
3
- Version: 1.1
3
+ Version: 1.1.1
4
4
  Summary: Foo
5
5
  Author-email: Chris Mutel <cmutel@gmail.com>
6
6
  Maintainer-email: Chris Mutel <cmutel@gmail.com>
@@ -29,7 +29,7 @@ __all__ = (
29
29
  "UndefinedInterface",
30
30
  )
31
31
 
32
- __version__ = "1.1"
32
+ __version__ = "1.1.1"
33
33
 
34
34
 
35
35
  from bw_processing.array_creation import create_array, create_structured_array
@@ -2,6 +2,12 @@ import dataclasses
2
2
  import math
3
3
  from enum import Enum
4
4
 
5
+ try:
6
+ from stats_arrays import NoUncertainty, UndefinedUncertainty
7
+ _NO_UNCERTAINTY_IDS = (UndefinedUncertainty.id, NoUncertainty.id)
8
+ except ImportError:
9
+ _NO_UNCERTAINTY_IDS = (0, 1)
10
+
5
11
 
6
12
  class MatrixName(str, Enum):
7
13
  """Standard matrix names used in Brightway.
@@ -63,6 +69,16 @@ class MatrixEntry:
63
69
  maximum: float = math.nan
64
70
  negative: bool = False
65
71
 
72
+ def __post_init__(self):
73
+ if self.uncertainty_type in _NO_UNCERTAINTY_IDS:
74
+ if math.isnan(self.loc):
75
+ object.__setattr__(self, "loc", self.amount)
76
+ elif self.loc != self.amount:
77
+ raise ValueError(
78
+ f"uncertainty_type {self.uncertainty_type} requires loc == amount, "
79
+ f"got loc={self.loc} but amount={self.amount}"
80
+ )
81
+
66
82
  def as_dict(self) -> dict:
67
83
  return dataclasses.asdict(self)
68
84
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: bw_processing
3
- Version: 1.1
3
+ Version: 1.1.1
4
4
  Summary: Foo
5
5
  Author-email: Chris Mutel <cmutel@gmail.com>
6
6
  Maintainer-email: Chris Mutel <cmutel@gmail.com>
@@ -42,12 +42,32 @@ class TestMatrixEntry:
42
42
  assert e.flip is False
43
43
  assert e.uncertainty_type == 0
44
44
  assert e.negative is False
45
- assert math.isnan(e.loc)
45
+ assert e.loc == pytest.approx(3.0)
46
46
  assert math.isnan(e.scale)
47
47
  assert math.isnan(e.shape)
48
48
  assert math.isnan(e.minimum)
49
49
  assert math.isnan(e.maximum)
50
50
 
51
+ def test_loc_set_to_amount_for_no_uncertainty(self):
52
+ e = MatrixEntry(row=1, col=2, amount=5.0)
53
+ assert e.loc == pytest.approx(5.0)
54
+
55
+ def test_explicit_loc_matching_amount_accepted(self):
56
+ e = MatrixEntry(row=1, col=2, amount=5.0, uncertainty_type=0, loc=5.0)
57
+ assert e.loc == pytest.approx(5.0)
58
+
59
+ def test_loc_mismatch_raises_for_uncertainty_type_0(self):
60
+ with pytest.raises(ValueError, match="loc == amount"):
61
+ MatrixEntry(row=1, col=2, amount=5.0, uncertainty_type=0, loc=9.9)
62
+
63
+ def test_loc_mismatch_raises_for_uncertainty_type_1(self):
64
+ with pytest.raises(ValueError, match="loc == amount"):
65
+ MatrixEntry(row=1, col=2, amount=5.0, uncertainty_type=1, loc=9.9)
66
+
67
+ def test_loc_not_set_when_uncertainty_type_nonzero(self):
68
+ e = MatrixEntry(row=1, col=2, amount=5.0, uncertainty_type=2)
69
+ assert math.isnan(e.loc)
70
+
51
71
  def test_frozen(self):
52
72
  e = MatrixEntry(row=1, col=2, amount=3.0)
53
73
  with pytest.raises(Exception):
File without changes
File without changes
File without changes
File without changes