コード例 #1
0
ファイル: LstJson.cs プロジェクト: 0xCM/Meta.Core
        public void LstJson05()
        {
            var syn    = Synthetic.Create(RandomSeed.Seed01);
            var input  = syn.Next <string>(500);
            var json   = JsonServices.ToJson(input);
            var output = JsonServices.ToObject <Lst <string> >(json);

            claim.equal(input, output);
        }
コード例 #2
0
ファイル: FunctorTest.cs プロジェクト: 0xCM/Meta.Core
        public void Test01B()
        {
            var source = Synthetic.Create(150);
            var data   = source.Next <int>(500);
            var result = fmap(x => x * 15.0m, data);
            var expect = Lst.map(x => x * 15.0m, data);

            claim.equal(expect, result);
        }
コード例 #3
0
ファイル: FunctorTest.cs プロジェクト: 0xCM/Meta.Core
        public void Test01A()
        {
            var F      = Lst.Functor <int, decimal>();
            var f      = func <int, decimal>(x => x * 15.0m);
            var source = Synthetic.Create(150);
            var data   = source.Next <int>(500);
            var result = F.fmap(f)(data);
            var expect = map(x => x * 15.0m, data);

            claim.equal(expect, result);
        }
コード例 #4
0
ファイル: AttributeInfo.cs プロジェクト: tinelion/cs_jvm
        public static AttributeInfo Read(ClassReader classReader, ConstantPool constantPool)
        {
            ushort        attributeNameIndex = classReader.ReadU2();
            string        attributeName      = Encoding.UTF8.GetString(((ConstantUtf8)constantPool.ConstantPoolInfo[attributeNameIndex]).Bytes);
            AttributeInfo attributeInfo      = null;

            switch (attributeName)
            {
            case "ConstantValue":
                attributeInfo = new ConstantValue(); break;

            case "Code":
                attributeInfo = new Code(); break;

            case "Deprecated":
                attributeInfo = new Deprecated(); break;

            case "LineNumberTable":
                attributeInfo = new LineNumberTable(); break;

            case "LocalVariableTable":
                attributeInfo = new LocalVariableTable(); break;

            case "SourceFile":
                attributeInfo = new SourceFile(); break;

            case "Synthetic":
                attributeInfo = new Synthetic(); break;

            case "Exceptions":
                attributeInfo = new Exceptions(); break;

            case "Signature":
                attributeInfo = new Signature(); break;

            //case "StackMapTable":
            //    attributeInfo = null;
            default:
                throw new Exception("no such attribute error");
            }
            attributeInfo.AttributeName = attributeName;
            attributeInfo.ReadAttributeInfo(classReader, constantPool);
            return(attributeInfo);
        }
コード例 #5
0
        public async Task <ActionResult> Create(IFormFile uploadeddata, ReflectiveCoefficient reflectiveCoefficient)
        {
            var synthetics = new List <Synthetic>();
            var Acoustics  = new List <AcousticImpedance>();
            var res        = new List <CsvModel>();


            try
            {
                using (var reader = new StreamReader(uploadeddata.OpenReadStream()))

                    using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
                    {
                        var records = csv.GetRecords <CsvModel>();
                        res = records.ToList();
                    }
                var AIArray  = new float[res.Count()];
                var TWTArray = new float[res.Count()];
                var count    = 0;
                foreach (var row in res)
                {
                    float floattwt;
                    float floatAi;
                    try
                    {
                        floattwt = float.Parse(row.TWT);
                    }
                    catch (Exception)
                    {
                        TempData["Error"] = $"Time Value: {row.TWT} is not in the correct format, Please follow Format";
                        return(RedirectToAction(nameof(Index)));
                    }
                    try
                    {
                        floatAi = float.Parse(row.AI);
                    }
                    catch (Exception)
                    {
                        TempData["Error"] = $"AI value: {row.AI} is not in the correct format, Please follow Format";
                        return(RedirectToAction(nameof(Index)));
                    }
                    var acoustic = new AcousticImpedance()
                    {
                        AI = floatAi, TWT = floattwt
                    };

                    Acoustics.Add(acoustic);
                    AIArray[count]  = floatAi;
                    TWTArray[count] = floattwt;
                    count++;
                }
                var dd     = 0;
                var result = await _utilityHelper.getSyntheticFromPython(reflectiveCoefficient.Dt, TWTArray, AIArray);

                if (result != null)
                {
                    foreach (var num in result)
                    {
                        //var newfloat = float.Parse(num);
                        var newsynthetic = new Synthetic {
                            Sy = num
                        };
                        synthetics.Add(newsynthetic);
                        dd++;
                    }
                    reflectiveCoefficient.AcousticImpedances = Acoustics;
                    reflectiveCoefficient.Synthetics         = synthetics;
                    reflectiveCoefficient.Date = DateTime.Now;
                    _context.Add(reflectiveCoefficient);
                    _context.SaveChanges();
                    TempData["Success"] = "Upload and Synthetic data generated successfully";
                    return(RedirectToAction(nameof(Index)));
                }
                TempData["Error"] = "Unable to process file";
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                TempData["Error"] = $"Unable to process file: {ex.Message}";
                return(RedirectToAction(nameof(Index)));
            }

            // return RedirectToAction(nameof(Index));
        }