Search in sources :

Example 16 with ParameterRedef

use of org.openlca.core.model.ParameterRedef in project olca-modules by GreenDelta.

the class ParameterTableTest method testGloablRedef.

@Test
public void testGloablRedef() throws Exception {
    ParameterRedef redef = new ParameterRedef();
    redef.name = "inp_param";
    redef.value = 99;
    var fi = ParameterTable.interpreter(Tests.getDb(), Collections.singleton(process.id), Collections.singleton(redef));
    // global
    assertEquals(99.0, fi.eval("inp_param"), 1e-6);
    assertEquals(2 * 99.0, fi.eval("dep_param"), 1e-6);
    // local
    var scope = fi.getScope(process.id);
    assertTrue(scope.isPresent());
    assertEquals(84.0, scope.get().eval("inp_param"), 1e-6);
    assertEquals(3 * 84.0, scope.get().eval("dep_param"), 1e-6);
}
Also used : ParameterRedef(org.openlca.core.model.ParameterRedef) Test(org.junit.Test)

Example 17 with ParameterRedef

use of org.openlca.core.model.ParameterRedef in project olca-app by GreenDelta.

the class ParameterClipboard method read.

static List<ParameterRedef> read(String text) {
    if (text == null)
        return Collections.emptyList();
    String[] lines = text.toString().split("\n");
    List<ParameterRedef> list = new ArrayList<>();
    Mapper mapper = new Mapper();
    for (String line : lines) {
        String[] row = line.split("\t");
        for (int k = 0; k < row.length; k++) {
            row[k] = row[k].trim();
        }
        if (row.length > 2 && Strings.nullOrEqual(row[2], M.Amount))
            // the header row
            continue;
        ParameterRedef p = mapper.doIt(row);
        if (p != null) {
            list.add(p);
        }
    }
    return list;
}
Also used : ArrayList(java.util.ArrayList) ParameterRedef(org.openlca.core.model.ParameterRedef)

Aggregations

ParameterRedef (org.openlca.core.model.ParameterRedef)17 Parameter (org.openlca.core.model.Parameter)6 Test (org.junit.Test)5 ProjectVariant (org.openlca.core.model.ProjectVariant)4 ArrayList (java.util.ArrayList)3 ProductSystem (org.openlca.core.model.ProductSystem)3 Project (org.openlca.core.model.Project)3 ParameterRedefSet (org.openlca.core.model.ParameterRedefSet)2 AbstractZipTest (org.openlca.jsonld.AbstractZipTest)2 HashMap (java.util.HashMap)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 Before (org.junit.Before)1 ParameterDao (org.openlca.core.database.ParameterDao)1 Category (org.openlca.core.model.Category)1 Exchange (org.openlca.core.model.Exchange)1 ImpactFactor (org.openlca.core.model.ImpactFactor)1 ImpactMethod (org.openlca.core.model.ImpactMethod)1 Uncertainty (org.openlca.core.model.Uncertainty)1 Logger (org.slf4j.Logger)1