Exemplo n.º 1
0
def test_combined_production_repair_distributions():
    original = {
        'exchanges': [{
            'amount': 1,
            'type': 'reference product',
        }, {
            'type': 'to environment',
            'amount': 1.0,
            'formula': "first * 2",
            'uncertainty': {
                'type': 'lognormal',
                'mu': 0,
                'variance with pedigree matrix': 0.15
            }
        }],
        'parameters': [{
            'variable': 'first',
            'amount': 0,
        }]
    }
    expected = [{
        'exchanges': [{
            'amount': 1,
            'type': 'reference product',
        }, {
            'type': 'to environment',
            'amount': 0,
            'formula': "first * 2",
        }],
        'parameters': [{
            'variable': 'first',
            'amount': 0,
        }]
    }]
    assert combined_production(original) == expected
Exemplo n.º 2
0
def test_combined_production_zero_exchanges(no_recalculate):
    given = {
        'exchanges': [{
            'type': 'reference product',
            'amount': 2,
            'variable': "first",
        }, {
            'type': 'reference product',
            'amount': 3,
            'variable': 'second'
        }, {
            'type': 'reference product',
            'amount': 0,
            'variable': 'third',
        }, {
            'type': 'from technosphere'
        }, {
            'type': 'to environment'
        }]
    }
    expected = [{
        'exchanges': [{
            'type': 'reference product',
            'amount': 2,
            'variable': 'first',
        }, {
            'type': 'dropped product',
            'amount': 0,
            'variable': 'second',
        }, {
            'type': 'dropped product',
            'amount': 0,
            'variable': 'third',
        }, {
            'type': 'from technosphere'
        }, {
            'type': 'to environment'
        }]
    }, {
        'exchanges': [{
            'type': 'reference product',
            'amount': 3,
            'variable': 'second',
        }, {
            'type': 'dropped product',
            'amount': 0,
            'variable': 'first',
        }, {
            'type': 'dropped product',
            'amount': 0,
            'variable': 'third',
        }, {
            'type': 'from technosphere'
        }, {
            'type': 'to environment'
        }]
    }]
    original = deepcopy(given)
    assert combined_production(given) == expected
    assert original == given
Exemplo n.º 3
0
def test_combined_production(no_recalculate):
    given = {
        'name': 'a',
        'location': 'b',
        'exchanges': [
            {
                'type': 'reference product',
                'amount': 2,
                'variable': "first",
                'name': 'foo',
            }, {
                'type': 'reference product',
                'amount': 3,
                'variable': 'second',
                'name': 'bar',
            },
            {'type': 'from technosphere'},
            {'type': 'to environment'}
        ]
    }
    expected = [{
        'name': 'a',
        'location': 'b',
        'exchanges': [
            {
                'type': 'reference product',
                'amount': 2,
                'variable': 'first',
                'name': 'foo',
            }, {
                'type': 'dropped product',
                'amount': 0,
                'variable': 'second',
                'name': 'bar',
            },
            {'type': 'from technosphere'},
            {'type': 'to environment'}
        ]
    }, {
        'name': 'a',
        'location': 'b',
        'exchanges': [{
                'type': 'reference product',
                'amount': 3,
                'variable': 'second',
                'name': 'bar',
            }, {
                'type': 'dropped product',
                'amount': 0,
                'variable': 'first',
                'name': 'foo',
            },
            {'type': 'from technosphere'},
            {'type': 'to environment'}
        ]
    }]
    original = deepcopy(given)
    assert combined_production(given) == expected
    assert original == given
Exemplo n.º 4
0
def test_combined_production_without_byproducts():
    expected = [{
        'name': 'a',
        'location': 'b',
        'exchanges': [{
            'type': 'reference product',
            'amount': 2,
            'variable': 'first',
            'name': '',
        }, {
            'type': 'dropped product',
            'amount': 0.0,
            'variable': 'second',
            'name': '',
        }, {
            'amount': ((2 + 0) * 10) * 2,
            'formula': 'some_parameter * 2',
            'type': 'from technosphere',
        }, {
            'amount': ((2 + 0) * 10) / 2,
            'formula': 'some_parameter / 2',
            'type': 'to environment',
        }],
        'parameters': [{
            'amount': 20.0,
            'formula': '(first + second) * 10',
            'variable': 'some_parameter',
        }]
    }, {
        'name': 'a',
        'location': 'b',
        'exchanges': [{
            'type': 'reference product',
            'amount': 3,
            'variable': 'second',
            'name': '',
        }, {
            'type': 'dropped product',
            'amount': 0.0,
            'variable': 'first',
            'name': '',
        }, {
            'amount': ((0 + 3) * 10) * 2,
            'formula': 'some_parameter * 2',
            'type': 'from technosphere',
        }, {
            'amount': ((0 + 3) * 10) / 2,
            'formula': 'some_parameter / 2',
            'type': 'to environment',
        }],
        'parameters': [{
            'amount': ((0 + 3) * 10),
            'formula': '(first + second) * 10',
            'variable': 'some_parameter',
        }]
    }]
    original = deepcopy(cp_dataset)
    assert combined_production(cp_dataset) == expected
    assert original == cp_dataset
Exemplo n.º 5
0
def test_combined_production_without_byproducts():
    expected = [{
        'exchanges': [{
            'type': 'reference product',
            'amount': 2,
            'variable': 'first',
        }, {
            'type': 'dropped product',
            'amount': 0.0,
            'variable': 'second',
        }, {
            'amount': ((2 + 0) * 10) * 2,
            'formula': 'some_parameter * 2',
            'type': 'from technosphere',
        }, {
            'amount': ((2 + 0) * 10) / 2,
            'formula': 'some_parameter / 2',
            'type': 'to environment',
        }],
        'parameters': [{
            'amount': 20.0,
            'formula': '(first + second) * 10',
            'variable': 'some_parameter',
        }]
    }, {
        'exchanges': [{
            'type': 'reference product',
            'amount': 3,
            'variable': 'second',
        }, {
            'type': 'dropped product',
            'amount': 0.0,
            'variable': 'first',
        }, {
            'amount': ((0 + 3) * 10) * 2,
            'formula': 'some_parameter * 2',
            'type': 'from technosphere',
        }, {
            'amount': ((0 + 3) * 10) / 2,
            'formula': 'some_parameter / 2',
            'type': 'to environment',
        }],
        'parameters': [{
            'amount': ((0 + 3) * 10),
            'formula': '(first + second) * 10',
            'variable': 'some_parameter',
        }]
    }]
    original = deepcopy(cp_dataset)
    assert combined_production(cp_dataset) == expected
    assert original == cp_dataset
Exemplo n.º 6
0
def test_combined_production_repair_distributions():
    original = {
        'name': 'a',
        'location': 'b',
        'exchanges': [{
            'amount': 1,
            'type': 'reference product',
            'name': '',
        }, {
            'type': 'to environment',
            'amount': 1.0,
            'formula': "first * 2",
            'uncertainty': {
                'type': 'lognormal',
                'mu': 0,
                'variance with pedigree matrix': 0.15
            }
        }],
        'parameters': [{
            'variable': 'first',
            'amount': 0,
        }]
    }
    expected = [{
        'name': 'a',
        'location': 'b',
        'exchanges': [{
            'amount': 1,
            'type': 'reference product',
            'name': '',
        }, {
            'type': 'to environment',
            'amount': 0,
            'formula': "first * 2",
        }],
        'parameters': [{
            'variable': 'first',
            'amount': 0,
        }]
    }]
    assert combined_production(original) == expected