Ejemplo n.º 1
0
        public void OptionBuilder_should_work_with_random_sweeper()
        {
            var context       = new MLContext();
            var builder       = new TestOptionBuilderWithSweepableAttributeOnly();
            var maximum       = 10;
            var sweeperOption = new UniformRandomSweeper.Option();

            var randomSweeper = new UniformRandomSweeper(sweeperOption);

            foreach (var sweeperOutput in randomSweeper.ProposeSweeps(builder, maximum))
            {
                maximum -= 1;
                var option = builder.BuildFromParameters(sweeperOutput);
                option.LongOption
                .Should()
                .BeLessOrEqualTo(100)
                .And
                .BeGreaterOrEqualTo(0);

                option.FloatOption
                .Should()
                .BeLessOrEqualTo(100f)
                .And
                .BeGreaterOrEqualTo(0f);

                option.StringOption
                .Should()
                .BeOneOf(new string[] { "str1", "str2", "str3", "str4" });

                maximum.Should().BeGreaterThan(-2);
            }
        }
Ejemplo n.º 2
0
        public void OptionBuilder_should_create_default_option()
        {
            var builder = new TestOptionBuilderWithSweepableAttributeOnly();
            var option  = builder.CreateDefaultOption();

            option.LongOption.Should().Equals(10);
            option.FloatOption.Should().Equals(1f);
            option.StringOption.Should().Equals("str");
        }
Ejemplo n.º 3
0
        public void OptionBuilder_should_build_option_from_parameter_set()
        {
            var builder = new TestOptionBuilderWithSweepableAttributeOnly();
            var input   = new Dictionary <string, string>()
            {
                { "LongOption", "2" },
                { "FloatOption", "2" },
                { "StringOption", "str2" },
            };

            var option = builder.BuildFromParameters(input);

            option.LongOption.Should().Equals(2);
            option.FloatOption.Should().Equals(2f);
            option.StringOption.Should().Equals("str2");
        }
Ejemplo n.º 4
0
        public void OptionBuilder_should_build_option_using_field_with_sweepable_parameter_attribute()
        {
            var optionBuilder = new TestOptionBuilderWithSweepableAttributeOnly();
            var option1       = optionBuilder.CreateDefaultOption();

            option1.FloatOption.Should().Be(0f);
            option1.LongOption.Should().Be(0);
            option1.StringOption.Should().Be("str1");

            var input = new Dictionary <string, string>()
            {
                { "LongOption", "2" },
                { "FloatOption", "2" },
                { "StringOption", "str2" },
            };

            var option2 = optionBuilder.BuildFromParameters(input);

            option2.LongOption.Should().Equals(2);
            option2.FloatOption.Should().Equals(2f);
            option2.StringOption.Should().Equals("str2");
        }
Ejemplo n.º 5
0
        public void OptionBuilder_should_print_in_a_human_readable_format()
        {
            var optionBuilder = new TestOptionBuilderWithSweepableAttributeOnly();

            Approvals.Verify(optionBuilder);
        }