Incremental name changes; use of builder; fix in normalize

This commit is contained in:
jeffbanks
2023-06-02 12:18:18 -05:00
parent 387cef4c17
commit b9d5008c5a
11 changed files with 152 additions and 35 deletions

View File

@@ -29,7 +29,7 @@ import java.util.function.Function;
*/
@ThreadSafeMapper
@Categories(Category.experimental)
public class NormalizeDoubleVectorList implements Function<List<Double>,List<Double>> {
public class NormalizeDoubleListVector implements Function<List<Double>,List<Double>> {
@Override
public List<Double> apply(List<Double> doubles) {
ArrayList<Double> unit = new ArrayList<>(doubles.size());

View File

@@ -29,7 +29,7 @@ import java.util.function.Function;
*/
@ThreadSafeMapper
@Categories(Category.experimental)
public class NormalizeFloatVectorList implements Function<List<Float>,List<Float>> {
public class NormalizeFloatListVector implements Function<List<Float>,List<Float>> {
@Override
public List<Float> apply(List<Float> floats) {
ArrayList<Float> unit = new ArrayList<>(floats.size());

View File

@@ -29,9 +29,9 @@ import java.util.function.Function;
*/
@ThreadSafeMapper
@Categories(Category.experimental)
public class NormalizeVector implements Function<List,List> {
private final NormalizeDoubleVectorList ndv = new NormalizeDoubleVectorList();
private final NormalizeFloatVectorList nfv = new NormalizeFloatVectorList();
public class NormalizeListVector implements Function<List,List> {
private final NormalizeDoubleListVector ndv = new NormalizeDoubleListVector();
private final NormalizeFloatListVector nfv = new NormalizeFloatListVector();
@Override
public List apply(List list) {
@@ -39,7 +39,7 @@ public class NormalizeVector implements Function<List,List> {
return List.of();
} else if (list.get(0) instanceof Float) {
return nfv.apply(list);
} else if (list.get(1) instanceof Double) {
} else if (list.get(0) instanceof Double) {
return ndv.apply(list);
} else {
throw new RuntimeException("Only Doubles and Floats are recognized.");

View File

@@ -27,7 +27,7 @@ public class ToNormalizedVectorTest {
@Test
public void testNormalizeBasic() {
NormalizeDoubleVectorList normalize = new NormalizeDoubleVectorList();
NormalizeDoubleListVector normalize = new NormalizeDoubleListVector();
List<Double> normalized = normalize.apply(List.of(1.0d));
for (int i = 0; i < normalized.size(); i++) {
assertThat(normalized.get(i)).isCloseTo(1.0d, Offset.offset(0.00001d));