Search in sources :

Example 6 with LocalSampleCalculatorInput

use of org.opensearch.ml.common.parameter.LocalSampleCalculatorInput in project ml-commons by opensearch-project.

the class LocalSampleCalculatorTest method execute.

@Test
public void execute() {
    SampleAlgoOutput output = (SampleAlgoOutput) calculator.execute(input);
    Assert.assertEquals(6.0, output.getSampleResult().doubleValue(), 1e-5);
    input = new LocalSampleCalculatorInput("max", Arrays.asList(1.0, 2.0, 3.0));
    output = (SampleAlgoOutput) calculator.execute(input);
    Assert.assertEquals(3.0, output.getSampleResult().doubleValue(), 1e-5);
    input = new LocalSampleCalculatorInput("min", Arrays.asList(1.0, 2.0, 3.0));
    output = (SampleAlgoOutput) calculator.execute(input);
    Assert.assertEquals(1.0, output.getSampleResult().doubleValue(), 1e-5);
}
Also used : LocalSampleCalculatorInput(org.opensearch.ml.common.parameter.LocalSampleCalculatorInput) SampleAlgoOutput(org.opensearch.ml.common.parameter.SampleAlgoOutput) Test(org.junit.Test)

Example 7 with LocalSampleCalculatorInput

use of org.opensearch.ml.common.parameter.LocalSampleCalculatorInput in project ml-commons by opensearch-project.

the class LocalSampleCalculatorTest method setUp.

@Before
public void setUp() {
    calculator = new LocalSampleCalculator(client, settings);
    input = new LocalSampleCalculatorInput("sum", Arrays.asList(1.0, 2.0, 3.0));
}
Also used : LocalSampleCalculatorInput(org.opensearch.ml.common.parameter.LocalSampleCalculatorInput) Before(org.junit.Before)

Aggregations

LocalSampleCalculatorInput (org.opensearch.ml.common.parameter.LocalSampleCalculatorInput)7 Test (org.junit.Test)5 Input (org.opensearch.ml.common.parameter.Input)4 SampleAlgoOutput (org.opensearch.ml.common.parameter.SampleAlgoOutput)4 Client (org.opensearch.client.Client)2 Settings (org.opensearch.common.settings.Settings)2 MLInput (org.opensearch.ml.common.parameter.MLInput)2 ArrayList (java.util.ArrayList)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1 Data (lombok.Data)1 NoArgsConstructor (lombok.NoArgsConstructor)1 Before (org.junit.Before)1 FunctionName (org.opensearch.ml.common.parameter.FunctionName)1 Output (org.opensearch.ml.common.parameter.Output)1 Executable (org.opensearch.ml.engine.Executable)1 LocalSampleCalculator (org.opensearch.ml.engine.algorithms.sample.LocalSampleCalculator)1 Function (org.opensearch.ml.engine.annotation.Function)1