コード例 #1
0
        Tuple <IIndex <c>, VectorConstruction> IIndexBuilder.Search <c, d>(Tuple <IIndex <c>, VectorConstruction> _arg8, IVector <d> searchVector, d searchValue)
        {
            Tuple <IIndex <c>, VectorConstruction> tuple = _arg8;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <c>         index1   = tuple.Item1;
            List <c>           cList    = new List <c>();
            List <long>        longList = new List <long>();
            int index2 = 0;
            int count  = index1.Keys.Count;
            int length = (int)searchVector.Length;
            int num    = (count >= length ? length : count) - 1;

            if (num >= index2)
            {
                do
                {
                    d optionalValue = searchVector.GetValue((long)index2);
                    if ((!optionalValue.HasValue ? 0 : (LanguagePrimitives.HashCompare.GenericEqualityIntrinsic <d>((M0)optionalValue.Value, (M0)searchValue) ? 1 : 0)) != 0)
                    {
                        cList.Add(index1.Keys[index2]);
                        longList.Add((long)index2);
                    }
                    ++index2;
                }while (index2 != num + 1);
            }
            LinearIndex <c>         linearIndex      = new LinearIndex <c>(System.Array.AsReadOnly <c>(ArrayModule.OfSeq <c>((IEnumerable <c>)cList)), (IIndexBuilder)this, (FSharpOption <bool>)null);
            IEnumerable <long>      indices          = (IEnumerable <long>)SeqModule.Map <long, long>((Func <M0, M1>) new LinearIndex.range(), (IEnumerable <M0>)longList);
            RangeRestriction <long> rangeRestriction = VectorHelpers.RangeRestriction.ofSeq((long)longList.Count, indices);

            return(new Tuple <IIndex <c>, VectorConstruction>((IIndex <c>)linearIndex, VectorConstruction.NewGetRange(vectorConstruction, rangeRestriction)));
        }
コード例 #2
0
ファイル: Frame.cs プロジェクト: nh43de/deedle-cs
        public static Frame <K, string> FromRecords <K, R>(Series <K, R> series)
        {
            IEnumerable <Tuple <K, R> > tuples = (IEnumerable <Tuple <K, R> >) new FrameExtensions.keyValuePairs <K, R>(series, (Tuple <K, FSharpOption <R> >)null, (FSharpOption <R>)null, default(K), (IEnumerator <Tuple <K, FSharpOption <R> > >)null, 0, (Tuple <K, R>)null);
            Frame <int, string>         frame  = Reflection.convertRecordSequence <R>(SeqModule.Map <Tuple <K, R>, R>((FSharpFunc <M0, M1>) new FrameExtensions.recordsToConvert <K, R>(), (IEnumerable <M0>)tuples));

            return(FrameModule.IndexRowsWith <K, int, string>((IEnumerable <K>)SeqModule.Map <Tuple <K, R>, K>((FSharpFunc <M0, M1>) new FrameExtensions.FromRecords <K, R>(), (IEnumerable <M0>)tuples), frame));
        }
コード例 #3
0
        public void Visit(Ast.Expr.FuncCall f)
        {
            foreach (var e in f.Item.ExprList)
            {
                Visit(e);
            }
            if (f.Item.Decl == null)
            {
                return;
            }
            Ast.Stmt.Funcdef fd = (Ast.Stmt.Funcdef)f.Item.Decl.Value;
            // Compare param types to decl types
            var formalList      = SeqModule.ToList(fd.Item.FormalList);
            var actualList      = SeqModule.ToList(f.Item.ExprList);
            var actualAndFormal = ListModule.Zip(actualList, formalList);

            foreach (var af in actualAndFormal)
            {
                if (af.Item1.ActualType != af.Item2.Formal.Type)
                {
                    m_errorList.Add("Type Error: Cannot use actual paramater of type " + af.Item1.ActualType +
                                    " for formal paramater of type " + af.Item2.Formal.Type);
                }
            }
            f.ActualType = fd.Item.Formal.Type;
        }
コード例 #4
0
        public static Tuple <IEnumerable <T>, IEnumerable <T> > Fork <T>(this IEnumerable <T> input)
        {
            var cachedInput = SeqModule.Cache(input);

            return(Tuple.Create(
                       cachedInput.Where((val, idx) => idx % 2 == 0),
                       cachedInput.Where((val, idx) => idx % 2 == 1)));
        }
コード例 #5
0
        ReadOnlyCollection <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > > IIndexBuilder.GroupBy <K, TNewKey>(IIndex <K> index, Func <K, TNewKey> keySel, VectorConstruction vector)
        {
            IIndexBuilder builder = (IIndexBuilder)this;

            LinearIndex.windows <K, TNewKey>                 windows336 = new LinearIndex.windows <K, TNewKey>();
            ReadOnlyCollection <K>                           keys       = index.Keys;
            IEnumerable <Tuple <M1, IEnumerable <M0> > >     tuples1    = SeqModule.GroupBy <K, TNewKey>((Func <M0, M1>)keySel, (IEnumerable <M0>)keys);
            IEnumerable <Tuple <TNewKey, IEnumerable <K> > > tuples2    = (IEnumerable <Tuple <TNewKey, IEnumerable <K> > >)SeqModule.Choose <Tuple <TNewKey, IEnumerable <K> >, Tuple <TNewKey, IEnumerable <K> > >((Func <M0, FSharpOption <M1> >)windows336, (IEnumerable <M0>)tuples1);

            return(System.Array.AsReadOnly <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> >[])ArrayModule.OfSeq <Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((IEnumerable <M0>)SeqModule.Map <Tuple <TNewKey, IEnumerable <K> >, Tuple <TNewKey, Tuple <IIndex <K>, VectorConstruction> > >((Func <M0, M1>) new LinearIndex.DeedleIndicesIIndexBuilderGroupBy <K, TNewKey>(index, vector, builder), (IEnumerable <M0>)tuples2))));
        }
コード例 #6
0
        private void UpdateTextBoxes(FSharpList <LispVal> code)
        {
            sexpTextBox.Text = AnyToString(code);

            FSharpList <LispVal> codeWithPrimitives =
                ListModule.of_seq(
                    SeqModule
                    .of_list(code)
                    .Select(v => CodeGenerator.insertPrimitives(v)));

            primitivesTextBox.Text = AnyToString(codeWithPrimitives);
        }
コード例 #7
0
        Tuple <IIndex <TNewKey>, VectorConstruction> IIndexBuilder.WithIndex <K, TNewKey>(IIndex <K> index1, IVector <TNewKey> indexVector, VectorConstruction vector)
        {
            Tuple <TNewKey, long>[] array       = (Tuple <TNewKey, long>[])SeqModule.ToArray <Tuple <TNewKey, long> >((IEnumerable <M0>) new LinearIndex.newKeys <TNewKey, K>(index1, indexVector, new KeyValuePair <K, long>(), (Tuple <K, long>)null, new long(), default(K), new TNewKey(), (IEnumerator <KeyValuePair <K, long> >)null, 0, (Tuple <TNewKey, long>)null));
            LinearIndex <TNewKey>   linearIndex = new LinearIndex <TNewKey>(System.Array.AsReadOnly <TNewKey>((TNewKey[])ArrayModule.OfSeq <TNewKey>((IEnumerable <M0>)SeqModule.Map <Tuple <TNewKey, long>, TNewKey>((Func <M0, M1>) new LinearIndex.newIndex <TNewKey>(), (IEnumerable <M0>)array))), (IIndexBuilder)this, (FSharpOption <bool>)null);
            long keyCount = ((IIndex <TNewKey>)linearIndex).KeyCount;

            LinearIndex.relocations relocations5178 = new LinearIndex.relocations();
            long   lo  = 0;
            long   hi  = keyCount - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations()) : (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocations5178, (IEnumerable <M0>)obj), SeqModule.Map <Tuple <TNewKey, long>, long>((Func <M0, M1>) new LinearIndex.relocations <TNewKey>(), (IEnumerable <M0>)array));

            return(new Tuple <IIndex <TNewKey>, VectorConstruction>((IIndex <TNewKey>)linearIndex, VectorConstruction.NewRelocate(vector, (long)array.Length, tuples)));
        }
コード例 #8
0
ファイル: Ranges`1.cs プロジェクト: nh43de/deedle-cs
        public Deedle.Ranges.Ranges <T> MergeWith(IEnumerable <Deedle.Ranges.Ranges <T> > ranges)
        {
            IEnumerable <Deedle.Ranges.Ranges <T> > list = (IEnumerable <Deedle.Ranges.Ranges <T> >)SeqModule.ToList <Deedle.Ranges.Ranges <T> >((IEnumerable <M0>) new Ranges.MergeWith <T>(this, ranges, 0, (Deedle.Ranges.Ranges <T>)null));

            if (SeqModule.IsEmpty <Deedle.Ranges.Ranges <T> >((IEnumerable <M0>)list))
            {
                throw new ArgumentException("Range cannot be empty", nameof(ranges));
            }
            IRangeKeyOperations <T>    operations = ((Deedle.Ranges.Ranges <T>)SeqModule.Head <Deedle.Ranges.Ranges <T> >((IEnumerable <M0>)list)).Operations;
            FSharpList <Tuple <T, T> > fsharpList = (FSharpList <Tuple <T, T> >)ListModule.SortWith <Tuple <T, T> >((FSharpFunc <M0, FSharpFunc <M0, int> >) new Ranges.MergeWith <T>(operations), SeqModule.ToList <Tuple <T, T> >((IEnumerable <M0>) new Ranges.MergeWith <T>(list, (Deedle.Ranges.Ranges <T>)null, (IEnumerator <Deedle.Ranges.Ranges <T> >)null, (Tuple <T, T>)null, (IEnumerator <Tuple <T, T> >)null, 0, (Tuple <T, T>)null)));
            FSharpFunc <Tuple <T, T>, FSharpFunc <FSharpList <Tuple <T, T> >, IEnumerable <Tuple <T, T> > > > fsharpFunc = (FSharpFunc <Tuple <T, T>, FSharpFunc <FSharpList <Tuple <T, T> >, IEnumerable <Tuple <T, T> > > >) new Ranges.MergeWith <T>(operations);
            IRangeKeyOperations <T> ops = operations;

            return(new Deedle.Ranges.Ranges <T>((IEnumerable <Tuple <T, T> >)FSharpFunc <Tuple <T, T>, FSharpList <Tuple <T, T> > > .InvokeFast <IEnumerable <Tuple <T, T> > >((FSharpFunc <Tuple <T, T>, FSharpFunc <FSharpList <Tuple <T, T> >, M0> >)fsharpFunc, (Tuple <T, T>)ListModule.Head <Tuple <T, T> >((FSharpList <M0>)fsharpList), (FSharpList <Tuple <T, T> >)ListModule.Tail <Tuple <T, T> >((FSharpList <M0>)fsharpList)), ops));
        }
コード例 #9
0
        Tuple <IIndex <b>, VectorConstruction> IIndexBuilder.LookupLevel <b>(Tuple <IIndex <b>, VectorConstruction> _arg9, ICustomLookup <b> searchKey)
        {
            Tuple <IIndex <b>, VectorConstruction> tuple = _arg9;
            VectorConstruction vectorConstruction        = tuple.Item2;
            IIndex <b>         index = tuple.Item1;

            Tuple <long, b>[] array = (Tuple <long, b>[])SeqModule.ToArray <Tuple <long, b> >((IEnumerable <M0>) new LinearIndex.matching <b>(searchKey, index, new KeyValuePair <b, long>(), (Tuple <b, long>)null, default(b), new long(), (IEnumerator <KeyValuePair <b, long> >)null, 0, (Tuple <long, b>)null));
            long length             = (long)array.Length;

            LinearIndex.relocs relocs5601 = new LinearIndex.relocs();
            long   lo  = 0;
            long   hi  = length - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocs(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocs()) : (object)new LinearIndex.relocs(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocs());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocs5601, (IEnumerable <M0>)obj), SeqModule.Map <Tuple <long, b>, long>((Func <M0, M1>) new LinearIndex.relocs <b>(), (IEnumerable <M0>)array));

            return(new Tuple <IIndex <b>, VectorConstruction>((IIndex <b>) new LinearIndex <b>(System.Array.AsReadOnly <b>(ArrayModule.OfSeq <b>((IEnumerable <b>)SeqModule.Map <Tuple <long, b>, b>((Func <M0, M1>) new LinearIndex.newIndex <b>(), (IEnumerable <M0>)array))), (IIndexBuilder)this, FSharpOption <bool> .Some(index.IsOrdered)), VectorConstruction.NewRelocate(vectorConstruction, length, tuples)));
        }
コード例 #10
0
ファイル: Pairwise.cs プロジェクト: tekcor/vvvv-sdk
        public void Evaluate(int SpreadMax)
        {
            Output1.SliceCount = Input.SliceCount;
            Output2.SliceCount = Input.SliceCount;

            for (var spread = 0; spread < Input.SliceCount; spread++)
            {
                var pairs = SeqModule.Pairwise(Input[spread]).ToArray();

                Output1[spread].SliceCount = pairs.Length;
                Output2[spread].SliceCount = pairs.Length;

                for (var i = 0; i < pairs.Length; i++)
                {
                    var pair = pairs[i];
                    Output1[spread][i] = pair.Item1;
                    Output2[spread][i] = pair.Item2;
                }
            }
        }
コード例 #11
0
        public static FSharpOption <Tuple <FSharpOption <Bitmap>, string, FSharpList <Tuple <string, string> > > > EtiketParse(string path)
        {
            string txt    = File.ReadAllText(path, enc);
            Match  match  = regBar.Match(txt);
            Match  match2 = match;
            Match  match3 = match2;
            Match  n      = match3;

            if (n.Success)
            {
                Match  m      = match3;
                string barc   = m.Groups[1].Value;
                Match  match4 = regEtik.Match(txt);
                Match  match5 = match4;
                Match  match6 = match5;
                Match  l      = match6;
                if (l.Success)
                {
                    Match k = match6;
                    return(FSharpOption <Tuple <FSharpOption <Bitmap>, string, FSharpList <Tuple <string, string> > > > .Some(new Tuple <FSharpOption <Bitmap>, string, FSharpList <Tuple <string, string> > >(null, barc, ListModule.Zip(FSharpList <string> .Cons("mark", FSharpList <string> .Cons("sht", FSharpList <string> .Cons("pp", FSharpList <string> .Cons("fn", FSharpList <string> .Cons("rh", FSharpList <string> .Cons("posgr", FSharpList <string> .Cons("sideAndSize", FSharpList <string> .Cons("strSteelCart", FSharpList <string> .Cons("car", FSharpList <string> .Cons("sp", FSharpList <string> .Cons("customername", FSharpList <string> .Cons("orderitemname", FSharpList <string> .Cons("mon_comm", FSharpList <string> .Empty))))))))))))), ListModule.Tail(SeqModule.ToList(new EtiketParse_71(k, null, null, 0, null)))))));
                }
                Match match7 = regImp.Match(txt);
                Match match8 = match7;
                Match match9 = match8;
                Match j      = match9;
                if (j.Success)
                {
                    Match    i    = match9;
                    Bitmap   bmp  = new Bitmap(170, 170);
                    Graphics gr   = Graphics.FromImage(bmp);
                    Pen      pen  = new Pen(Color.Black, 2f);
                    Pen      penB = new Pen(Color.Black, 4f);
                    ListModule.Iterate(new EtiketParse_82_4(gr, pen, penB), SeqModule.ToList(new EtiketParse_81_5(txt, null, null, 0, null)));
                    ListModule.Iterate(new EtiketParse_99_9(gr), ListModule.Filter(new EtiketParse_98_10(), SeqModule.ToList(new EtiketParse_97_11(txt, null, null, 0, null))));
                    return(FSharpOption <Tuple <FSharpOption <Bitmap>, string, FSharpList <Tuple <string, string> > > > .Some(new Tuple <FSharpOption <Bitmap>, string, FSharpList <Tuple <string, string> > >(FSharpOption <Bitmap> .Some(bmp), barc, ListModule.Zip(FSharpList <string> .Cons("mark", FSharpList <string> .Cons("MarkBalka", FSharpList <string> .Cons("ColorCode", FSharpList <string> .Cons("SideBalka", FSharpList <string> .Cons("car", FSharpList <string> .Cons("strSteelCart", FSharpList <string> .Cons("PosGroup", FSharpList <string> .Cons("pp", FSharpList <string> .Cons("IsShtulp", FSharpList <string> .Cons("IsFalsh", FSharpList <string> .Empty)))))))))), ListModule.Tail(SeqModule.ToList(new EtiketParse_109_15(i, null, null, 0, null)))))));
                }
                return(null);
            }
            return(null);
        }
コード例 #12
0
        Tuple <IIndex <TNewKey>, IVector <R> > IIndexBuilder.Resample <K, TNewKey, R>(IIndexBuilder chunkBuilder, IIndex <K> index, IEnumerable <K> keys, Deedle.Direction dir, VectorConstruction vector, Func <Tuple <K, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > selector)
        {
            if (!index.IsOrdered)
            {
                throw new InvalidOperationException("Resampling is only supported on ordered indices");
            }
            IIndexBuilder    indexBuilder = (IIndexBuilder)this;
            IEnumerable <M1> m1s;

            if (dir == Deedle.Direction.Forward)
            {
                IEnumerable <Tuple <K, long> > tuples = (IEnumerable <Tuple <K, long> >)SeqModule.Map <K, Tuple <K, long> >((Func <M0, M1>) new LinearIndex.keyLocations <K>(index), keys);
                m1s = SeqModule.MapIndexed <Tuple <Tuple <K, long>, Tuple <K, long> >, Tuple <K, Tuple <long, long> > >((Func <int, Func <M0, M1> >) new LinearIndex.locations <K>(index), (IEnumerable <M0>)SeqModule.Pairwise <Tuple <K, long> >(SeqModule.Append <Tuple <K, long> >((IEnumerable <M0>)tuples, (IEnumerable <M0>)FSharpList <Tuple <K, long> > .Cons(new Tuple <K, long>(default(K), Addressing.LinearAddress.invalid), FSharpList <Tuple <K, long> > .get_Empty()))));
            }
            else
            {
                int keyLen = SeqModule.Length <K>(keys);
                IEnumerable <Tuple <K, long> > tuples = (IEnumerable <Tuple <K, long> >)SeqModule.Map <K, Tuple <K, long> >((Func <M0, M1>) new LinearIndex.keyLocations <K>(index), keys);
                m1s = SeqModule.MapIndexed <Tuple <Tuple <K, long>, Tuple <K, long> >, Tuple <K, Tuple <long, long> > >((Func <int, Func <M0, M1> >) new LinearIndex.locations <K>(index, keyLen), (IEnumerable <M0>)SeqModule.Pairwise <Tuple <K, long> >(SeqModule.Append <Tuple <K, long> >((IEnumerable <M0>)FSharpList <Tuple <K, long> > .Cons(new Tuple <K, long>(default(K), Addressing.LinearAddress.invalid), FSharpList <Tuple <K, long> > .get_Empty()), (IEnumerable <M0>)tuples)));
            }
            Tuple <K, Tuple <long, long> >[] tupleArray1 = (Tuple <K, Tuple <long, long> >[])ArrayModule.OfSeq <Tuple <K, Tuple <long, long> > >((IEnumerable <M0>)m1s);
            Func <Tuple <K, Tuple <long, long> >, Tuple <K, Tuple <IIndex <K>, VectorConstruction> > > Func1 = (Func <Tuple <K, Tuple <long, long> >, Tuple <K, Tuple <IIndex <K>, VectorConstruction> > >) new LinearIndex.vectorConstructions <K>(chunkBuilder, index);

            Tuple <K, Tuple <long, long> >[] tupleArray2 = tupleArray1;
            if ((object)tupleArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray3 = new Tuple <K, Tuple <IIndex <K>, VectorConstruction> > [tupleArray2.Length];
            for (int index1 = 0; index1 < tupleArray3.Length; ++index1)
            {
                tupleArray3[index1] = Func1.Invoke(tupleArray2[index1]);
            }
            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray4 = tupleArray3;
            Func <Tuple <K, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > Func2 = selector;

            Tuple <K, Tuple <IIndex <K>, VectorConstruction> >[] tupleArray5 = tupleArray4;
            if ((object)tupleArray5 == null)
            {
                throw new ArgumentNullException("array");
            }
            Tuple <TNewKey, R>[] tupleArray6 = new Tuple <TNewKey, R> [tupleArray5.Length];
            for (int index1 = 0; index1 < tupleArray6.Length; ++index1)
            {
                tupleArray6[index1] = Func2.Invoke(tupleArray5[index1]);
            }
            Tuple <TNewKey, R>[]         tupleArray7    = tupleArray6;
            IIndex <TNewKey>             index2         = indexBuilder.Create <TNewKey>(SeqModule.Map <Tuple <TNewKey, R>, TNewKey>((Func <M0, M1>) new LinearIndex.newIndex <TNewKey, R>(), (IEnumerable <M0>)tupleArray7), (FSharpOption <bool>)null);
            IVectorBuilder               vectorBuilder1 = this.vectorBuilder;
            Func <Tuple <TNewKey, R>, R> Func3          = (Func <Tuple <TNewKey, R>, R>) new LinearIndex.vect <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray8 = tupleArray7;
            if ((object)tupleArray8 == null)
            {
                throw new ArgumentNullException("array");
            }
            R[]            optionalValueArray = new R[tupleArray8.Length];
            IVectorBuilder vectorBuilder2     = vectorBuilder1;

            for (int index1 = 0; index1 < optionalValueArray.Length; ++index1)
            {
                optionalValueArray[index1] = Func3.Invoke(tupleArray8[index1]);
            }
            IVector <R> missing = vectorBuilder2.CreateMissing <R>(optionalValueArray);

            return(new Tuple <IIndex <TNewKey>, IVector <R> >(index2, missing));
        }
コード例 #13
0
ファイル: FrameExtensions.cs プロジェクト: nh43de/deedle-cs
 public static int CountColumns <R, C>(this Frame <R, C> frame)
 {
     return(SeqModule.Length <KeyValuePair <C, long> >((IEnumerable <M0>)frame.ColumnIndex.Mappings));
 }
コード例 #14
0
ファイル: SeriesBuilder`2.cs プロジェクト: nh43de/deedle-cs
 IEnumerator <KeyValuePair <K, V> > IEnumerable <KeyValuePair <K, V> > .GetEnumerator()
 {
     return(((IEnumerable <KeyValuePair <K, V> >)SeqModule.Map <Tuple <K, V>, KeyValuePair <K, V> >((FSharpFunc <M0, M1>) new SeriesExtensions.System\u002DCollections\u002DGeneric\u002DIEnumerable\u002DGetEnumerator <K, V>(), (IEnumerable <M0>)ListModule.Reverse <Tuple <K, V> >((FSharpList <M0>)ListModule.Zip <K, V>((FSharpList <M0>) this.keys, (FSharpList <M1>) this.values)))).GetEnumerator());
 }
コード例 #15
0
ファイル: SeriesBuilder`2.cs プロジェクト: nh43de/deedle-cs
        bool IDictionary <K, V> .TryGetValue(K key, ref V value)
        {
            FSharpOption <Tuple <K, V> > fsharpOption = (FSharpOption <Tuple <K, V> >)SeqModule.TryFind <Tuple <K, V> >((FSharpFunc <M0, bool>) new SeriesExtensions.System\u002DCollections\u002DGeneric\u002DIDictionary\u002DTryGetValue <K, V>(key), (IEnumerable <M0>)SeqModule.Zip <K, V>((IEnumerable <M0>) this.keys, (IEnumerable <M1>) this.values));

            if (fsharpOption == null)
            {
                return(false);
            }
            V v = fsharpOption.get_Value().Item2;

            value = v;
            return(true);
        }
コード例 #16
0
ファイル: SeriesBuilder`2.cs プロジェクト: nh43de/deedle-cs
        void ICollection <KeyValuePair <K, V> > .CopyTo(KeyValuePair <K, V>[] array, int offset)
        {
            SeriesBuilder <K, V> seriesBuilder = this;

            SeqModule.IterateIndexed <KeyValuePair <K, V> >((FSharpFunc <int, FSharpFunc <M0, Unit> >) new SeriesExtensions.System\u002DCollections\u002DGeneric\u002DIDictionary\u002DCopyTo <K, V>(offset, array), (IEnumerable <M0>)seriesBuilder);
        }
コード例 #17
0
        public static Frame <c, a> frame <a, b, c>(IEnumerable <Tuple <TLeft, TRight> > columns) where b : ISeries <c>
        {
            Tuple <a[], b[]> tuple1 = ArrayModule.Unzip <TLeft, TRight>((Tuple <M0, M1>[])ArrayModule.OfSeq <Tuple <TLeft, TRight> >((IEnumerable <M0>)columns));

            b[] values = tuple1.Item2;
            a[] keys   = tuple1.Item1;
            Tuple <FSharpList <IVectorBuilder>, FSharpList <IIndexBuilder> > tuple2 = new Tuple <FSharpList <IVectorBuilder>, FSharpList <IIndexBuilder> >((FSharpList <IVectorBuilder>)ListModule.OfSeq <IVectorBuilder>(SeqModule.Distinct <IVectorBuilder>((IEnumerable <M0>)SeqModule.ToList <IVectorBuilder>((IEnumerable <M0>) new FFrameextensions.vbs <b, c>(values, default(b), (IEnumerator <b>)null, 0, (IVectorBuilder)null)))), (FSharpList <IIndexBuilder>)ListModule.OfSeq <IIndexBuilder>(SeqModule.Distinct <IIndexBuilder>((IEnumerable <M0>)SeqModule.ToList <IIndexBuilder>((IEnumerable <M0>) new FFrameextensions.ibs <b, c>(values, default(b), (IEnumerator <b>)null, 0, (IIndexBuilder)null)))));
            Tuple <IVectorBuilder, IIndexBuilder> tuple3;

            if (tuple2.Item1.get_TailOrNull() != null)
            {
                FSharpList <IVectorBuilder> fsharpList1 = tuple2.Item1;
                if (fsharpList1.get_TailOrNull().get_TailOrNull() == null && tuple2.Item2.get_TailOrNull() != null)
                {
                    FSharpList <IIndexBuilder> fsharpList2 = tuple2.Item2;
                    if (fsharpList2.get_TailOrNull().get_TailOrNull() == null)
                    {
                        tuple3 = new Tuple <IVectorBuilder, IIndexBuilder>(fsharpList1.get_HeadOrDefault(), fsharpList2.get_HeadOrDefault());
                        goto label_5;
                    }
                }
            }
            tuple3 = new Tuple <IVectorBuilder, IIndexBuilder>(FVectorBuilderimplementation.VectorBuilder.Instance, FIndexBuilderimplementation.IndexBuilder.Instance);
label_5:
            Tuple <IVectorBuilder, IIndexBuilder> tuple4 = tuple3;
            IVectorBuilder vectorBuilder = tuple4.Item1;

            return(FrameUtils.fromColumns <c, a, b>(tuple4.Item2, vectorBuilder, new Series <TLeft, TRight>(keys, values)));
        }
コード例 #18
0
ファイル: FrameExtensions.cs プロジェクト: nh43de/deedle-cs
        public static Frame <TRowKey, TColumnKey> GetRowsAt <TRowKey, TColumnKey>(this Frame <TRowKey, TColumnKey> frame, params int[] indices)
        {
            int[] numArray1 = indices;
            FSharpFunc <int, TRowKey> fsharpFunc1 = (FSharpFunc <int, TRowKey>) new FrameExtensions.keys9 <TRowKey, TColumnKey>(frame.Rows);

            int[] numArray2 = numArray1;
            if ((object)numArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            TRowKey[] rowKeyArray1 = new TRowKey[numArray2.Length];
            for (int index = 0; index < rowKeyArray1.Length; ++index)
            {
                rowKeyArray1[index] = fsharpFunc1.Invoke(numArray2[index]);
            }
            TRowKey[] rowKeyArray2 = rowKeyArray1;
            int[]     numArray3    = indices;
            FSharpFunc <int, ISeries <TColumnKey> > fsharpFunc2 = (FSharpFunc <int, ISeries <TColumnKey> >) new FrameExtensions.values0 <TColumnKey, TRowKey>(frame);

            int[] numArray4 = numArray3;
            if ((object)numArray4 == null)
            {
                throw new ArgumentNullException("array");
            }
            ISeries <TColumnKey>[] seriesArray1 = new ISeries <TColumnKey> [numArray4.Length];
            for (int index = 0; index < seriesArray1.Length; ++index)
            {
                seriesArray1[index] = fsharpFunc2.Invoke(numArray4[index]);
            }
            ISeries <TColumnKey>[] seriesArray2 = seriesArray1;
            return(FFrameextensions.FrameofRowsStatic <TRowKey, ISeries <TColumnKey>, TColumnKey>((IEnumerable <Tuple <TRowKey, ISeries <TColumnKey> > >)SeqModule.Zip <TRowKey, ISeries <TColumnKey> >((IEnumerable <M0>)rowKeyArray2, (IEnumerable <M1>)seriesArray2)));
        }
コード例 #19
0
        internal Tuple <LinearIndex <a>, VectorConstruction> asLinearIndex <a>(IIndex <a> index, VectorConstruction vector)
        {
            LinearIndex <a> linearIndex = index as LinearIndex <a>;

            if (linearIndex != null)
            {
                return(new Tuple <LinearIndex <a>, VectorConstruction>(linearIndex, vector));
            }
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.MapIndexed <KeyValuePair <a, long>, Tuple <long, long> >((Func <int, Func <M0, M1> >) new LinearIndex.relocs <a>(), (IEnumerable <M0>)index.Mappings);
            VectorConstruction vectorConstruction    = VectorConstruction.NewRelocate(vector, index.KeyCount, tuples);

            return(new Tuple <LinearIndex <a>, VectorConstruction>(new LinearIndex <a>(System.Array.AsReadOnly <a>(ArrayModule.OfSeq <a>((IEnumerable <a>)SeqModule.Map <KeyValuePair <a, long>, a>((Func <M0, M1>) new LinearIndex.clo <a>(), (IEnumerable <M0>)index.Mappings))), LinearIndexBuilder.Instance, (FSharpOption <bool>)null), vectorConstruction));
        }
コード例 #20
0
        Tuple <IIndex <K>, VectorConstruction> IIndexBuilder.DropItem <K>(Tuple <IIndex <K>, VectorConstruction> _arg10, K key)
        {
            Tuple <IIndex <K>, VectorConstruction> tuple1 = _arg10;
            VectorConstruction vectorConstruction1        = tuple1.Item2;
            IIndex <K>         index = tuple1.Item1;
            FSharpChoice <Unit, Tuple <K, long> > fsharpChoice = OptionalValueModule.MissingPresent <Tuple <K, long> >(index.Lookup(key, Lookup.Exact, (Func <long, bool>) new LinearIndex.DeedleIndicesIIndexBuilderDropItem()));

            if (fsharpChoice is FSharpChoice <Unit, Tuple <K, long> > .Choice2Of2)
            {
                Tuple <K, long>        tuple2 = ((FSharpChoice <Unit, Tuple <K, long> > .Choice2Of2)fsharpChoice).get_Item();
                VectorConstruction     vectorConstruction2 = VectorConstruction.NewDropRange(vectorConstruction1, RangeRestriction <long> .NewFixed(tuple2.Item2, tuple2.Item2));
                ReadOnlyCollection <K> keys = index.Keys;
                return(new Tuple <IIndex <K>, VectorConstruction>((IIndex <K>) new LinearIndex <K>(System.Array.AsReadOnly <K>(ArrayModule.OfSeq <K>(SeqModule.Filter <K>((Func <K, bool>) new LinearIndex.newKeys <K>(key), (IEnumerable <M0>)keys))), (IIndexBuilder)this, FSharpOption <bool> .Some(index.IsOrdered)), vectorConstruction2));
            }
            string paramName = nameof(key);

            throw new ArgumentException(((Func <K, string>)ExtraTopLevelOperators.PrintFormatToString <Func <K, string> >((PrintfFormat <M0, Unit, string, string>) new PrintfFormat <Func <K, string>, Unit, string, string, K>("The key '%O' is not present in the index."))).Invoke(key), paramName);
        }
コード例 #21
0
 public static Deedle.Series <K, a> ofOptionalObservations <K, a>(IEnumerable <Tuple <K, FSharpOption <a> > > observations)
 {
     return(new Deedle.Series <K, FSharpOption <a> >((IEnumerable <K>)SeqModule.Map <Tuple <K, FSharpOption <a> >, K>((FSharpFunc <M0, M1>) new FSeriesextensions.ofOptionalObservations <K, a>(), (IEnumerable <M0>)observations), (IEnumerable <FSharpOption <a> >)SeqModule.Map <Tuple <K, FSharpOption <a> >, FSharpOption <a> >((FSharpFunc <M0, M1>) new FSeriesextensions.ofOptionalObservations <K, a>(), (IEnumerable <M0>)observations)).SelectOptional <a>(new Func <KeyValuePair <K, OptionalValue <FSharpOption <a> > >, OptionalValue <a> >(new FSeriesextensions.ofOptionalObservations <K, a>().Invoke)));
 }
コード例 #22
0
 public static Deedle.Series <int, a> ofNullables <a>(IEnumerable <a?> values) where a : struct
 {
     return(new Deedle.Series <int, a?>((IEnumerable <int>)SeqModule.MapIndexed <a?, int>((FSharpFunc <int, FSharpFunc <M0, M1> >) new FSeriesextensions.keys <a>(), (IEnumerable <M0>)values), values).Select <a>(new Func <KeyValuePair <int, a?>, a>(new FSeriesextensions.ofNullables <a>().Invoke)));
 }
コード例 #23
0
 public static Deedle.Series <int, a> ofValues <a>(IEnumerable <a> values)
 {
     return(new Deedle.Series <int, a>((IEnumerable <int>)SeqModule.MapIndexed <a, int>((FSharpFunc <int, FSharpFunc <M0, M1> >) new FSeriesextensions.keys <a>(), values), values));
 }
コード例 #24
0
 IEnumerator <TNewAddress> IEnumerable <TNewAddress> .GetEnumerator()
 {
     return(((IEnumerable <TNewAddress>)SeqModule.Map <TOldAddress, TNewAddress>((Func <M0, M1>) this.f, (IEnumerable <M0>) this.c)).GetEnumerator());
 }
コード例 #25
0
ファイル: SeriesBuilder`2.cs プロジェクト: nh43de/deedle-cs
 bool IDictionary <K, V> .ContainsKey(K k)
 {
     return(SeqModule.Exists <K>((FSharpFunc <M0, bool>) new SeriesExtensions.System\u002DCollections\u002DGeneric\u002DIDictionary\u002DContainsKey <K>(k), (IEnumerable <M0>) this.keys));
 }
コード例 #26
0
 public static double Sum <K, V>(this Series <K, V> series)
 {
     return((double)SeqModule.Fold <V, double>((FSharpFunc <M1, FSharpFunc <M0, M1> >) new SeriesStatsExtensions.Sum <V>(), (M1)Operators.get_NaN(), (IEnumerable <M0>)series.Values));
 }
コード例 #27
0
        Tuple <IIndex <a>, VectorConstruction> IIndexBuilder.GetAddressRange <a>(Tuple <IIndex <a>, VectorConstruction> _arg11, RangeRestriction <long> range)
        {
            Tuple <IIndex <a>, VectorConstruction> tuple = _arg11;
            VectorConstruction vectorConstruction1       = tuple.Item2;
            IIndex <a>         index1  = tuple.Item1;
            IIndexBuilder      builder = (IIndexBuilder)this;
            FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > fsharpChoice = range.AsAbsolute(index1.KeyCount);

            if (fsharpChoice is FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice1Of2)
            {
                FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice1Of2 choice1Of2 = (FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice1Of2)fsharpChoice;
                long num1 = choice1Of2.get_Item().Item1;
                if (choice1Of2.get_Item().Item2 < num1)
                {
                    long num2 = choice1Of2.get_Item().Item1;
                    long num3 = choice1Of2.get_Item().Item2;
                    return(new Tuple <IIndex <a>, VectorConstruction>((IIndex <a>) new LinearIndex <a>(ReadOnlyCollection.empty <a>(), builder, FSharpOption <bool> .Some(true)), VectorConstruction.NewEmpty(0L)));
                }
            }
            if (!(fsharpChoice is FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice2Of2))
            {
                FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice1Of2 choice1Of2 = (FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice1Of2)fsharpChoice;
                long startAddress         = choice1Of2.get_Item().Item1;
                long endAddress           = choice1Of2.get_Item().Item2;
                VectorConstruction range1 = VectorConstruction.NewGetRange(vectorConstruction1, RangeRestriction <long> .NewFixed(startAddress, endAddress));
                return(new Tuple <IIndex <a>, VectorConstruction>((IIndex <a>) new LinearRangeIndex <a>(index1, startAddress, endAddress), range1));
            }
            IRangeRestriction <long> indices = ((FSharpChoice <Tuple <long, long>, IRangeRestriction <long> > .Choice2Of2)fsharpChoice).get_Item();
            IEnumerable <a>          @as     = (IEnumerable <a>) new LinearIndex.newKeys <a>(index1, indices, new long(), (IEnumerator <long>)null, 0, default(a));
            IIndex <a> index2 = builder.Create <a>(@as, (FSharpOption <bool>)null);

            LinearIndex.relocations relocations59218 = new LinearIndex.relocations();
            long   lo  = 0;
            long   hi  = index2.KeyCount - 1L;
            object obj = lo > hi ? (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations()) : (object)new LinearIndex.relocations(lo, hi, 1L, (Func <long, Func <long, bool> >) new LinearIndex.relocations());
            IEnumerable <Tuple <long, long> > tuples = (IEnumerable <Tuple <long, long> >)SeqModule.Zip <long, long>((IEnumerable <M0>)SeqModule.Map <long, long>((Func <M0, M1>)relocations59218, (IEnumerable <M0>)obj), (IEnumerable <M1>)indices);
            VectorConstruction vectorConstruction2   = VectorConstruction.NewRelocate(vectorConstruction1, index2.KeyCount, tuples);

            return(new Tuple <IIndex <a>, VectorConstruction>(index2, vectorConstruction2));
        }
コード例 #28
0
 IEnumerator <KeyValuePair <R, ISeries <C> > > IEnumerable <KeyValuePair <R, ISeries <C> > > .GetEnumerator()
 {
     return(((IEnumerable <KeyValuePair <R, ISeries <C> > >)SeqModule.Map <Tuple <R, ISeries <C> >, KeyValuePair <R, ISeries <C> > >((FSharpFunc <M0, M1>) new FrameBuilder.System\u002DCollections\u002DGeneric\u002DIEnumerable\u002DGetEnumerator <R, C>(), (IEnumerable <M0>)ListModule.Reverse <Tuple <R, ISeries <C> > >((FSharpList <M0>) this.series))).GetEnumerator());
 }
コード例 #29
0
        Tuple <IIndex <TNewKey>, IVector <R> > IIndexBuilder.Aggregate <K, TNewKey, R>(IIndex <K> index, Aggregation <K> aggregation, VectorConstruction vector, Func <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> > selector)
        {
            if (!index.IsOrdered)
            {
                throw new InvalidOperationException("Floating window aggregation and chunking is only supported on ordered indices. Consider sorting the series before calling the operation.");
            }
            IIndexBuilder   indexBuilder1 = (IIndexBuilder)this;
            Aggregation <K> aggregation1  = aggregation;
            IEnumerable <Tuple <DataSegmentKind, long, long> > tuples1;

            switch (aggregation1.get_Tag())
            {
            case 0:
                Aggregation <K> .WindowSize windowSize = (Aggregation <K> .WindowSize)aggregation1;
                tuples1 = Seq.windowRangesWithBounds((long)windowSize.item1, windowSize.item2, index.KeyCount);
                break;

            case 2:
                tuples1 = (IEnumerable <Tuple <DataSegmentKind, long, long> >)SeqModule.Map <Tuple <long, long>, Tuple <DataSegmentKind, long, long> >((Func <M0, M1>) new LinearIndex.locations(), (IEnumerable <M0>)Seq.windowRangesWhile <K>(((Aggregation <K> .WindowWhile)aggregation1).item, (IEnumerable <K>)index.Keys));
                break;

            case 3:
                tuples1 = (IEnumerable <Tuple <DataSegmentKind, long, long> >)SeqModule.Map <Tuple <long, long>, Tuple <DataSegmentKind, long, long> >((Func <M0, M1>) new LinearIndex.locations(), (IEnumerable <M0>)Seq.chunkRangesWhile <K>(((Aggregation <K> .ChunkWhile)aggregation1).item, (IEnumerable <K>)index.Keys));
                break;

            default:
                Aggregation <K> .ChunkSize chunkSize = (Aggregation <K> .ChunkSize)aggregation1;
                tuples1 = Seq.chunkRangesWithBounds((long)chunkSize.item1, chunkSize.item2, index.KeyCount);
                break;
            }
            IEnumerable <Tuple <DataSegmentKind, long, long> > tuples2 = tuples1;
            IEnumerable <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > > tuples3 = (IEnumerable <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > >)SeqModule.Map <Tuple <DataSegmentKind, long, long>, Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> > >((Func <M0, M1>) new LinearIndex.vectorConstructions <K>(index, vector), (IEnumerable <M0>)tuples2);

            Tuple <TNewKey, R>[] tupleArray1         = (Tuple <TNewKey, R>[])ArrayModule.OfSeq <Tuple <TNewKey, R> >((IEnumerable <M0>)SeqModule.Map <Tuple <DataSegmentKind, Tuple <IIndex <K>, VectorConstruction> >, Tuple <TNewKey, R> >((Func <M0, M1>)selector, (IEnumerable <M0>)tuples3));
            IIndexBuilder        indexBuilder2       = indexBuilder1;
            Func <Tuple <TNewKey, R>, TNewKey> Func1 = (Func <Tuple <TNewKey, R>, TNewKey>) new LinearIndex.newIndex <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray2 = tupleArray1;
            if ((object)tupleArray2 == null)
            {
                throw new ArgumentNullException("array");
            }
            TNewKey[]     array         = new TNewKey[tupleArray2.Length];
            IIndexBuilder indexBuilder3 = indexBuilder2;

            for (int index1 = 0; index1 < array.Length; ++index1)
            {
                array[index1] = Func1.Invoke(tupleArray2[index1]);
            }
            IIndex <TNewKey>             index2         = indexBuilder3.Create <TNewKey>(System.Array.AsReadOnly <TNewKey>(array), (FSharpOption <bool>)null);
            IVectorBuilder               vectorBuilder1 = this.vectorBuilder;
            Func <Tuple <TNewKey, R>, R> Func2          = (Func <Tuple <TNewKey, R>, R>) new LinearIndex.vect <TNewKey, R>();

            Tuple <TNewKey, R>[] tupleArray3 = tupleArray1;
            if ((object)tupleArray3 == null)
            {
                throw new ArgumentNullException("array");
            }
            R[]            optionalValueArray = new R[tupleArray3.Length];
            IVectorBuilder vectorBuilder2     = vectorBuilder1;

            for (int index1 = 0; index1 < optionalValueArray.Length; ++index1)
            {
                optionalValueArray[index1] = Func2.Invoke(tupleArray3[index1]);
            }
            IVector <R> missing = vectorBuilder2.CreateMissing <R>(optionalValueArray);

            return(new Tuple <IIndex <TNewKey>, IVector <R> >(index2, missing));
        }
コード例 #30
0
 public static IEnumerable <StreamEvent <byte[]> > mapToStreamItems(IEnumerable <Document> docs)
 {
     return(SeqModule.Collect <Document, IEnumerable <StreamEvent <byte[]> >, StreamEvent <byte[]> >(new MapToStreamItem(), docs));
 }