processes
LcProcess
Bases: LcEntity
__init__(external_ref, **kwargs)
THe process's data is a set of exchanges.
A process's reference entity is a subset of these. It is an error for these exchanges to have terminations (if they're terminated, they're not reference flows- they're dependencies). These references can be used as allocation keys for the exchanges.
The entities in reference_entity and _exchanges are not necessarily the same, although they should hash the same. Not sure whether this is a design flaw or not- but the important thing is that reference entities do not need to have exchange values associated with them (although they could).
process.find_reference(key), references() [generator], and reference(flow) all return entries from _exchanges, not entries from reference_entity. The only public interface to the objects in reference_entity is reference_entity itself.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
entity_uuid |
|
required | |
kwargs |
|
{}
|
add_exchange(flow, dirn, reference=None, value=None, termination=None, add_dups=False)
This is used to create Exchanges and ExchangeValues and AllocatedExchanges.
If the flow+dir+term is already in the exchange set: if no reference is specified and/or no value is specified- nothing to do otherwise (if reference and value are specified): upgrade the exchange to an allocatedExchange and add the new reference exch val otherwise: if reference is specified, create an AllocatedExchange otherwise create an Exchange / ExchangeValue
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
|
required | |
dirn |
|
required | |
reference |
|
None
|
|
value |
|
None
|
|
termination |
None for reference or cutoff flows; a context for elementary flows; a valid external_ref for terminated intermediate flows. |
None
|
|
add_dups |
(False) set to true to handle "duplicate exchange" errors by cumulating their values |
False
|
Returns:
Type | Description |
---|---|
|
allocate_by_quantity(quantity)
Store a quantity for partitioning allocation. All non-reference exchanges will have their exchange values computed based on the total, determined by the quantity specified. For each reference exchange, computes the magnitude of the quantity output from the unallocated process. Reference flows lacking characterization in that quantity will receive zero allocation.
Each magnitude is the allocation numerator for that reference, and the sum of the magnitudes is the allocation denominator.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantity |
an LcQuantity (or None to remove quantity allocation) |
required |
Returns:
Type | Description |
---|---|
|
allocation_factors(quantity=None)
Returns a dict mapping reference exchange to that reference's allocation factor according to the specified allocation quantity. If no quantity is specified, the current allocation quantity is used. DOES NOT AFFECT CURRENT ALLOCATION.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
quantity |
allocation quantity |
None
|
Returns:
Type | Description |
---|---|
|
exchange_values(flow, direction=None)
Yield full exchanges matching flow specification. Flow specification required. Will only yield multiple results if there are multiple terminations for the same flow.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
|
required | |
direction |
|
None
|
Returns:
Type | Description |
---|---|
|
find_reference(spec=None, direction=None)
returns a reference exchange matching the specification.
If multiple results are found, filters out terminated exchanges
Parameters:
Name | Type | Description | Default |
---|---|---|---|
spec |
could be None, external_ref, flow, flow ref, or exchange |
None
|
|
direction |
could be helpful if the object is a non-reference exchange |
None
|
Returns:
Type | Description |
---|---|
|
inventory(ref_flow=None)
generate a process's exchanges. If no reference is supplied, generate unallocated exchanges, including all reference exchanges. If a reference is supplied AND the process is allocated with respect to that reference, generate ExchangeValues as allocated to that reference flow, and exclude reference exchanges. If a reference is supplied but the process is NOT allocated to that reference, generate unallocated ExchangeValues (excluding the reference itself). Reference must be a flow or exchange found in the process's reference entity.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
ref_flow |
|
None
|
Returns:
Type | Description |
---|---|
|
is_allocated(reference, strict=False)
Tests whether a process's exchanges contain allocation factors for a given reference.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference |
|
required | |
strict |
[False] if True, raise an exception if some (but not all) exchanges are missing allocations. |
False
|
Returns:
Type | Description |
---|---|
True - allocations exist; False - no allocations exist; raise MissingFactor - some allocations exist |
new(name, **kwargs)
classmethod
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
the name of the process |
required |
Returns:
Type | Description |
---|---|
|
set_reference(flow, dirn)
Exchange must already exist. fmr: If the exchange is currently terminated, the termination is removed. now: exchanges terminated to non-elementary context are now allowed
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
|
required | |
dirn |
|
required |
Returns:
Type | Description |
---|---|
|
show_inventory(reference=None)
Convenience wrapper around self.inventory() which: * sorts the exchanges by reference, then by direction * prints the exchanges to output * provides an enumeration of exchanges for interactive access = returns the exchanges as a sorted list.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
reference |
|
None
|
Returns:
Type | Description |
---|---|
|
test_allocation_consistency(flow=None, display=True)
For each non-reference item in the inventory, test that the values allocated to each reference, weighted by the reference values, sum up to the un-allocated value.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
flow |
[None] single flow to test; defaults to entire inventory |
None
|
|
display |
[True] whether to print output to the screen |
True
|
Returns:
Type | Description |
---|---|
|
MultipleReferencesFound
Bases: Exception
Whereas AmbiguousReferenceError indicates that further filtering is possible; MultipleReferencesFound indicates that there is no way to provide additional information.