public SourceTableDescriptionAggregation(IEnumerable <SourceTableDescription> input)
        {
            rowTestAggregation    = new SourceTableSliceTestAggregation(input.Select(x => x.firstRowTest));
            columnTestAggregation = new SourceTableSliceTestAggregation(input.Select(x => x.firstColumnTest));

            rowTestAggregation.format    = SourceTableSliceType.row;
            columnTestAggregation.format = SourceTableSliceType.column;

            sourceHeight.Learn(input.Select(x => (Double)x.sourceSize.y));
            sourceWidth.Learn(input.Select(x => (Double)x.sourceSize.x));

            Count = rowTestAggregation.Count;
        }
        public static MetaTableDescription CompileDescription(this TableExtractionTask task, List <SourceTableDescription> sourceDescriptions)
        {
            MetaTableDescription metaDescription = null;


            SourceTableDescriptionAggregation aggregatedDescriptions = sourceDescriptions.CompileSourceDescription(); // new SourceTableDescriptionAggregation();  //task.score.LastEntry().aggregatedDescriptions;

            // List<SourceTableDescription> sourceDescriptions = task.score.TaskRuns.Where(x => x.executionMode == ExtractionTaskEngineMode.Training).Where(x => x.IsSuccess).Select(x => x.metaTableDescription.sourceDescription).ToList();


            //aggregatedDescriptions.Report(report_folder, reporter);

            metaDescription         = new imbSCI.DataExtraction.MetaTables.Descriptors.MetaTableDescription(new SourceTableDescription(), imbSCI.DataExtraction.MetaTables.Descriptors.MetaTableFormatType.unknown);
            metaDescription.Comment = "Created by for " + task.name;

            SourceTableSliceTestAggregation SelectedAsPropertyUID = null;
            SourceTableSliceTestAggregation SelectedAsEntryUID    = null;

            if (aggregatedDescriptions.rowTestAggregation.IsPreferedAsPropertyUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.rowTestAggregation;
            }
            else if (aggregatedDescriptions.columnTestAggregation.IsPreferedAsPropertyUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.columnTestAggregation;
            }
            else if (aggregatedDescriptions.rowTestAggregation.IsSuitableAsUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.rowTestAggregation;
            }
            else if (aggregatedDescriptions.columnTestAggregation.IsSuitableAsUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.columnTestAggregation;
            }
            else if (aggregatedDescriptions.rowTestAggregation.IsAcceptableAsPropertyUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.rowTestAggregation;
            }
            else if (aggregatedDescriptions.columnTestAggregation.IsAcceptableAsPropertyUID)
            {
                SelectedAsPropertyUID = aggregatedDescriptions.columnTestAggregation;
            }

            if (SelectedAsPropertyUID == null)
            {
                metaDescription.index_propertyID = -1;
            }
            else
            {
                if (aggregatedDescriptions.rowTestAggregation == SelectedAsPropertyUID)
                {
                    SelectedAsEntryUID = aggregatedDescriptions.columnTestAggregation;
                }
                else if (aggregatedDescriptions.columnTestAggregation == SelectedAsPropertyUID)
                {
                    SelectedAsEntryUID = aggregatedDescriptions.rowTestAggregation;
                }
            }

            if (SelectedAsEntryUID != null)
            {
                if (SelectedAsEntryUID.IsDistinctValue)
                {
                }
                else
                {
                    SelectedAsEntryUID            = null;
                    metaDescription.index_entryID = -1;
                }
            }


            if (SelectedAsEntryUID != null)
            {
                metaDescription.entrySource   = SelectedAsEntryUID.format;
                metaDescription.index_entryID = 0;
            }

            if (SelectedAsPropertyUID != null)
            {
                metaDescription.propertySource   = SelectedAsPropertyUID.format;
                metaDescription.index_propertyID = 0;
            }


            if (metaDescription.propertySource == SourceTableSliceType.undefined)
            {
                if (aggregatedDescriptions.sourceWidth.Range <= aggregatedDescriptions.sourceHeight.Range)
                {
                    metaDescription.propertySource = SourceTableSliceType.column;
                }
                else if (aggregatedDescriptions.sourceWidth.Range > aggregatedDescriptions.sourceHeight.Range)
                {
                    metaDescription.propertySource = SourceTableSliceType.row;
                }
            }

            if (metaDescription.entrySource == SourceTableSliceType.undefined)
            {
                switch (metaDescription.propertySource)
                {
                default:

                    break;

                case SourceTableSliceType.column:
                    metaDescription.entrySource = SourceTableSliceType.row;
                    break;

                case SourceTableSliceType.row:
                    metaDescription.entrySource = SourceTableSliceType.column;
                    break;
                }
            }

            switch (metaDescription.propertySource)
            {
            default:

                break;

            case SourceTableSliceType.column:
                metaDescription.sourceDescription.valueZone.y = 0;    // metaDescription.index_propertyID + 1;
                metaDescription.sourceDescription.valueZone.x = 0;    //metaDescription.index_entryID + 1;
                                                                      // metaDescription.IsTransposed = true;
                                                                      //   metaDescription.entrySource = SourceTableSliceType.row;
                metaDescription.format = MetaTableFormatType.vertical;
                break;

            case SourceTableSliceType.row:
                //  metaDescription.entrySource = SourceTableSliceType.column;
                metaDescription.format = MetaTableFormatType.horizontal;
                metaDescription.sourceDescription.valueZone.x = 0;     // metaDescription.index_propertyID + 1;
                metaDescription.sourceDescription.valueZone.y = 0;     // metaDescription.index_entryID + 1;
                break;
            }



            // metaDescription.Report(report_folder, reporter);

            return(metaDescription);
        }