Skip to content
Snippets Groups Projects
Commit cdc7c055 authored by Xiangrui Meng's avatar Xiangrui Meng
Browse files

[SPARK-7498] [MLLIB] add varargs back to setDefault

We removed `varargs` due to Java compilation issues. That was a false alarm because I didn't run `build/sbt clean`. So this PR reverts the changes. jkbradley

Author: Xiangrui Meng <meng@databricks.com>

Closes #6320 from mengxr/SPARK-7498 and squashes the following commits:

74a7259 [Xiangrui Meng] add varargs back to setDefault
parent 6d75ed7e
No related branches found
No related tags found
No related merge requests found
......@@ -438,19 +438,18 @@ trait Params extends Identifiable with Serializable {
* @param value the default value
*/
protected final def setDefault[T](param: Param[T], value: T): this.type = {
defaultParamMap.put(param, value)
defaultParamMap.put(param -> value)
this
}
/**
* Sets default values for a list of params.
*
* Note: Java developers should use the single-parameter [[setDefault()]].
* Annotating this with varargs causes compilation failures. See SPARK-7498.
* @param paramPairs a list of param pairs that specify params and their default values to set
* respectively. Make sure that the params are initialized before this method
* gets called.
*/
@varargs
protected final def setDefault(paramPairs: ParamPair[_]*): this.type = {
paramPairs.foreach { p =>
setDefault(p.param.asInstanceOf[Param[Any]], p.value)
......@@ -559,7 +558,7 @@ final class ParamMap private[ml] (private val map: mutable.Map[Param[Any], Any])
/**
* Puts a (param, value) pair (overwrites if the input param exists).
*/
def put[T](param: Param[T], value: T): this.type = put(ParamPair(param, value))
def put[T](param: Param[T], value: T): this.type = put(param -> value)
/**
* Puts a list of param pairs (overwrites if the input params exists).
......
......@@ -81,5 +81,6 @@ public class JavaTestParams extends JavaParams {
ParamValidators.inArray(validStrings));
setDefault(myIntParam_, 1);
setDefault(myDoubleParam_, 0.5);
setDefault(myIntParam().w(1), myDoubleParam().w(0.5));
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment