jtibshirani commented on a change in pull request #2018: URL: https://github.com/apache/lucene-solr/pull/2018#discussion_r511087483
########## File path: lucene/queries/src/java/org/apache/lucene/queries/intervals/IntervalQuery.java ########## @@ -99,7 +99,7 @@ public IntervalQuery(String field, IntervalsSource intervalsSource, float pivot, private IntervalQuery(String field, IntervalsSource intervalsSource, IntervalScoreFunction scoreFunction) { Objects.requireNonNull(field, "null field aren't accepted"); Objects.requireNonNull(intervalsSource, "null intervalsSource aren't accepted"); - Objects.requireNonNull(scoreFunction, "null scoreFunction aren't accepted"); + Objects.requireNonNull(scoreFunction, "null searchStrategy aren't accepted"); Review comment: Just noticed this rename seems accidental. ########## File path: lucene/core/src/test/org/apache/lucene/util/TestVectorUtil.java ########## @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.lucene.util; + +public class TestVectorUtil extends LuceneTestCase { + + public void testBasicDotProduct() { + assertEquals(5, VectorUtil.dotProduct(new float[]{1, 2, 3}, new float[]{-10, 0, 5}), 0); + } + + public void testSelfDotProduct() { + // the dot product of a vector with itself is equal to the sum of the squares of its components + float[] v = randomVector(); + assertEquals(l2(v), VectorUtil.dotProduct(v, v), 1e-5); + } + + public void testOrthogonalDotProduct() { + // the dot product of two perpendicular vectors is 0 + float[] v = new float[2]; + v[0] = random().nextInt(100); + v[1] = random().nextInt(100); + float[] u = new float[2]; + u[0] = v[1]; + u[1] = -v[0]; + assertEquals(0, VectorUtil.dotProduct(u, v), 1e-5); + } + + public void testSelfSquareSum() { + // the l2 distance of a vector with itself is zero + float[] v = randomVector(); + assertEquals(0, VectorUtil.squareSum(v, v), 1e-5); + } + + public void testBasicSquareSum() { + assertEquals(12, VectorUtil.squareSum(new float[]{1, 2, 3}, new float[]{-1, 0, 5}), 0); + } + + public void testRandomSquareSum() { + // the MSE of a vector with its inverse is equal to four times the sum of squares of its components Review comment: Small comment: I don't think you mean MSE here since it's not a mean, it could be 'squared distance' ? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org