public static HyperParamValues<?> fromConfig(Config config, String key) {
    switch (config.getValue(key).valueType()) {
      case LIST:
        List<String> stringValues = config.getStringList(key);
        // Have to distinguish int and double manually
        try {
          return range(Integer.parseInt(stringValues.get(0)),
                       Integer.parseInt(stringValues.get(1)));
        } catch (NumberFormatException nfe) {
          // continue
        }
        try {
          return range(Double.parseDouble(stringValues.get(0)),
                       Double.parseDouble(stringValues.get(1)));
        } catch (NumberFormatException nfe) {
          // continue
        }
        return unorderedFromValues(stringValues);
      case STRING:
      case NUMBER:
        // Have to distinguish int and double manually
        String stringValue = config.getString(key);
        try {
          return fixed(Integer.parseInt(stringValue));
        } catch (NumberFormatException nfe) {
          // continue
        }
        try {
          return fixed(Double.parseDouble(stringValue));
        } catch (NumberFormatException nfe) {
          // continue
        }
        return unorderedFromValues(Collections.singletonList(stringValue));
      default:
        throw new IllegalArgumentException("No valid parameter range for key " + key);
    }
  }
public static HyperParamValues < ? > fromConfig ( Config config , String key ) { switch ( config . getValue ( key ) . valueType ( ) ) { case LIST : List < String > stringValues = config . getStringList ( key ) ; try { return range ( Integer . parseInt ( stringValues . get ( 0 ) ) , Integer . parseInt ( stringValues . get ( 1 ) ) ) ; } catch ( NumberFormatException nfe ) { } try { return range ( Double . parseDouble ( stringValues . get ( 0 ) ) , Double . parseDouble ( stringValues . get ( 1 ) ) ) ; } catch ( NumberFormatException nfe ) { } return unorderedFromValues ( stringValues ) ; case STRING : case NUMBER : String stringValue = config . getString ( key ) ; try { return fixed ( Integer . parseInt ( stringValue ) ) ; } catch ( NumberFormatException nfe ) { } try { return fixed ( Double . parseDouble ( stringValue ) ) ; } catch ( NumberFormatException nfe ) { } return unorderedFromValues ( Collections . singletonList ( stringValue ) ) ; default : throw new IllegalArgumentException ( "No valid parameter range for key " + key ) ; } }
@param config application configuration
@param key config key to access
@return a {@link HyperParamValues} appropriate to the value. If an {@code int} or
{@code double}, returns {@link #fixed(int)} or {@link #fixed(double)} respectively.
If a {@code List<int>} or {@code List<double>}, returns {@link #range(int,int)} or
{@link #range(double,double)} respectively.