Exemplo n.º 1
0
 public static Tuple <DataKind, ArrayKind> GetKindArray(DataViewType type)
 {
     if (type.IsVector())
     {
         int dc = type.AsVector().DimCount();
         return(new Tuple <DataKind, ArrayKind>(type.ItemType().RawKind(), dc == 1 &&
                                                type.AsVector().GetDim(0) > 0 ? ArrayKind.Array : ArrayKind.VBuffer));
     }
     else
     {
         return(new Tuple <DataKind, ArrayKind>(type.RawKind(), ArrayKind.None));
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// Saves a type into a stream.
 /// </summary>
 public static void WriteType(ModelSaveContext ctx, DataViewType type)
 {
     ctx.Writer.Write(type.IsVector());
     if (type.IsVector())
     {
         ctx.Writer.Write(type.AsVector().DimCount());
         for (int i = 0; i < type.AsVector().DimCount(); ++i)
         {
             ctx.Writer.Write(type.AsVector().GetDim(i));
         }
         ctx.Writer.Write((byte)type.AsVector().ItemType().RawKind());
     }
     else if (type.IsKey())
     {
         throw Contracts.ExceptNotImpl("Key cannot be serialized yet.");
     }
     else
     {
         ctx.Writer.Write((byte)type.RawKind());
     }
 }
Exemplo n.º 3
0
 private void ValidateInputs(out int indexLabel, out int indexTime, out DataViewType typeLabel, out DataViewType typeTime)
 {
     indexLabel = SchemaHelper.GetColumnIndex(Source.Schema, _args.columns[0].Source);
     typeLabel  = Source.Schema[indexLabel].Type;
     if (typeLabel.IsVector())
     {
         if (typeLabel.AsVector().DimCount() != 1 || typeLabel.AsVector().GetDim(0) != 1)
         {
             throw Host.ExceptNotImpl("Not implemented yet for multiple dimensions.");
         }
     }
     if (typeLabel.RawKind() != DataKind.Single)
     {
         throw Host.ExceptNotImpl("InputColumn must be R4.");
     }
     indexTime = SchemaHelper.GetColumnIndex(Source.Schema, _args.timeColumn);
     typeTime  = Source.Schema[indexTime].Type;
     if (typeTime.RawKind() != DataKind.Single)
     {
         throw Host.ExceptNotImpl("Time columne must be R4.");
     }
 }