antelope-interface 0.3.1__tar.gz → 0.3.3__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.
- {antelope_interface-0.3.1/src/antelope_interface.egg-info → antelope_interface-0.3.3}/PKG-INFO +1 -1
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/pyproject.toml +1 -1
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/setup.py +4 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/__init__.py +1 -1
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/ibackground.py +7 -0
- antelope_interface-0.3.3/src/antelope/qdb/qdb.py +32 -0
- antelope_interface-0.3.3/src/antelope/qdb/units.py +15 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/base.py +4 -1
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/exchange_ref.py +30 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/process_ref.py +33 -0
- antelope_interface-0.3.3/src/antelope/refs/tests/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3/src/antelope_interface.egg-info}/PKG-INFO +1 -1
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/SOURCES.txt +3 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/LICENSE +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/MANIFEST.in +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/README.md +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/setup.cfg +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/exchanges_from_spreadsheet.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/flows/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/flows/flow.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/flows/flow_interface.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/flows/openlca_locales.json +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/abstract_query.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/ibasic.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iconfigure.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iexchange.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iforeground.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iindex.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iquantity.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/models/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/models/auth.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/models/comparators.py +0 -0
- {antelope_interface-0.3.1/src/antelope/refs/tests → antelope_interface-0.3.3/src/antelope/qdb}/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/__init__.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/catalog_ref.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/flow_ref.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/quantity_ref.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/refs/tests/test_flows.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/xdb_tokens.py +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/dependency_links.txt +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/requires.txt +0 -0
- {antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/top_level.txt +0 -0
|
@@ -5,6 +5,10 @@ setup()
|
|
|
5
5
|
|
|
6
6
|
"""
|
|
7
7
|
Version History:
|
|
8
|
+
0.3.3 2025/09/08 - Apply ordering to exchange refs; pandas-friendly output for process refs
|
|
9
|
+
|
|
10
|
+
0.3.2 2025/08/01 - 0.3.2 release. better background handling.
|
|
11
|
+
|
|
8
12
|
0.3.1 2025/06/18 - 0.3.1 release. small tweaks to method signatures.
|
|
9
13
|
|
|
10
14
|
0.3.0 2024/10/24 - 0.3.0 release. add comparators.
|
|
@@ -11,7 +11,7 @@ from .interfaces.ibasic import BasicInterface, EntityNotFound, NoAccessToEntity,
|
|
|
11
11
|
from .interfaces.iconfigure import ConfigureInterface
|
|
12
12
|
from .interfaces.iexchange import ExchangeInterface, ExchangeRequired
|
|
13
13
|
from .interfaces.iindex import IndexInterface, IndexRequired, directions, comp_dir, num_dir, check_direction, valid_sense, comp_sense
|
|
14
|
-
from .interfaces.ibackground import BackgroundInterface, BackgroundRequired
|
|
14
|
+
from .interfaces.ibackground import BackgroundInterface, BackgroundRequired, LinkingError
|
|
15
15
|
from .interfaces.iquantity import QuantityInterface, QuantityRequired, NoFactorsFound, ConversionReferenceMismatch, FlowableMismatch
|
|
16
16
|
from .interfaces.iforeground import ForegroundInterface
|
|
17
17
|
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/ibackground.py
RENAMED
|
@@ -26,6 +26,13 @@ class BackgroundRequired(Exception):
|
|
|
26
26
|
pass
|
|
27
27
|
|
|
28
28
|
|
|
29
|
+
class LinkingError(Exception):
|
|
30
|
+
"""
|
|
31
|
+
To be returned when a strict linking strategy cannot be implemented
|
|
32
|
+
"""
|
|
33
|
+
pass
|
|
34
|
+
|
|
35
|
+
|
|
29
36
|
_interface = 'background'
|
|
30
37
|
|
|
31
38
|
BACKGROUND_VALUES_REQUIRED = {'dependencies', 'emissions', 'cutoffs', 'lci', 'sys_lci', 'foreground', 'ad', 'bf'}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"""
|
|
2
|
+
An interface specification for a quantity database. This was originally conceived as being *the* quantity
|
|
3
|
+
interface, but as things have developed it's become clear that the qdb does more (and less) than the
|
|
4
|
+
quantity interface governs, and many (even most) of the operations of qdb are not even part of the antelope
|
|
5
|
+
interface spec.
|
|
6
|
+
|
|
7
|
+
For that reason, we are putting this *still in* antelope interface but *outside of* the abstract query framework,
|
|
8
|
+
and making it a straight abstract base class.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from abc import ABC
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class QdbInterface(ABC):
|
|
15
|
+
"""
|
|
16
|
+
The main purpose of the qdb is to maintain a free-standing database of quantities and flows. This will
|
|
17
|
+
most likely be implemented as a graph, but the interface for interacting with it is not going to care about
|
|
18
|
+
that. Here we brainstorm about all the things we would want the qdb to do.
|
|
19
|
+
|
|
20
|
+
# quantities
|
|
21
|
+
|
|
22
|
+
Quantities are a fundamental concept in physical science; yet my implementation of them is basically made up
|
|
23
|
+
based on my experience and intuition. We distinguish between reference quantities, which are directly measurable,
|
|
24
|
+
and which are [within qdb] *strictly* canonical and can therefore only be created or altered by privileged users,
|
|
25
|
+
and *indicators*, which are quantities that may or may not be directly measurable but are owned by users and
|
|
26
|
+
therefore not canonical.
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
In qdb, we only store *reference* quantities (right? or do we allow users
|
|
30
|
+
to make their own quantities? we allow users to make their own *indicators*. Only privileged users can c
|
|
31
|
+
"""
|
|
32
|
+
pass
|
|
@@ -233,6 +233,36 @@ class ExchangeRef(object):
|
|
|
233
233
|
except AttributeError:
|
|
234
234
|
return False
|
|
235
235
|
|
|
236
|
+
def __lt__(self, other):
|
|
237
|
+
if EXCHANGE_TYPES.index(self.type) < EXCHANGE_TYPES.index(other.type):
|
|
238
|
+
return True
|
|
239
|
+
if self.type == other.type:
|
|
240
|
+
return (self.flow.external_ref, self.direction, self.value) < \
|
|
241
|
+
(other.flow.external_ref, other.direction, other.value)
|
|
242
|
+
return False
|
|
243
|
+
|
|
244
|
+
def __le__(self, other):
|
|
245
|
+
if self.__eq__(other):
|
|
246
|
+
return True
|
|
247
|
+
if self.__lt__(other):
|
|
248
|
+
return True
|
|
249
|
+
return False
|
|
250
|
+
|
|
251
|
+
def __gt__(self, other):
|
|
252
|
+
if EXCHANGE_TYPES.index(self.type) > EXCHANGE_TYPES.index(other.type):
|
|
253
|
+
return True
|
|
254
|
+
if self.type == other.type:
|
|
255
|
+
return (self.flow.external_ref, self.direction, self.value) > \
|
|
256
|
+
(other.flow.external_ref, other.direction, other.value)
|
|
257
|
+
return False
|
|
258
|
+
|
|
259
|
+
def __ge__(self, other):
|
|
260
|
+
if self.__eq__(other):
|
|
261
|
+
return True
|
|
262
|
+
if self.__gt__(other):
|
|
263
|
+
return True
|
|
264
|
+
return False
|
|
265
|
+
|
|
236
266
|
@property
|
|
237
267
|
def key(self):
|
|
238
268
|
return self._hash
|
|
@@ -341,3 +341,36 @@ class ProcessRef(EntityRef):
|
|
|
341
341
|
"""
|
|
342
342
|
ref_flow = self._use_ref_exch(ref_flow)
|
|
343
343
|
return self._query.deep_lcia(self.external_ref, lcia_qty, ref_flow=ref_flow, detailed=detailed, **kwargs)
|
|
344
|
+
|
|
345
|
+
@property
|
|
346
|
+
def inventory_as_series(self):
|
|
347
|
+
"""
|
|
348
|
+
Use this as generative input to pandas.Series:
|
|
349
|
+
s = pandas.Series(process_ref.inventory_as_series)
|
|
350
|
+
:return:
|
|
351
|
+
"""
|
|
352
|
+
def _tx_cx(_ex):
|
|
353
|
+
if _ex.type == 'reference':
|
|
354
|
+
return '*'
|
|
355
|
+
elif _ex.type == 'node':
|
|
356
|
+
return '#'
|
|
357
|
+
elif _ex.type == 'context':
|
|
358
|
+
return _ex.termination.name
|
|
359
|
+
else:
|
|
360
|
+
return None
|
|
361
|
+
return {(k.flow.name, _tx_cx(k), k.direction, k.unit): k.value for k in self.inventory()}
|
|
362
|
+
|
|
363
|
+
@property
|
|
364
|
+
def inventory_as_dataframe(self):
|
|
365
|
+
"""
|
|
366
|
+
Use this as generative input to pandas.DataFrame:
|
|
367
|
+
df = pandas.DataFrame(process_ref.inventory_as_dataframe)
|
|
368
|
+
:return:
|
|
369
|
+
"""
|
|
370
|
+
def _cx_of(_ex):
|
|
371
|
+
if _ex.type == 'context':
|
|
372
|
+
return _ex.termination.name
|
|
373
|
+
return None
|
|
374
|
+
for k in self.inventory():
|
|
375
|
+
yield {'Flow': k.flow.name, 'Direction': k.direction, 'Type': k.type, 'Unit': k.flow.unit,
|
|
376
|
+
'Value': k.value, 'Context': _cx_of(k)}
|
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/SOURCES.txt
RENAMED
|
@@ -22,6 +22,9 @@ src/antelope/interfaces/iquantity.py
|
|
|
22
22
|
src/antelope/models/__init__.py
|
|
23
23
|
src/antelope/models/auth.py
|
|
24
24
|
src/antelope/models/comparators.py
|
|
25
|
+
src/antelope/qdb/__init__.py
|
|
26
|
+
src/antelope/qdb/qdb.py
|
|
27
|
+
src/antelope/qdb/units.py
|
|
25
28
|
src/antelope/refs/__init__.py
|
|
26
29
|
src/antelope/refs/base.py
|
|
27
30
|
src/antelope/refs/catalog_ref.py
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/exchanges_from_spreadsheet.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/flows/openlca_locales.json
RENAMED
|
File without changes
|
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/abstract_query.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope/interfaces/iforeground.py
RENAMED
|
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
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/requires.txt
RENAMED
|
File without changes
|
{antelope_interface-0.3.1 → antelope_interface-0.3.3}/src/antelope_interface.egg-info/top_level.txt
RENAMED
|
File without changes
|