private static IValueGenerator[] ConvertToValueGenerators(IEnumerable <SweepableParam> hps)
        {
            var results = new IValueGenerator[hps.Count()];

            for (int i = 0; i < hps.Count(); i++)
            {
                switch (hps.ElementAt(i))
                {
                case SweepableDiscreteParam dp:
                    var dpArgs = new DiscreteParamArguments()
                    {
                        Name   = dp.Name,
                        Values = dp.Options.Select(o => o.ToString()).ToArray()
                    };
                    results[i] = new DiscreteValueGenerator(dpArgs);
                    break;

                case SweepableFloatParam fp:
                    var fpArgs = new FloatParamArguments()
                    {
                        Name    = fp.Name,
                        Min     = fp.Min,
                        Max     = fp.Max,
                        LogBase = fp.IsLogScale,
                    };
                    if (fp.NumSteps.HasValue)
                    {
                        fpArgs.NumSteps = fp.NumSteps.Value;
                    }
                    if (fp.StepSize.HasValue)
                    {
                        fpArgs.StepSize = fp.StepSize.Value;
                    }
                    results[i] = new FloatValueGenerator(fpArgs);
                    break;

                case SweepableLongParam lp:
                    var lpArgs = new LongParamArguments()
                    {
                        Name    = lp.Name,
                        Min     = lp.Min,
                        Max     = lp.Max,
                        LogBase = lp.IsLogScale
                    };
                    if (lp.NumSteps.HasValue)
                    {
                        lpArgs.NumSteps = lp.NumSteps.Value;
                    }
                    if (lp.StepSize.HasValue)
                    {
                        lpArgs.StepSize = lp.StepSize.Value;
                    }
                    results[i] = new LongValueGenerator(lpArgs);
                    break;
                }
            }
            return(results);
        }
Exemple #2
0
 public DiscreteValueGenerator(DiscreteParamArguments args)
 {
     _args = args;
 }