Ejemplo n.º 1
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));
        }
Ejemplo n.º 2
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));
        }
Ejemplo n.º 3
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));
 }
Ejemplo n.º 4
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)));
 }
Ejemplo n.º 5
0
 public static Frame <int, ColKey> FromRows <ColKey, V>(IEnumerable <Series <ColKey, V> > rows)
 {
     return(FrameUtils.fromRows <int, ColKey, Series <ColKey, V> >(FIndexBuilderimplementation.IndexBuilder.Instance, FVectorBuilderimplementation.VectorBuilder.Instance, new Series <int, Series <ColKey, V> >((IEnumerable <int>)SeqModule.MapIndexed <Series <ColKey, V>, int>((FSharpFunc <int, FSharpFunc <M0, M1> >) new FrameExtensions.FromRows <ColKey, V>(), (IEnumerable <M0>)rows), rows)));
 }