The Altair Community is migrating to a new platform to provide a better experience for you. In preparation for the migration, the Altair Community is on read-only mode from October 28 - November 6, 2024. Technical support via cases will continue to work as is. For any urgent requests from Students/Faculty members, please submit the form linked here

"[SOLVED] Possible error in com.rapidminer.parameter.Parameters"

UrhixidurUrhixidur Member Posts: 40 Contributor II
edited June 2019 in Help
This is the code of com.rapidminer.parameter.Parameters.setParameter(String key, String value) as of Unuk rev 708:

/**
* Sets the parameter for the given key after performing a range-check. This method returns true if the type was
* known and false if no parameter type was defined for this key.
*/
public boolean setParameter(String key, String value) {
boolean knownType = true;
if (value == null) {
keyToValueMap.remove(key);
} else {
ParameterType type = keyToTypeMap.get(key);
if (type != null) {
value = type.transformNewValue(value);
knownType = true;
}
keyToValueMap.put(key, value);
}
fireUpdate(key);
return knownType;
}
Now, note that the Javadoc states "This method returns [...] false if no parameter type was defined for this key."  But if you take a close look at the method's code, you'll see that it can *never* return false.

The fix is simple: the knownType initializer needs to be changed, and the Javadoc refined as follows:

/**
* Sets the parameter for the given key after performing a range-check.
* This method returns true if the type was known and false if no
* parameter type was defined for this key (or if the parameter type
* is no longer defined as a result of setting its value to null).
*/
public boolean setParameter(String key, String value) {
boolean knownType = false;
...
Tagged:

Answers

  • Nils_WoehlerNils_Woehler Member Posts: 463 Maven
    Hi Urhixdur,

    thanks for the report. Seems to be true, we should initialize knownType with false here. I've fixed it :)

    Best,
    Nils
Sign In or Register to comment.