Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mengxr committed May 13, 2015
1 parent 83a163c commit 409ea08
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
3 changes: 3 additions & 0 deletions mllib/src/main/scala/org/apache/spark/ml/Model.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ abstract class Model[M <: Model[M]] extends Transformer {
*/
var parent: Estimator[M] = _

/**
* Sets the parent of this model (Java API).
*/
def setParent(parent: Estimator[M]): M = {
this.parent = parent
this.asInstanceOf[M]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,7 @@ trait Params extends Identifiable with Serializable {

/** Validates that the input param belongs to this instance. */
private def shouldOwn(param: Param[_]): Unit = {
require(param.parent == uid, s"Param $param does not belong to $this.")
require(param.parent == uid && hasParam(param.name), s"Param $param does not belong to $this.")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@
public class JavaTestParams extends JavaParams {

public JavaTestParams() {
this._uid = Identifiable$.MODULE$.randomUID("javaTestParams");
_init();
this.uid_ = Identifiable$.MODULE$.randomUID("javaTestParams");
init();
}

public JavaTestParams(String uid) {
this._uid = uid;
_init();
this.uid_ = uid;
init();
}

private String _uid;
private String uid_;

@Override
public String uid() {
return _uid;
return uid_;
}

public IntParam myIntParam;
Expand All @@ -63,13 +63,13 @@ public JavaTestParams setMyDoubleParam(double value) {

public Param<String> myStringParam;

public String getMyStringParam() { return (String)getOrDefault(myStringParam); }
public String getMyStringParam() { return getOrDefault(myStringParam); }

public JavaTestParams setMyStringParam(String value) {
set(myStringParam, value); return this;
}

private void _init() {
private void init() {
myIntParam = new IntParam(this, "myIntParam", "this is an int param", ParamValidators.gt(0));
myDoubleParam = new DoubleParam(this, "myDoubleParam", "this is a double param",
ParamValidators.inRange(0.0, 1.0));
Expand Down

0 comments on commit 409ea08

Please sign in to comment.