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


C# Function.Filter方法代码示例

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


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

示例1: EventBubbleCorerctlyForFunctionWithReducedArgument

        [Category(TestCategory.Jira)] //TOOLS-4934
        public void EventBubbleCorerctlyForFunctionWithReducedArgument()
        {
            IFunction function = new Function
                                     {
                                         Arguments = {new Variable<int>("x1"), new Variable<int>("x2")},
                                         Components = {new Variable<int>("f")}
                                     };

            function[0, 1] = new[] {1};
            function[0, 2] = new[] {2};
            function[1, 1] = new[] {3};
            function[1, 2] = new[] {4};

            var arg1 = function.Arguments[0];

            var filteredFunction = function.Filter(new VariableValueFilter<int>(arg1, 0), new VariableReduceFilter(arg1));
            
            int called = 0;

            filteredFunction.ValuesChanged += (s, e) => called++;

            function[0, 2] = 3; //set value

            Assert.AreEqual(1, called);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:FunctionTest.cs

示例2: FilterFunction

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

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

            x.SetValues(new[] { 1.0, 2.0, 3.0 });
            y.SetValues(new[] { 10.0, 20.0 });

            f.Components[0].Values[1, 1] = 100.0;
            f.Components[1].Values[1, 1] = 200.0;

            // fx       10.0  20.0 
            //          ------------
            //    1.0  | 0.0    0.0
            //    2.0  | 0.0  100.0 
            //    3.0  | 0.0    0.0
            //
            // fy       10.0  20.0 
            //          ------------
            //    1.0  | 0.0    0.0
            //    2.0  | 0.0  200.0 
            //    3.0  | 0.0    0.0

            var filteredFunction = f.Filter(x.CreateValueFilter(2.0), y.CreateValueFilter(20.0));

            Assert.AreEqual(2, filteredFunction.Components.Count);
            Assert.AreEqual(2, filteredFunction.Arguments.Count);

            Assert.AreEqual(1, filteredFunction.Arguments[0].Values.Count);
            Assert.AreEqual(1, filteredFunction.Arguments[1].Values.Count);
            Assert.AreEqual(1, filteredFunction.Components[0].Values.Count);
            Assert.AreEqual(1, filteredFunction.Components[1].Values.Count);

            Assert.AreEqual(100.0, filteredFunction.Components[0].Values[0]);
            Assert.AreEqual(200.0, filteredFunction.Components[1].Values[0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:44,代码来源:FunctionFilterTest.cs

示例3: BindToFilteredFuntion

        public void BindToFilteredFuntion()
        {
            //setup a 2D function and fix one dimension
            IFunction function = new Function();
            IVariable<int> x = new Variable<int>();

            function.Arguments.Add(x);
            function.Arguments.Add(new Variable<int>("Y"));
            function.Components.Add(new Variable<int>());

            function[0, 0] = 2;
            function[0, 1] = 3;
            function[1, 0] = 1;
            function[1, 1] = 4;

            IFunction filteredFunction = function.Filter(new VariableValueFilter<int>(x, 0));

            ILineChartSeries lineChartSeries = ChartSeriesFactory.CreateLineSeries();
            var variable = filteredFunction.Arguments[1];
            var component = filteredFunction.Components[0]; 
            
            lineChartSeries.XValuesDataMember = variable.DisplayName;
            lineChartSeries.YValuesDataMember = component.DisplayName;

            var functionBindingList = new FunctionBindingList(filteredFunction);
            lineChartSeries.DataSource = functionBindingList;
            while (functionBindingList.IsProcessing)
            {
                Application.DoEvents();
            }

            Assert.AreEqual(2, lineChartSeries.XValues.Count);
            Assert.AreEqual(2, lineChartSeries.YValues.Count);
            Assert.AreEqual(0.0, lineChartSeries.XValues[0]);
            Assert.AreEqual(1.0, lineChartSeries.XValues[1]);
            Assert.AreEqual(2.0, lineChartSeries.YValues[0]);
            Assert.AreEqual(3.0, lineChartSeries.YValues[1]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:38,代码来源:TeeChartSeriesDecoratorTest.cs

示例4: GetValuesOfFilteredFunction

        public void GetValuesOfFilteredFunction()
        {
            IFunction function = new Function();
            function.Components.Add(new Variable<int>());
            function.Arguments.Add(new Variable<int>());
            function[0] = 1;
            function[1] = 2;
            function[2] = 3;


            IFunction filtered =
                function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] {0, 1}));

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

示例5: FilterUsingComponent

        public void FilterUsingComponent()
        {
            IFunction f = new Function();
            IVariable c1 = new Variable<int>("c1");
            IVariable c2 = new Variable<int>("c2");
            IVariable x = new Variable<int>("x");
            IVariable y = new Variable<int>("y");
            f.Components.Add(c1);
            f.Components.Add(c2);
            f.Arguments.Add(x);
            f.Arguments.Add(y);

            f.SetValues(
                new[] { 100, 200 },
                new VariableValueFilter<int>(x, new[] { 1, 2, 3, 4, 5 }),
                new VariableValueFilter<int>(y, new[] { 1, 2, 3 })
                );

            IFunction filtered = f.Filter(new ComponentFilter(c1));

            IMultiDimensionalArray<int> values = filtered.GetValues<int>(new VariableValueFilter<int>(x, new[] { 1, 2, 3 }));

            Assert.IsTrue(values.Shape.SequenceEqual(new[] { 3, 3 }));
            Assert.AreEqual(100, values[2, 2]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FunctionFilterTest.cs

示例6: FilteredFunctionArgumentInterpolationAndExtrapolationTakenFromParent

        public void FilteredFunctionArgumentInterpolationAndExtrapolationTakenFromParent()
        {
            IFunction function = new Function();
            function.Components.Add(new Variable<int>());
            function.Arguments.Add(new Variable<int>{InterpolationType = InterpolationType.Constant});
            function.Arguments[0].ExtrapolationType = ExtrapolationType.Linear;
            function[0] = 1;
            function[1] = 2;

            IFunction filtered =
                function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 0, 1 }));

            Assert.AreEqual(InterpolationType.Constant, filtered.Arguments[0].InterpolationType);
            Assert.AreEqual(ExtrapolationType.Linear, filtered.Arguments[0].ExtrapolationType);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:FunctionFilterTest.cs

示例7: SettingNoDataValuesOfFilteredFunctionGivesException

 public void SettingNoDataValuesOfFilteredFunctionGivesException()
 {
     IFunction function = new Function();
     function.Components.Add(new Variable<int>());
     function.Arguments.Add(new Variable<int>());
     function[0] = 1;
     function[1] = 2;
     function[2] = 3;
     function.Components[0].NoDataValue = 79;
     var filtered = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 0, 1 }));
     filtered.Components[0].NoDataValue = 88;
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:12,代码来源:FunctionFilterTest.cs

示例8: NoDataValuesOfFilteredFunction

 [Category(TestCategory.Jira)] //TOOLS-4258
 public void NoDataValuesOfFilteredFunction()
 {
     IFunction function = new Function();
     function.Components.Add(new Variable<int>());
     function.Arguments.Add(new Variable<int>());
     function[0] = 1;
     function[1] = 2;
     function[2] = 3;
     function.Components[0].NoDataValue = 79;
     var filtered = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 0, 1 }));
     Assert.AreEqual(79, filtered.Components[0].NoDataValue);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:13,代码来源:FunctionFilterTest.cs

示例9: ClearSourceFunctionShouldClearFilteredBindingList

        public void ClearSourceFunctionShouldClearFilteredBindingList()
        {
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x")},
                Components = { new Variable<int>("f") }
            };

            function[1] = 1;
            function[2] = 4;

            var filteredFunction = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 1 }));

            IFunctionBindingList functionBindingList = new FunctionBindingList { Function = filteredFunction };

            functionBindingList.Count
                .Should().Be.EqualTo(1);

            function.Clear();

            functionBindingList.Count
                .Should().Be.EqualTo(0);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:23,代码来源:FunctionBindingListTest.cs

示例10: Filtered2DFunction

        public void Filtered2DFunction()
        {
            IFunction function = new Function
                                     {
                                         Arguments = { new Variable<int>("x"), new Variable<int>("y") },
                                         Components = {new Variable<int>("f")}
                                     };

            function[1, 1] = 1;
            function[1, 2] = 2;
            function[2, 1] = 3;
            function[2, 2] = 4;

            var filteredFunction = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[]{1}));

            IFunctionBindingList functionBindingList = new FunctionBindingList { Function = filteredFunction };

            functionBindingList.Count
                .Should().Be.EqualTo(2);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:20,代码来源:FunctionBindingListTest.cs

示例11: PropertyChangeBubbleCorerctlyForFilteredFunction

        [Category(TestCategory.WorkInProgress)] //TOOLS-
        public void PropertyChangeBubbleCorerctlyForFilteredFunction()
        {
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x1"), new Variable<int>("x2") },
                Components = { new Variable<int>("f") }
            };

            function[0, 1] = new[] { 1 };
            function[0, 2] = new[] { 2 };
            function[1, 1] = new[] { 3 };
            function[1, 2] = new[] { 4 };

            var arg1 = function.Arguments[0];

            var filteredFunction = function.Filter(new VariableValueFilter<int>(arg1, 0), new VariableReduceFilter(arg1));

            int called = 0;

            ((INotifyPropertyChange)filteredFunction).PropertyChanged += (s, e) => called++;

            filteredFunction[0] = 3; //set value

            Assert.AreEqual(2, called); // Expect IsEditing is changed twice (true, false)
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:26,代码来源:FunctionTest.cs

示例12: SetFunctionValuesUsingFilteredFunction

        public void SetFunctionValuesUsingFilteredFunction()
        {
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x") },
                Components = { new Variable<int>("f1"), new Variable<int>("f2") }
            };

            function[1] = new[] { 1, 10 };
            function[2] = new[] { 2, 20 };

            var filteredFunction = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] { 2 }));

            var f1ValueChangeCount = 0;
            filteredFunction.Components[0].ValuesChanged += delegate { f1ValueChangeCount++; };

            // replace value
            filteredFunction.Components[0].Values[0] = 3;

            function.Components[0].Values.Cast<int>()
                .Should().Have.SameSequenceAs(new[] {1, 3});

            function.Components[1].Values.Cast<int>()
                .Should().Have.SameSequenceAs(new[] { 10, 20 });

            f1ValueChangeCount
                .Should().Be.EqualTo(1);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:28,代码来源:FunctionTest.cs

示例13: FilteredFunctionStore

        public void FilteredFunctionStore()
        {
            IFunction function = new Function { Arguments = { new Variable<int>("x") }, Components = { new Variable<int>("y") } };

            function[1] = 1;
            function[2] = 2;

            var store = function.Store;
            
            var filteredFunction = function.Filter(new VariableValueFilter<int>(function.Arguments[0], new[] {2}));

            filteredFunction.Store
                .Should().Be.EqualTo(store);

            store.Functions.Count
                .Should("Filtered functions not added to store").Be.EqualTo(3);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:FunctionTest.cs

示例14: EventShouldNotBubbleIfFunctionOutsideReducedFunctionIsRemoved

        public void EventShouldNotBubbleIfFunctionOutsideReducedFunctionIsRemoved()
        {
            int called = 0;
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x1"), 
                    new Variable<int>("x2") },
                Components = { new Variable<int>("f") }
            };

            function[0, 1] = new[] { 1 };
            function[0, 2] = new[] { 2 };
            function[1, 1] = new[] { 3 };
            function[1, 2] = new[] { 4 };

            var arg1 = function.Arguments[0];

            var filteredFunction = function.Filter(new VariableValueFilter<int>(arg1, 0), new VariableReduceFilter(arg1));

            filteredFunction.ValuesChanged += (s, e) => called++;

            function.Arguments[0].Values.Remove(1);
            Assert.AreEqual(0, called, "Removing unrelated argument value: should not fire events");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:24,代码来源:FunctionTest.cs

示例15: EventShouldNotBubbleIfReducedFunctionIsUnaffected

        public void EventShouldNotBubbleIfReducedFunctionIsUnaffected()
        {
            int called = 0;
            IFunction function = new Function
            {
                Arguments = { new Variable<int>("x1"), 
                    new Variable<int>("x2") },
                Components = { new Variable<int>("f") }
            };

            function[0, 1] = new[] { 1 };
            function[0, 2] = new[] { 2 };
            function[1, 1] = new[] { 3 };
            function[1, 2] = new[] { 4 };

            var arg1 = function.Arguments[0];

            var filteredFunction = function.Filter(new VariableValueFilter<int>(arg1, 0), new VariableReduceFilter(arg1));
            
            filteredFunction.ValuesChanged += (s, e) => called++;

            called = 0;
            function[1, 1] = 55; //set value
            Assert.AreEqual(0, called, "Filtered function should be unaffected: should not fire events");

            called = 0;
            function[0, 1] = 3; //set value
            Assert.AreEqual(1, called, "Filtered function should be affected: should fire events");
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:29,代码来源:FunctionTest.cs


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