当前位置: 首页>>代码示例>>C#>>正文


C# Function.GetValues方法代码示例

本文整理汇总了C#中System.Function.GetValues方法的典型用法代码示例。如果您正苦于以下问题:C# Function.GetValues方法的具体用法?C# Function.GetValues怎么用?C# Function.GetValues使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Function的用法示例。


在下文中一共展示了Function.GetValues方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestAsArgument

        public void TestAsArgument()
        {
            IVariable<IFeatureLocation> a = new Variable<IFeatureLocation>("argument");
            IVariable<double> c1 = new Variable<double>("value");
            IVariable<string> c2 = new Variable<string>("description");

            // f = (a, p)(h)
            IFunction f = new Function("rating curve");
            f.Arguments.Add(a);
            f.Components.Add(c1);
            f.Components.Add(c2);

            SimpleFeature simpleFeature = new SimpleFeature(10.0);
            IFeatureLocation featureLocation = new FeatureLocation { Feature = simpleFeature };

            // value based argument referencing.
            f[featureLocation] = new object[] { 1.0, "jemig de pemig" };

            IMultiDimensionalArray<double> c1Value = f.GetValues<double>(new ComponentFilter(f.Components[0]),
                                                                         new VariableValueFilter<IFeatureLocation>(
                                                                             f.Arguments[0],
                                                                             new FeatureLocation
                                                                                 {Feature = simpleFeature}));

            Assert.AreEqual(1.0, c1Value[0], 1.0e-6);

            //IMultiDimensionalArray<string> c2Value = f.GetValues<string>(new ComponentFilter(f.Components[1]),
            //                                                             new VariableValueFilter<IFeatureLocation>(
            //                                                                 f.Arguments[0], featureLocation));

            //Assert.AreEqual("jemig de pemig", c2Value[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:32,代码来源:FeatureLocationTest.cs

示例2: Function2DGetValuesUsingOneArgumentValue

        public void Function2DGetValuesUsingOneArgumentValue()
        {
            IVariable<float> f = new Variable<float>("f");
            IVariable<float> x1 = new Variable<float>("x1");
            IVariable<float> x2 = new Variable<float>("x2");

            IFunction function = new Function("OneComponentTwoArguments Test");
            function.Components.Add(f);
            function.Arguments.Add(x1);
            function.Arguments.Add(x2);

            /*   x2
             *    ^
             *    |
             *    |  x  x     <=== f(x1,x2)
             *    |  x  x
             *    |  x  x
             *    | 
             *     --------> x1
             * 
             */

            function[0.0f, 0.0f] = 0.0f;
            function[1.0f, 0.0f] = 0.0f;
            function[0.0f, 1.0f] = 100.0f;
            function[1.0f, 1.0f] = 100.0f;
            function[0.0f, 2.0f] = 200.0f;
            function[1.0f, 2.0f] = 200.0f;


            // get all values
            IList allValues = function.GetValues();
            Assert.AreEqual(6, allValues.Count);

            // get values filtered by 1st argument
            IMultiDimensionalArray filteredValues1 = function.GetValues(new VariableValueFilter<float>(x1, 1.0f));

            Assert.AreEqual(x2.Values.Count, filteredValues1.Count);

            // get values filtered by 2 arguments
            IMultiDimensionalArray filteredValues2 = function.GetValues(x1.CreateValueFilter(1.0f), x2.CreateValueFilter(1.0f));

            Assert.AreEqual(1, filteredValues2.Count);
            Assert.AreEqual(100f, filteredValues2[0, 0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:45,代码来源:FunctionFilterTest.cs

示例3: Clone

        public void Clone()
        {
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");

            IFunction f = new Function { Arguments = {x}, Components = {y} };

            f[10.0] = 100.0;
            f[20.0] = 200.0;
            f[30.0] = 300.0;

            var clone = (IFunction) f.Clone();

            Assert.AreEqual(f.Name, clone.Name);
            Assert.AreEqual(f.Arguments.Count, clone.Arguments.Count);
            Assert.AreEqual(f.Components.Count, clone.Components.Count);

            var clonedValues = clone.GetValues();
            var expectedValues = f.GetValues();
            Assert.AreEqual(expectedValues, clonedValues, "values must be cloned");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:21,代码来源:FunctionTest.cs

示例4: Clear

        public void Clear()
        {
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");

            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Components.Add(y);

            f.SetValues(new[] {100.0, 200.0, 300.0}, new VariableValueFilter<double>(x, new[] {1.0, 2.0, 3.0}));

            IList values = f.GetValues();
            Assert.AreEqual(3, values.Count);

            f.Clear();
            Assert.AreEqual(0, values.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:FunctionTest.cs

示例5: SetValues

        public void SetValues()
        {
            object defaultValue = default(float);
            var f = new Variable<float>("f");
            var x1 = new Variable<float>("x1");
            var x2 = new Variable<float>("x2");

            var function = new Function("OneComponentTwoArguments Test");
            function.Components.Add(f);
            function.Arguments.Add(x1);
            function.Arguments.Add(x2);

            function[0.0f, 0.0f] = 0.0f;

            //   x1    x2     f
            //  0.0   0.0   0.0

            Assert.AreEqual(1, x1.Values.Count);


            var x2values = new[] {0.1f, 0.2f};

            // set multiple values
            function.SetValues(new[] {5.0f},
                               new VariableValueFilter<float>(x1, 1.0f), new VariableValueFilter<float>(x2, x2values));

            //   x1    x2     f
            //  0.0   0.0   0.0
            //  1.0   0.0  default
            //  0.0   0.1  default
            //  1.0   0.1   5.0
            //  0.0   0.2  default
            //  1.0   0.2   5.0

            Assert.AreEqual(2, x1.Values.Count);
            Assert.AreEqual(3, x2.Values.Count);
            Assert.AreEqual(6, function.GetValues().Count);
            Assert.AreEqual(0.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 0.0F), new VariableValueFilter<float>(x2, 0.0F))[0]);
            Assert.AreEqual(defaultValue, function.GetValues(
                                              new VariableValueFilter<float>(x1, 1.0F),
                                              new VariableValueFilter<float>(x2, 0.0F))[0]
                );
            Assert.AreEqual(defaultValue, function.GetValues(
                                              new VariableValueFilter<float>(x1, 0.0F),
                                              new VariableValueFilter<float>(x2, 0.1F))[0]
                );
            Assert.AreEqual(5.0F, function.GetValues(
                                      new VariableValueFilter<float>(x1, 1.0F),
                                      new VariableValueFilter<float>(x2, 0.1F))[0]
                );
            Assert.AreEqual(defaultValue, function.GetValues(
                                              new VariableValueFilter<float>(x1, 0.0F),
                                              new VariableValueFilter<float>(x2, 0.2F))[0]
                );
            Assert.AreEqual(5.0F, function.GetValues(
                                      new VariableValueFilter<float>(x1, 1.0F),
                                      new VariableValueFilter<float>(x2, 0.2F))[0]
                );

            function.SetValues(new[] { 6.0f }, new VariableValueFilter<float>(x1, 2.0f));
            //   x1    x2     f
            //  0.0   0.0   0.0
            //  1.0   0.0  default
            //  0.0   0.1  default
            //  1.0   0.1   5.0
            //  0.0   0.2  default
            //  1.0   0.2   5.0
            //  2.0   0.0   6.0
            //  2.0   0.1   6.0
            //  2.0   0.2   6.0
            Assert.AreEqual(x1.Values.Count, 3);
            Assert.AreEqual(x2.Values.Count, 3);
            Assert.AreEqual(function.GetValues().Count, 9);
            Assert.AreEqual(0.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 0.0F),
                                               new VariableValueFilter<float>(x2, 0.0F))[0]);
            Assert.AreEqual(defaultValue,
                            function.GetValues(new VariableValueFilter<float>(x1, 1.0F), new VariableValueFilter<float>(x2, 0.0F))[0]);
            Assert.AreEqual(defaultValue,
                            function.GetValues(new VariableValueFilter<float>(x1, 0.0F), new VariableValueFilter<float>(x2, 0.1F))[0]);
            Assert.AreEqual(5.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 1.0F),
                                               new VariableValueFilter<float>(x2, 0.1F))[0]);
            Assert.AreEqual(defaultValue,
                            function.GetValues(new VariableValueFilter<float>(x1, 0.0F), new VariableValueFilter<float>(x2, 0.2F))[0]);
            Assert.AreEqual(5.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 1.0F),
                                               new VariableValueFilter<float>(x2, 0.2F))[0]);
            Assert.AreEqual(6.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 2.0F),
                                               new VariableValueFilter<float>(x2, 0.0F))[0]);
            Assert.AreEqual(6.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 2.0F),
                                               new VariableValueFilter<float>(x2, 0.1F))[0]);
            Assert.AreEqual(6.0F,
                            function.GetValues(new VariableValueFilter<float>(x1, 2.0F),
                                               new VariableValueFilter<float>(x2, 0.2F))[0]);

            function.SetValues(new[] {3.0f},
//.........这里部分代码省略.........
开发者ID:lishxi,项目名称:_SharpMap,代码行数:101,代码来源:FunctionTest.cs

示例6: ClearFunctionBindingListShouldRemoveFunctionValues

        public void ClearFunctionBindingListShouldRemoveFunctionValues()
        {
            IFunction function = new Function();

            function.Arguments.Add(new Variable<int>("x1"));
            function.Components.Add(new Variable<string>("y1"));

            function[0] = "zero";
            function[1] = "one";
            function[2] = "two";

            var functionBindingList = new FunctionBindingList { Function = function };
            functionBindingList.Clear();

            WaitUntilLastOperationIsFinished(functionBindingList);

            Assert.AreEqual(0, function.GetValues<string>().Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:18,代码来源:FunctionBindingListTest.cs

示例7: ClearFunction_ShouldNotClearAttributes

        public void ClearFunction_ShouldNotClearAttributes()
        {
            // setup
            IVariable<double> x = new Variable<double>("x");
            IVariable<double> y = new Variable<double>("y");
            IFunction f = new Function();
            f.Arguments.Add(x);
            f.Components.Add(y);
            string kie = "kie";
            string expected = "veljoe";
            f.Attributes[kie] = expected;
            f.Components[0].Attributes[kie] = expected;

            f.SetValues(new[] { 100.0, 200.0, 300.0 }, new VariableValueFilter<double>(x, new[] { 1.0, 2.0, 3.0 }));

            // call
            f.Clear();

            // check
            Assert.AreEqual(0, f.GetValues().Count);
            var funcVal = f.Attributes[kie];
            Assert.AreEqual(expected,funcVal);
            var val = f.Components[0].Attributes[kie];
            Assert.AreEqual(expected,val);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FunctionTest.cs

示例8: BranchSegmentBoundaryAsFunctionArgument

        public void BranchSegmentBoundaryAsFunctionArgument()
        {
            // Test with only 1 FeatureVariable as argument; could be usefull as initial conditions
            Function initialFlow = new Function("initial flow");

            Variable<SimpleFeature> branchSegmentBoundaryVariable = new Variable<SimpleFeature>("cell");
            branchSegmentBoundaryVariable.AutoSort = false;
            initialFlow.Arguments.Add(branchSegmentBoundaryVariable);

            initialFlow.Components.Add(new Variable<double>("depth"));

            // save results back to Functions
            initialFlow[boundary11] = 1.0;
            initialFlow[boundary12] = 2.0;
            initialFlow[boundary13] = 3.0;
            initialFlow[boundary23] = 4.0;
            initialFlow[boundary22] = 5.0;
            initialFlow[boundary21] = 6.0;

            IList<double> values = initialFlow.GetValues<double>();
            Assert.AreEqual(1.0, values[0]);
            Assert.AreEqual(2.0, values[1]);
            Assert.AreEqual(3.0, values[2]);
            Assert.AreEqual(4.0, values[3]);
            Assert.AreEqual(5.0, values[4]);
            Assert.AreEqual(6.0, values[5]);


            values = initialFlow.GetValues<double>(new VariableValueFilter<SimpleFeature>(branchSegmentBoundaryVariable, boundary23));
            Assert.AreEqual(4.0, values[0]);

            double[] initialFlowValues = { 11, 12, 13, 14, 15, 16 }; // get from model engine
            initialFlow.SetValues(initialFlowValues);
            values = initialFlow.GetValues<double>();
            Assert.AreEqual(11.0, values[0]);
            Assert.AreEqual(12.0, values[1]);
            Assert.AreEqual(13.0, values[2]);
            Assert.AreEqual(14.0, values[3]);
            Assert.AreEqual(15.0, values[4]);
            Assert.AreEqual(16.0, values[5]);

            List<SimpleFeature> branchSegmentBoundaries2 = new List<SimpleFeature>();
            branchSegmentBoundaries2.Add(boundary21);
            branchSegmentBoundaries2.Add(boundary22);
            branchSegmentBoundaries2.Add(boundary23);
            values = initialFlow.GetValues<double>(new VariableValueFilter<SimpleFeature>(branchSegmentBoundaryVariable, branchSegmentBoundaries2));
            Assert.AreEqual(3, values.Count);
            Assert.AreEqual(14.0, values[0]);
            Assert.AreEqual(15.0, values[1]);
            Assert.AreEqual(16.0, values[2]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:51,代码来源:FeatureVariableTest.cs


注:本文中的System.Function.GetValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。