antelope-interface 0.2.7__tar.gz → 0.3.0__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 (40) hide show
  1. {antelope_interface-0.2.7/src/antelope_interface.egg-info → antelope_interface-0.3.0}/PKG-INFO +1 -1
  2. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/pyproject.toml +1 -1
  3. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/setup.py +4 -0
  4. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/models/__init__.py +2 -0
  5. antelope_interface-0.3.0/src/antelope/models/comparators.py +79 -0
  6. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/base.py +9 -9
  7. {antelope_interface-0.2.7 → antelope_interface-0.3.0/src/antelope_interface.egg-info}/PKG-INFO +1 -1
  8. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope_interface.egg-info/SOURCES.txt +1 -0
  9. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/LICENSE +0 -0
  10. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/MANIFEST.in +0 -0
  11. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/README.md +0 -0
  12. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/setup.cfg +0 -0
  13. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/__init__.py +0 -0
  14. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/exchanges_from_spreadsheet.py +0 -0
  15. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/flows/__init__.py +0 -0
  16. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/flows/flow.py +0 -0
  17. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/flows/flow_interface.py +0 -0
  18. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/flows/openlca_locales.json +0 -0
  19. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/__init__.py +0 -0
  20. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/abstract_query.py +0 -0
  21. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/ibackground.py +0 -0
  22. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/ibasic.py +0 -0
  23. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/iconfigure.py +0 -0
  24. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/iexchange.py +0 -0
  25. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/iforeground.py +0 -0
  26. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/iindex.py +0 -0
  27. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/interfaces/iquantity.py +0 -0
  28. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/models/auth.py +0 -0
  29. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/__init__.py +0 -0
  30. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/catalog_ref.py +0 -0
  31. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/exchange_ref.py +0 -0
  32. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/flow_ref.py +0 -0
  33. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/process_ref.py +0 -0
  34. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/quantity_ref.py +0 -0
  35. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/tests/__init__.py +0 -0
  36. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/refs/tests/test_flows.py +0 -0
  37. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope/xdb_tokens.py +0 -0
  38. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope_interface.egg-info/dependency_links.txt +0 -0
  39. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope_interface.egg-info/requires.txt +0 -0
  40. {antelope_interface-0.2.7 → antelope_interface-0.3.0}/src/antelope_interface.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: antelope_interface
3
- Version: 0.2.7
3
+ Version: 0.3.0
4
4
  Summary: A common interface for accessing LCA data
5
5
  Author-email: Brandon Kuczenski <bkuczenski@ucsb.edu>
6
6
  License: BSD-3-Clause
@@ -22,7 +22,7 @@ classifiers = [
22
22
  "Topic :: Scientific/Engineering"
23
23
  ]
24
24
  dependencies = ["synonym_dict >= 0.2.4", "pydantic >= 2.5.0"]
25
- version = "0.2.7"
25
+ version = "0.3.0"
26
26
 
27
27
  [tool.setuptools.packages.find]
28
28
  where = ["src"]
@@ -5,6 +5,10 @@ setup()
5
5
 
6
6
  """
7
7
  Version History:
8
+ 0.3.0 2024/10/24 - 0.3.0 release. add comparators.
9
+
10
+ 0.3.0-pre 2024/09/22 - pre-release for workshop (minor bugfix on UnallocatedExchange model)
11
+
8
12
  0.2.7 2024/09/10 - synchronization release for background / LCI changes
9
13
  add make_ref() machinery to a few interface routes
10
14
  alter extend_process to use dependencies instead of inventory
@@ -340,6 +340,8 @@ class Exchange(ResponseModel):
340
340
  if x.type == 'context':
341
341
  cx = list(x.termination)
342
342
  term = None
343
+ elif x.type == 'reference':
344
+ term = cx = None
343
345
  else:
344
346
  term = x.termination
345
347
  cx = None
@@ -0,0 +1,79 @@
1
+ """
2
+ Comparators
3
+
4
+ These tools enable quick comparison of sets of exchanges to see if they match
5
+ """
6
+ from math import isclose
7
+
8
+
9
+ def _rx_key(rx):
10
+ return rx.process.external_ref, rx.flow.external_ref, rx.direction
11
+
12
+
13
+ def _exch_key(exch):
14
+ return exch.flow.external_ref, exch.direction, tuple(exch.termination)
15
+
16
+
17
+ def compare_ref_exchanges(s1, s2):
18
+ """
19
+ Tests qualitative equivalence of two sets of *reference* exchanges (process, flow, direction).
20
+ :param s1:
21
+ :param s2:
22
+ :return:
23
+ """
24
+ set1 = {_rx_key(s) for s in s1}
25
+ set2 = {_rx_key(s) for s in s2}
26
+ d1 = set1.difference(set2)
27
+ d2 = set2.difference(set1)
28
+ if len(d1) + len(d2) == 0:
29
+ print('PASS (%d)' % len(set1))
30
+ else:
31
+ print('DIFFERENT (%d,%d / %d)' % (len(d1), len(d2), len(set1)))
32
+ return d1, d2
33
+
34
+
35
+ def compare_exchanges(s1, s2):
36
+ """
37
+ Tests qualitative equivalence of two sets of *depenedent* exchanges (flow, direction, termination).
38
+ Returns two sets: those present only in s1, those present only in s2
39
+ :param s1:
40
+ :param s2:
41
+ :return:
42
+ """
43
+ set1 = {_exch_key(s) for s in s1}
44
+ set2 = {_exch_key(s) for s in s2}
45
+ d1 = set1.difference(set2)
46
+ d2 = set2.difference(set1)
47
+ if len(d1) + len(d2) == 0:
48
+ print('PASS (%d)' % len(set1))
49
+ else:
50
+ print('DIFFERENT (%d,%d / %d)' % (len(d1), len(d2), len(set1)))
51
+ return d1, d2
52
+
53
+
54
+ def compare_exchange_values(s1, s2, rel_tol=1e-6):
55
+ """
56
+ The exchanges are unordered, so it's nontrivial to test two sets of results against one another.
57
+ We use the approach of mapping (flow.external_ref, direction, termination) to exchange value.
58
+ This is a summary test that compares the two sets and returns the entries in s2 that do NOT match
59
+ the entry in s1 (key error qualifies as nonmatch)
60
+ Thus a return value of length 0 indicates a passed test.
61
+ :param s1:
62
+ :param s2:
63
+ :param rel_tol: default 1e-6
64
+ :return: a list of failed exchanges, expressed as 2-tuples: (bad_exch, good_val) or (bad_exch, None)
65
+ """
66
+ c = {_exch_key(x): x.value for x in s1}
67
+ fail = []
68
+ for s in s2:
69
+ try:
70
+ v = c[_exch_key(s)]
71
+ if not isclose(v, s.value, rel_tol=rel_tol):
72
+ fail.append((s, v))
73
+ except KeyError:
74
+ fail.append((s, None))
75
+ if len(fail) == 0:
76
+ print('PASS (%d)' % len(c))
77
+ else:
78
+ print('DIFFERENT (%d / %d)' % (len(fail), len(c)))
79
+ return fail
@@ -17,15 +17,15 @@ without access to a query object that can implement the various methods.
17
17
  3. Grounded references should behave equivalently to the entities themselves. (except the remote catalogs can act
18
18
  as gatekeepers to decide what information can be disclosed)
19
19
 
20
- The inheritance pattern is:
21
-
22
- BaseRef
23
- | |
24
- | EntityRef (grounded by a catalog query)
25
- | | \ \
26
- | ProcessRef, FlowRef, QuantityRef [...]
27
- |
28
- CatalogRef (un-grounded)
20
+ The inheritance pattern is: ::
21
+
22
+ BaseRef
23
+ | |
24
+ | EntityRef (grounded by a catalog query)
25
+ | | | |
26
+ | ProcessRef, FlowRef, QuantityRef [...]
27
+ |
28
+ CatalogRef (un-grounded)
29
29
 
30
30
  The CatalogRef can instantiate a grounded reference if supplied with a query object that implements the interface.
31
31
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: antelope_interface
3
- Version: 0.2.7
3
+ Version: 0.3.0
4
4
  Summary: A common interface for accessing LCA data
5
5
  Author-email: Brandon Kuczenski <bkuczenski@ucsb.edu>
6
6
  License: BSD-3-Clause
@@ -21,6 +21,7 @@ src/antelope/interfaces/iindex.py
21
21
  src/antelope/interfaces/iquantity.py
22
22
  src/antelope/models/__init__.py
23
23
  src/antelope/models/auth.py
24
+ src/antelope/models/comparators.py
24
25
  src/antelope/refs/__init__.py
25
26
  src/antelope/refs/base.py
26
27
  src/antelope/refs/catalog_ref.py