Skip to content

Commit

Permalink
[SPARK-7498] [MLLIB] add varargs back to setDefault
Browse files Browse the repository at this point in the history
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 apache#6320 from mengxr/SPARK-7498 and squashes the following commits:

74a7259 [Xiangrui Meng] add varargs back to setDefault
  • Loading branch information
mengxr committed May 21, 2015
1 parent 6d75ed7 commit cdc7c05
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 3 additions & 4 deletions mllib/src/main/scala/org/apache/spark/ml/param/params.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ private void init() {
ParamValidators.inArray(validStrings));
setDefault(myIntParam_, 1);
setDefault(myDoubleParam_, 0.5);
setDefault(myIntParam().w(1), myDoubleParam().w(0.5));
}
}

0 comments on commit cdc7c05

Please sign in to comment.