-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Can allocate functional inputs - Don't allocate nonfunctional production
- Loading branch information
Showing
3 changed files
with
189 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,171 @@ | ||
from bw2io.strategies.simapro import sp_allocate_products | ||
|
||
|
||
def test_sp_allocate_products(): | ||
given = [ | ||
{ | ||
"type": "multifunctional", | ||
"exchanges": [ | ||
{ | ||
"name": "Biowaste", | ||
"unit": "kg", | ||
"comment": "Manure", | ||
"amount": 10, | ||
"uncertainty type": 0, | ||
"loc": 10, | ||
"type": "production", | ||
"functional": False, | ||
}, | ||
{ | ||
"name": "Quack", | ||
"unit": "p", | ||
"amount": 5, | ||
"uncertainty type": 0, | ||
"loc": 5, | ||
"type": "technosphere", | ||
}, | ||
{ | ||
"name": "Wool", | ||
"unit": "kg", | ||
"amount": 1000.0, | ||
"allocation": 3, | ||
"type": "production", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Strips", | ||
"unit": "kg", | ||
"amount": 2000.0, | ||
"allocation": 2, | ||
"type": "technosphere", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Viscera", | ||
"unit": "kg", | ||
"amount": 3000.0, | ||
"allocation": 0, | ||
"type": "production", | ||
"functional": True, | ||
}, | ||
], | ||
} | ||
] | ||
expected = [ | ||
{ | ||
"type": "multifunctional", | ||
"exchanges": [ | ||
{ | ||
"name": "Biowaste", | ||
"unit": "kg", | ||
"comment": "Manure", | ||
"amount": 10, | ||
"uncertainty type": 0, | ||
"loc": 10, | ||
"type": "production", | ||
"functional": False, | ||
}, | ||
{ | ||
"name": "Quack", | ||
"unit": "p", | ||
"amount": 5, | ||
"uncertainty type": 0, | ||
"loc": 5, | ||
"type": "technosphere", | ||
}, | ||
{ | ||
"name": "Wool", | ||
"unit": "kg", | ||
"amount": 1000.0, | ||
"allocation": 3, | ||
"type": "production", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Strips", | ||
"unit": "kg", | ||
"amount": 2000.0, | ||
"allocation": 2, | ||
"type": "technosphere", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Viscera", | ||
"unit": "kg", | ||
"amount": 3000.0, | ||
"allocation": 0, | ||
"type": "production", | ||
"functional": True, | ||
}, | ||
], | ||
}, | ||
{ | ||
"type": "process", | ||
"exchanges": [ | ||
{ | ||
"name": "Wool", | ||
"unit": "kg", | ||
"amount": 1000.0, | ||
"type": "production", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Biowaste", | ||
"unit": "kg", | ||
"comment": "Manure", | ||
"amount": 6., | ||
"uncertainty type": 0, | ||
"loc": 6., | ||
"type": "production", | ||
"functional": False, | ||
}, | ||
{ | ||
"name": "Quack", | ||
"unit": "p", | ||
"amount": 3., | ||
"uncertainty type": 0, | ||
"loc": 3., | ||
"type": "technosphere", | ||
}, | ||
], | ||
"name": "Wool", | ||
"reference product": "Wool", | ||
"unit": "kg", | ||
"production amount": 1000.0, | ||
}, | ||
{ | ||
"type": "process", | ||
"exchanges": [ | ||
{ | ||
"name": "Strips", | ||
"unit": "kg", | ||
"amount": 2000.0, | ||
"type": "technosphere", | ||
"functional": True, | ||
}, | ||
{ | ||
"name": "Biowaste", | ||
"unit": "kg", | ||
"comment": "Manure", | ||
"amount": 4., | ||
"uncertainty type": 0, | ||
"loc": 4., | ||
"type": "production", | ||
"functional": False, | ||
}, | ||
{ | ||
"name": "Quack", | ||
"unit": "p", | ||
"amount": 2., | ||
"uncertainty type": 0, | ||
"loc": 2., | ||
"type": "technosphere", | ||
}, | ||
], | ||
"name": "Strips", | ||
"reference product": "Strips", | ||
"unit": "kg", | ||
"production amount": 2000.0, | ||
}, | ||
] | ||
assert sp_allocate_products(given) == expected |