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


C# Variable.Filter方法代码示例

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


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

示例1: FilterIndependend

 public void FilterIndependend()
 {
     IVariable<int> x = new Variable<int>();
     x.SetValues(new[]{1,2,3,4,5,6,7,8,9,10});
     //select two ranges ..from [1..3] and [7..9]
     IList<Pair<int, int>> indexRanges= new List<Pair<int, int>>();
     indexRanges.Add(new Pair<int, int>(0,2));
     indexRanges.Add(new Pair<int, int>(6,8));
     IVariable<int> filteredX = (IVariable<int>) x.Filter(new VariableIndexRangesFilter(x, indexRanges));
     Assert.AreEqual(6, filteredX.Values.Count);
     Assert.IsTrue(new[]{1,2,3,7,8,9}.SequenceEqual(filteredX.Values));
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:12,代码来源:VariableIndexRangesTest.cs

示例2: VariableValueRanges

 public void VariableValueRanges()
 {
     IVariable<int> x = new Variable<int>();
     x.SetValues(new[]{1,2,3,4,5,6,7,8,9,10});
     //select two ranges ..from [1..3] and [7.8]
     IList<Pair<int,int>> ranges = new List<Pair<int, int>>();
     ranges.Add(new Pair<int, int>(1,3));
     ranges.Add(new Pair<int, int>(7,8));
     x = (IVariable<int>)x.Filter(new VariableValueRangesFilter<int>(x,ranges));
     Assert.AreEqual(5, x.Values.Count);
     Assert.AreEqual(new[] { 1, 2, 3, 7, 8}, x.Values.ToArray());
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:12,代码来源:VariableValueRangesTest.cs

示例3: FilterDependendVariableWithMultipleValues

 public void FilterDependendVariableWithMultipleValues()
 {
     IVariable<int> x = new Variable<int>("x");
     IVariable<int> y = new Variable<int>("y");
     x.Arguments.Add(y);
     x[0] = 1;
     x[1] = 2;
     x[2] = 3;
     x[3] = 4;
     Assert.AreEqual(4, x.Values.Count);
     IVariable<int> filteredX = (IVariable<int>)x.Filter(new VariableValueFilter<int>(y, new[] { 0, 2 }));
     Assert.AreEqual(2, filteredX.Values.Count);
     Assert.AreEqual(1, filteredX.Values[0]);
     Assert.AreEqual(3, filteredX.Values[1]);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:VariableValueFilterTest.cs

示例4: FilterDependendVariable

        public void FilterDependendVariable()
        {
            //int sa = componentArrays.Aggregate(1, (product, item) => (product *= item.Count));
            IVariable<double> y = new Variable<double>("y");
            IVariable<double> x = new Variable<double>("x");

            y.Arguments.Add(x);

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

            var filtered = y.Filter(x.CreateValueFilter(2.0));

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

示例5: SimpleReduce

 public void SimpleReduce()
 {
     IVariable<int> x = new Variable<int>("x");
     IVariable<int> y = new Variable<int>("y");
     IVariable<int> fx = new Variable<int>("fx");
     fx.Arguments.Add(x);
     fx.Arguments.Add(y);
     
     x.SetValues(new[] {1, 2, 3});
     y.SetValues(new[] {1});
     fx[3, 1] = 20;
     
     var reducedFunction = fx.Filter(new VariableValueFilter<int>(y, 1), new VariableReduceFilter(y));
     Assert.AreEqual(1, reducedFunction.Arguments.Count);
     Assert.AreEqual(3, reducedFunction.Values.Count);
     Assert.AreEqual(20, reducedFunction.Values[2]);
 }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:VariableReduceFilterTest.cs

示例6: FilterDependend

        public void FilterDependend()
        {
            IVariable<int> y = new Variable<int>();
            IVariable<int> x = new Variable<int>();
            y.Arguments.Add(x);

            x.SetValues(new[] {1, 2, 3, 4, 5, 6, 7, 8, 9, 10});
            y[2] = 10;
            y[8] = 10;
            //select two ranges ..from [1..3] and [7..9]
            IList<Pair<int, int>> indexRanges = new List<Pair<int, int>>();
            indexRanges.Add(new Pair<int, int>(0, 2));
            indexRanges.Add(new Pair<int, int>(6, 8));
            IVariable<int> filteredY = (IVariable<int>) y.Filter(new VariableIndexRangesFilter(x, indexRanges));
            Assert.AreEqual(6, filteredY.Values.Count);
            Assert.IsTrue(new[] {0, 10, 0, 0, 10, 0}.SequenceEqual(filteredY.Values));
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:VariableIndexRangesTest.cs

示例7: ReduceFitlterShouldPassIsEditableProperty

        public void ReduceFitlterShouldPassIsEditableProperty()
        {
            IVariable<int> x = new Variable<int>("x"){IsEditable = false};
            IVariable<int> y = new Variable<int>("y");
            IVariable<int> fx = new Variable<int>("fx");
            fx.Arguments.Add(x);
            fx.Arguments.Add(y);

            x.SetValues(new[] { 1, 2, 3 });
            y.SetValues(new[] { 1 });
            fx[3, 1] = 20;

            var reducedFunction = fx.Filter(new VariableReduceFilter(y));
            Assert.AreEqual(1, reducedFunction.Arguments.Count);
            Assert.AreEqual("x", reducedFunction.Arguments[0].Name);
            Assert.IsFalse(reducedFunction.Arguments[0].IsEditable);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:17,代码来源:VariableReduceFilterTest.cs

示例8: FilterIndependendVariable

        public void FilterIndependendVariable()
        {
            IVariable<int> x = new Variable<int>();
            x.SetValues(new[] { 1, 2, 3, 4, 5 });

            //filter out the middle 
            var filtered = x.Filter(x.CreateValuesFilter(new[] { 2, 3, 4 }));

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

示例9: GetValueOfFilteredFunctionUsingValueOfFiltererArgument

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

            y.Arguments.Add(x);

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

            var filtered = y.Filter(x.CreateValueFilter(2.0));
            
            //arguments of filtered functions are ignored!
            Assert.IsNull(filtered[3.0]);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:15,代码来源:FunctionFilterTest.cs

示例10: FilterFilteredFunction

        public void FilterFilteredFunction()
        {
            IVariable<int> x = new Variable<int>();
            x.SetValues(new[] { 1, 2, 3, 4, 5 });

            var filtered = x.Filter(x.CreateValuesFilter(new[] { 2, 3, 4 }));

            var filtered2 = filtered.Filter(x.CreateValueFilter(3));

            Assert.AreEqual(3, filtered.Values.Count);
            Assert.IsTrue(filtered.Values.Cast<int>().SequenceEqual(new[] { 2, 3, 4 }));

            Assert.AreEqual(1, filtered2.Values.Count);
            Assert.AreEqual(3, filtered2.Values[0]);

            // change filters
            ((IVariableValueFilter)filtered2.Filters[0]).Values.Add(5);
            ((IVariableValueFilter)filtered2.Filters[0]).Values.Add(4);
            Assert.AreEqual(2, filtered2.Values.Count);

            // expanding filter in the "filtered" will also expand "filtered2"
            ((IVariableValueFilter)filtered.Filters[0]).Values.Add(5);
            Assert.AreEqual(4, filtered.Values.Count);
            Assert.AreEqual(3, filtered2.Values.Count);
        }
开发者ID:lishxi,项目名称:_SharpMap,代码行数:25,代码来源:FunctionFilterTest.cs

示例11: EmptyFilter

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

            y.Arguments.Add(x);

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

            var filtered = y.Filter();

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


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