BivariateLookupTableFunction extends LookupTableFunction { @Override public Number evaluate(final EvaluationContext ec) throws CelloException { final String fmt = "Cannot evaluate %s in scalar context."; throw new CelloException( String.format(fmt, BivariateLookupTableFunction.class.getSimpleName())); } BivariateLookupTableFunction(final JSONObject jsonObj); @Override boolean isValid(); @Override Number evaluate(final EvaluationContext ec); List<Double> evaluate(final Pair<Variable, Double> value); Double evaluate(final Map<Variable, Double> value); List<Double> getYDataAtIdx(final Integer idx);  }
@Test public void evaluate_MockData_ShouldBeExpectedScalar1() throws CelloException { Map<Variable, Double> args = new HashMap<>(); args.put(lut.getVariables().findCObjectByName("x"), 1.5); args.put(lut.getVariables().findCObjectByName("bin"), 1.5); assertEquals(lut.evaluate(args), 5.0, TOLERANCE); }
@Test public void evaluate_MockData_ShouldBeExpectedScalar2() throws CelloException { Map<Variable, Double> args = new HashMap<>(); args.put(lut.getVariables().findCObjectByName("x"), 3.0); args.put(lut.getVariables().findCObjectByName("bin"), 3.0); assertEquals(lut.evaluate(args), 8.0, TOLERANCE); }
@Test public void evaluate_MockData_ShouldBeExpectedScalar3() throws CelloException { Map<Variable, Double> args = new HashMap<>(); args.put(lut.getVariables().findCObjectByName("x"), 4.0); args.put(lut.getVariables().findCObjectByName("bin"), 4.0); assertEquals(lut.evaluate(args), 8.0, TOLERANCE); }
@Test public void evaluate_MockData_ShouldBeExpectedVector1() throws CelloException { Variable v = lut.getVariables().findCObjectByName("x"); Pair<Variable, Double> args = new Pair<>(v, 1.0); List<Double> result = lut.evaluate(args); assertEquals(result.get(0), 4.0, TOLERANCE); assertEquals(result.get(1), 5.0, TOLERANCE); assertEquals(result.get(2), 6.0, TOLERANCE); }
@Test public void evaluate_MockData_ShouldBeExpectedVector2() throws CelloException { Variable v = lut.getVariables().findCObjectByName("x"); Pair<Variable, Double> args = new Pair<>(v, 1.25); List<Double> result = lut.evaluate(args); assertEquals(result.get(0), 4.25, TOLERANCE); assertEquals(result.get(1), 5.25, TOLERANCE); assertEquals(result.get(2), 6.25, TOLERANCE); }