@@ -22,7 +22,7 @@ import java.util.NoSuchElementException
2222
2323import scala .annotation .varargs
2424import scala .collection .mutable
25- import scala .reflect . ClassTag
25+ import scala .collection . JavaConverters . _
2626
2727import org .apache .spark .annotation .AlphaComponent
2828import org .apache .spark .ml .util .Identifiable
@@ -228,7 +228,8 @@ class StringArrayParam(parent: Params, name: String, doc: String, isValid: Array
228228
229229 override def w (value : Array [String ]): ParamPair [Array [String ]] = super .w(value)
230230
231- private [param] def wCast (value : Seq [String ]): ParamPair [Array [String ]] = w(value.toArray)
231+ /** Creates a param pair with a [[java.util.List ]] of values (for Java and Python). */
232+ def w (value : java.util.List [String ]): ParamPair [Array [String ]] = w(value.asScala.toArray)
232233}
233234
234235/**
@@ -323,13 +324,7 @@ trait Params extends Identifiable with Serializable {
323324 * Sets a parameter in the embedded param map.
324325 */
325326 protected final def set [T ](param : Param [T ], value : T ): this .type = {
326- shouldOwn(param)
327- if (param.isInstanceOf [StringArrayParam ] && value.isInstanceOf [Seq [_]]) {
328- paramMap.put(param.asInstanceOf [StringArrayParam ].wCast(value.asInstanceOf [Seq [String ]]))
329- } else {
330- paramMap.put(param.w(value))
331- }
332- this
327+ set(param -> value)
333328 }
334329
335330 /**
@@ -339,6 +334,15 @@ trait Params extends Identifiable with Serializable {
339334 set(getParam(param), value)
340335 }
341336
337+ /**
338+ * Sets a parameter in the embedded param map.
339+ */
340+ protected final def set (paramPair : ParamPair [_]): this .type = {
341+ shouldOwn(paramPair.param)
342+ paramMap.put(paramPair)
343+ this
344+ }
345+
342346 /**
343347 * Optionally returns the user-supplied value of a param.
344348 */
0 commit comments