Пример #1
0
        public void ValidateRowKeysPDGetInstanceFromRowKeysFileAccess()
        {
            DenseMatrix <string, string, double> denseMatObj =
                GetDenseMatrix();
            ParallelOptions parOptObj = new ParallelOptions();

            denseMatObj.WritePaddedDouble(Constants.FastQTempTxtFileName, parOptObj);
            using (RowKeysPaddedDouble rkpdObj =
                       RowKeysPaddedDouble.GetInstanceFromPaddedDouble(Constants.FastQTempTxtFileName,
                                                                       parOptObj))
            {
                rkpdObj.WriteRowKeys(Constants.KeysTempFile);
            }

            using (RowKeysPaddedDouble rkpdObj =
                       RowKeysPaddedDouble.GetInstanceFromRowKeys(
                           Constants.KeysTempFile, parOptObj, FileAccess.Read,
                           FileShare.Read))
            {
                Assert.AreEqual(denseMatObj.ColCount, rkpdObj.ColCount);
                Assert.AreEqual(denseMatObj.RowCount, rkpdObj.RowCount);
                Assert.AreEqual(denseMatObj.RowKeys.Count, rkpdObj.RowKeys.Count);
                Assert.AreEqual(denseMatObj.ColKeys.Count, rkpdObj.ColKeys.Count);
            }

            if (File.Exists(Constants.FastQTempTxtFileName))
            {
                File.Delete(Constants.FastQTempTxtFileName);
            }

            if (File.Exists(Constants.KeysTempFile))
            {
                File.Delete(Constants.KeysTempFile);
            }

            Console.WriteLine(
                "RowKeysPaddedDouble BVT : Validation of GetInstanceFromRowKeysPaddedDouble(file-access) method successful");
            ApplicationLog.WriteLine(
                "RowKeysPaddedDouble BVT : Validation of GetInstanceFromRowKeysPaddedDouble(file-access) method successful");
        }
Пример #2
0
        private Matrix <string, string, TValue> LoadParentMatrix(string name)
        {
            if (Verbose)
            {
                Console.WriteLine("Loading " + name);
            }

            if (LeaveOnDiskIfPossible)
            {
                try
                {
                    RowKeysAnsi predictorCharOriginal0 = RowKeysAnsi.GetInstanceFromRowKeysAnsi(name, ParallelOptionsScope.Current);

                    Matrix <string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(CharToTValConverter, MissingValueForParse);
                    //Matrix<string,string,TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(Bio.Util.ValueConverter.CharToDouble, double.NaN);

                    Helper.CheckCondition(null == CreateRowKeysFileOrNull, "Already reading from a RowKeyAnsi file, so can't create one.");
                    return(predictorCharOriginal);
                }
                catch (MatrixFormatException)
                {//ignore
                }


                try
                {
                    RowKeysAnsi predictorCharOriginal0 = RowKeysAnsi.GetInstanceFromDenseAnsi(name, ParallelOptionsScope.Current);


                    if (null != CreateRowKeysFileOrNull)
                    {
                        predictorCharOriginal0.WriteRowKeys(CreateRowKeysFileOrNull);
                    }

                    Matrix <string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(CharToTValConverter, MissingValueForParse);
                    //Matrix<string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(Bio.Util.ValueConverter.CharToDouble, double.NaN);
                    return(predictorCharOriginal);
                }
                catch (MatrixFormatException)
                {//ignore
                }

                try
                {
                    RowKeysPaddedDouble predictorCharOriginal0 = RowKeysPaddedDouble.GetInstanceFromRowKeys(name, ParallelOptionsScope.Current);

                    Matrix <string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(DoubleToTValConverter, MissingValueForParse);
                    //Matrix<string,string,TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(Bio.Util.ValueConverter.CharToDouble, double.NaN);

                    Helper.CheckCondition(null == CreateRowKeysFileOrNull, "Already reading from a RowKeyAnsi file, so can't create one.");
                    return(predictorCharOriginal);
                }
                catch (MatrixFormatException)
                {//ignore
                }


                try
                {
                    RowKeysPaddedDouble predictorCharOriginal0 = RowKeysPaddedDouble.GetInstanceFromPaddedDouble(name, ParallelOptionsScope.Current);


                    if (null != CreateRowKeysFileOrNull)
                    {
                        predictorCharOriginal0.WriteRowKeys(CreateRowKeysFileOrNull);
                    }

                    Matrix <string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(DoubleToTValConverter, MissingValueForParse);
                    //Matrix<string, string, TValue> predictorCharOriginal = predictorCharOriginal0.ConvertValueView(Bio.Util.ValueConverter.CharToDouble, double.NaN);
                    return(predictorCharOriginal);
                }
                catch (MatrixFormatException)
                {//ignore
                }
            }

            Matrix <string, string, TValue> predictorCharOriginalX = MatrixFactory.Parse(name, MissingValueForParse, ParallelOptionsScope.Current);

            Helper.CheckCondition(null == CreateRowKeysFileOrNull, "Not creating from a DenseAnsi file, so can't create a RowKeyAnsi file.");
            return(predictorCharOriginalX);
        }