public void WhenPropertyArrayIsNull_CreateObject() { ExcelFunctions.MakeObject(Name, ObjectType, null); var result = ObjectStore.Get <MakeObjectTestType>(Name); result.Should().NotBeNull(); }
public void WhenPropertyArrayIsEmpty_CreateObject(int arrayWidth) { ExcelFunctions.MakeObject(Name, ObjectType, new object[0, arrayWidth]); var result = ObjectStore.Get <MakeObjectTestType>(Name); result.Should().NotBeNull(); }
public void WhenTypeIsNotSupported_Throw() { Action action = () => ExcelFunctions.MakeObject(Name, "nosuch", new object[0, 0]); action.ShouldThrow <NNXException>() .WithMessage("*Unrecognized object type: 'nosuch'.*"); }
public void WhenTypeIsNullOrEmpty_Throw(string typeName) { Action action = () => ExcelFunctions.MakeObject(Name, typeName, new object[0, 0]); action.ShouldThrow <NNXException>() .WithMessage("*Argument TypeName should not be null or empty.*"); }
public void WhenGivenEmptyArray_Throw(object[] emtpyArray) { Action action = () => ExcelFunctions.MakeArray(Name, emtpyArray); action.ShouldThrow <NNXException>() .WithMessage("*Array cannot be empty.*"); }
public void ShouldSetWeights() { ExcelFunctions.MakeMultilayerPerceptron("x", 2, 3, new[] { 4.0, 2.0 }, "weights"); var result = ObjectStore.Get <MultilayerPerceptron>("x"); result.Weights[0][0].Should().Be(1.0); }
public void PercentRank() { var array = new Double[] { 1, 8, 12, 7, 2, 9, 10, 4 }; Assert.That(ExcelFunctions.PercentRank(array, 1.0), Is.EqualTo(0.00000000000).Within(1e-8), "A1"); Assert.That(ExcelFunctions.PercentRank(array, 2.0), Is.EqualTo(0.14285714280).Within(1e-8), "A2"); Assert.That(ExcelFunctions.PercentRank(array, 3.0), Is.EqualTo(0.21428571420).Within(1e-8), "A3"); Assert.That(ExcelFunctions.PercentRank(array, 4.0), Is.EqualTo(0.28571428570).Within(1e-8), "A4"); Assert.That(ExcelFunctions.PercentRank(array, 5.0), Is.EqualTo(0.33333333330).Within(1e-8), "A5"); Assert.That(ExcelFunctions.PercentRank(array, 6.0), Is.EqualTo(0.38095238090).Within(1e-8), "A6"); Assert.That(ExcelFunctions.PercentRank(array, 7.0), Is.EqualTo(0.42857142850).Within(1e-8), "A7"); Assert.That(ExcelFunctions.PercentRank(array, 8.0), Is.EqualTo(0.57142857140).Within(1e-8), "A8"); Assert.That(ExcelFunctions.PercentRank(array, 9.0), Is.EqualTo(0.71428571420).Within(1e-8), "A9"); Assert.That(ExcelFunctions.PercentRank(array, 10.0), Is.EqualTo(0.85714285710).Within(1e-8), "A10"); Assert.That(ExcelFunctions.PercentRank(array, 11.0), Is.EqualTo(0.92857142850).Within(1e-8), "A11"); Assert.That(ExcelFunctions.PercentRank(array, 12.0), Is.EqualTo(1.00000000000).Within(1e-8), "A12"); array = new Double[] { 1, 9, 12, 7, 2, 9, 10, 2 }; Assert.That(ExcelFunctions.PercentRank(array, 1.0), Is.EqualTo(0.00000000000).Within(1e-8), "B1"); Assert.That(ExcelFunctions.PercentRank(array, 2.0), Is.EqualTo(0.14285714280).Within(1e-8), "B2"); Assert.That(ExcelFunctions.PercentRank(array, 3.0), Is.EqualTo(0.31428571420).Within(1e-8), "B3"); Assert.That(ExcelFunctions.PercentRank(array, 4.0), Is.EqualTo(0.34285714280).Within(1e-8), "B4"); Assert.That(ExcelFunctions.PercentRank(array, 5.0), Is.EqualTo(0.37142857140).Within(1e-8), "B5"); Assert.That(ExcelFunctions.PercentRank(array, 6.0), Is.EqualTo(0.40000000000).Within(1e-8), "B6"); Assert.That(ExcelFunctions.PercentRank(array, 7.0), Is.EqualTo(0.42857142850).Within(1e-8), "B7"); Assert.That(ExcelFunctions.PercentRank(array, 8.0), Is.EqualTo(0.50000000000).Within(1e-8), "B8"); Assert.That(ExcelFunctions.PercentRank(array, 9.0), Is.EqualTo(0.57142857140).Within(1e-8), "B9"); Assert.That(ExcelFunctions.PercentRank(array, 10.0), Is.EqualTo(0.85714285710).Within(1e-8), "B10"); Assert.That(ExcelFunctions.PercentRank(array, 11.0), Is.EqualTo(0.92857142850).Within(1e-8), "B11"); Assert.That(ExcelFunctions.PercentRank(array, 12.0), Is.EqualTo(1.00000000000).Within(1e-8), "B12"); }
public void IfTranerConfigDoesNotExist_Throw() { Action action = () => ExcelFunctions.TrainMultilayerPerceptron("nn", "no such", _inputs, _targets, _hiddenLayerSizes); action.ShouldThrow <NNXException>(); }
public void ShouldMakeTrainerConfig() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0, 0, 2, 0); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); result.Should().NotBeNull(); }
/// <summary> /// Support Name in Col #5 or in #6. /// </summary> /// <param name="worksheet"></param> /// <param name="row"></param> /// <param name="col"></param> /// <returns></returns> private static bool _IsNameInThisRow(ExcelObject.Worksheet worksheet, int row, int col) { bool result = true; // This cell has value? result = result && !String.IsNullOrEmpty(ExcelFunctions.GetString(worksheet, row, col)); // "If" for optimization if (result) { // first celsl has empty value for (int x = 1; x < col; x++) { result = result && String.IsNullOrEmpty(ExcelFunctions.GetString(worksheet, row, x)); // "If" for optimization if (!result) { break; } } } return(result); }
public void WhenWeightsArrayIsNullOrEmpty_Throw(string[] bad) { Action action = () => ExcelFunctions.MakeWeights("weights", bad); action.ShouldThrow <NNXException>() .WithMessage("*Argument WeightArrays cannot be null or empty.*"); }
public void ShouldStoreBatchSize() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0, 0.3, 2, 20); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); Assert.Equal(2, result.BatchSize); }
public void ShouldCalculateCrossentropy() { var expected = 1.30454023362682; var result = ExcelFunctions.GetCrossEntropyError(_actuals, _outputs); result.Should().BeApproximately(expected, 1e-12); }
public void ShouldStoreQuadraticRegularization() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0, 0.3, 2, 0); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); Assert.Equal(0.3, result.QuadraticRegularization); }
public void ShouldStoreNumEpochs() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0, 0.3, 2, 20); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); Assert.Equal(10, result.NumEpochs); }
public void ShouldCalculateCrossentropy() { var expected = 0.06; var result = ExcelFunctions.GetMeanSquareError(_actuals, _outputs); result.Should().BeApproximately(expected, 1e-12); }
public void ShouldStoreMomentum() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0.2, 0, 2, 0); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); Assert.Equal(0.2, result.Momentum); }
public void ShouldReturnObjectName() { var expected = "t"; var result = ExcelFunctions.MakeSimpleGradientTrainer(expected, 10, 0.1, 0, 0, 2, 0); Assert.Equal(expected, result); }
public void ShouldSetHiddenLayerSizes() { ExcelFunctions.MakeMultilayerPerceptron("x", 2, 3, new[] { 4.0, 2.0 }, "weights"); var result = ObjectStore.Get <MultilayerPerceptron>("x"); result.HiddenLayerSizes.Should().Equal(4, 2); }
public void WhenTypeIsSupported_MakeObjectOfRequestedType() { ExcelFunctions.MakeObject(Name, ObjectType, new object[0, 0]); var result = ObjectStore.Get <MakeObjectTestType>(Name); result.Should().NotBeNull(); }
public void ShouldMakeMultilayerPerceptron() { ExcelFunctions.MakeMultilayerPerceptron("x", 2, 3, new[] { 4.0, 2.0 }, "weights"); var result = ObjectStore.Get <MultilayerPerceptron>("x"); result.Should().NotBeNull(); }
public void ShouldGetWeightsForLayer(int layerNum, double[] expected) { var result = ExcelFunctions.GetWeights(Name, layerNum); result.Should().BeAssignableTo <double[, ]>(); Assert.Equal(expected.ToVertical2DArray(), result); }
public void btnSubir_Click(object sender, System.EventArgs e) { DataSet maestroPedidoDataSet = new DataSet(); DataSet detallePedidoDataSet = new DataSet(); string nombreArchivoMaestro = CargarArchivoExcel(inpArchivoMaestro.PostedFile.FileName.ToString(), inpArchivoMaestro); if (nombreArchivoMaestro != string.Empty) { ExcelFunctions excel = new ExcelFunctions(nombreArchivoMaestro); excel.Request(maestroPedidoDataSet, IncludeSchema.NO, "SELECT * FROM " + NombreRangoMaestro); } string nombreArchivoDetalle = CargarArchivoExcel(inpArchivoDetalle.PostedFile.FileName.ToString(), inpArchivoDetalle); if (nombreArchivoDetalle != string.Empty) { ExcelFunctions excel = new ExcelFunctions(nombreArchivoDetalle); excel.Request(detallePedidoDataSet, IncludeSchema.NO, "SELECT * FROM " + NombreRangoDetalle); } //Si el commit no devolvio errores, lo redirecciono a la misma página if (Importar(maestroPedidoDataSet, detallePedidoDataSet)) { Response.Redirect(ConfigurationManager.AppSettings["MainIndexPage"] + "?process=Inventarios.ImportarPedidos&ext=1"); } }
public void IfObjectIsNotINeuralNetwork_Throw() { ObjectStore.Add("notNN", "notNN"); Action action = () => ExcelFunctions.FeedForward("notNN", new[] { 1.0 }); action.ShouldThrow <NNXException>().WithMessage("*was expected to be INeuralNetwork*"); }
public void ShouldStoreLearningRate() { ExcelFunctions.MakeSimpleGradientTrainer("t", 10, 0.1, 0, 0, 2, 0); var result = ObjectStore.Get <SimpleGradientTrainer>("t"); Assert.Equal(0.1, result.LearningRate); }
private Operand GAMMALN(List <Operand> arg) { if (arg.Count < 1) { return(throwError("GAMMALN中参数不足", new List <Operand>())); } return(new Operand(OperandType.NUMBER, ExcelFunctions.GAMMALN(arg[0].NumberValue))); }
public void IfNumHiddenNodesIsNotPositive_Throw(int bad) { _hiddenLayerSizes[0] = bad; Action action = () => ExcelFunctions.TrainMultilayerPerceptron("nn", "trainer", _inputs, _targets, _hiddenLayerSizes); action.ShouldThrow <NeuralNetworkException>(); }
public void IfTranderConfigIsNotOfTypeTrainerConfig_Throw() { ObjectStore.Add("bad", "string"); Action action = () => ExcelFunctions.TrainMultilayerPerceptron("nn", "bad", _inputs, _targets, _hiddenLayerSizes); action.ShouldThrow <NNXException>(); }
public void WhenPropertyDoesNotExist_Throw() { _properties[0, 0] = "NoSuch"; Action action = () => ExcelFunctions.MakeObject(Name, ObjectType, _properties); action.ShouldThrow <NNXException>() .WithMessage($"*Object type {ObjectType} does not have property NoSuch.*"); }
public void ShouldInvokeTrainOnce() { var trainerMock = SetupInspectingMockTrainer(); ExcelFunctions.TrainMultilayerPerceptron("nn", "trainer", _inputs, _targets, _hiddenLayerSizes); trainerMock.Verify(t => t.Train(It.IsAny <IList <InputOutput> >(), It.IsAny <INeuralNetwork>()), Times.Exactly(1)); }
private void GenerateMasterDocuments(Applicant NewApplicant, Master NewMaster) { if (NewApplicant.LearningForm.Equals("очной")) { File.Copy(ProgramPath + @"Шаблоны\MasterTemplate.xls", ProgramPath + @"Документы (оч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (оч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } else if (NewApplicant.LearningForm.Equals("очно-заочной")) { File.Copy(ProgramPath + @"Шаблоны\MasterTemplate.xls", ProgramPath + @"Документы (оч-заоч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (оч-заоч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } else { File.Copy(ProgramPath + @"Шаблоны\MasterTemplate.xls", ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } ExcelForm.OpenWorksheet(1); FillMasterForm(NewApplicant, NewMaster); ExcelForm.OpenWorksheet(2); FillMasterRequest(NewApplicant, NewMaster); ExcelForm.OpenWorksheet(3); FillMasterListOfExams(NewApplicant, NewMaster); ExcelForm.OpenWorksheet(4); FillMasterProfile(NewApplicant, NewMaster); ExcelForm.OpenWorksheet(5); FillMasterReceipt(NewApplicant, NewMaster); int Fac; if (NewMaster.Specs[0] != null) { String SFac = GetFacultyNumber(NewMaster.Specs[0].Faculty.ToArray()[0]); Int32.TryParse(SFac, out Fac); FillSummary(Fac, NewApplicant); } ExcelForm.CloseDocument(); }
private void GenerateDocuments(object sender, RoutedEventArgs e) { Address Addr = new Address(); Addr.Index = ControlIndex.Text; Addr.Region = ControlRegion.Text; Addr.Town = ControlTown.Text; Addr.AppAddress = ControlAddress.Text; List<EnteranceExamination> LExams = new List<EnteranceExamination>(); EnteranceExamination Exam = new EnteranceExamination(); if (ControlSubject1.SelectedIndex != -1) Exam.Subject = ControlSubject1.SelectedItem.ToString(); Exam.Points = ControlPoints1.Text; if (ControlEge1.IsChecked == true) { Exam.Ege = true; Exam.Olimp = false; } if (ControlOlimp1.IsChecked == true) { Exam.Ege = false; Exam.Olimp = true; } Exam.TitleAndNum = ControlTitleAndNum1.Text; Exam.DocumentIssuedDate = ControlDocumentIssuedDate1.Text; LExams.Add(Exam); Exam = new EnteranceExamination(); if (ControlSubject2.SelectedIndex != -1) Exam.Subject = ControlSubject2.SelectedItem.ToString(); Exam.Points = ControlPoints2.Text; if (ControlEge2.IsChecked == true) { Exam.Ege = true; Exam.Olimp = false; } if (ControlOlimp2.IsChecked == true) { Exam.Ege = false; Exam.Olimp = true; } Exam.TitleAndNum = ControlTitleAndNum2.Text; Exam.DocumentIssuedDate = ControlDocumentIssuedDate2.Text; LExams.Add(Exam); Exam = new EnteranceExamination(); if (ControlSubject3.SelectedIndex != -1) Exam.Subject = ControlSubject3.SelectedItem.ToString(); Exam.Points = ControlPoints3.Text; if (ControlEge3.IsChecked == true) { Exam.Ege = true; Exam.Olimp = false; } if (ControlOlimp3.IsChecked == true) { Exam.Ege = false; Exam.Olimp = true; } Exam.TitleAndNum = ControlTitleAndNum3.Text; Exam.DocumentIssuedDate = ControlDocumentIssuedDate3.Text; LExams.Add(Exam); Exam = new EnteranceExamination(); if (ControlSubject4.SelectedIndex != -1) Exam.Subject = ControlSubject4.SelectedItem.ToString(); Exam.Points = ControlPoints4.Text; if (ControlEge4.IsChecked == true) { Exam.Ege = true; Exam.Olimp = false; } if (ControlOlimp4.IsChecked == true) { Exam.Ege = false; Exam.Olimp = true; } Exam.TitleAndNum = ControlTitleAndNum4.Text; Exam.DocumentIssuedDate = ControlDocumentIssuedDate4.Text; LExams.Add(Exam); Exam = new EnteranceExamination(); if (ControlSubject5.SelectedIndex != -1) Exam.Subject = ControlSubject5.SelectedItem.ToString(); Exam.Points = ControlPoints5.Text; if (ControlEge5.IsChecked == true) { Exam.Ege = true; Exam.Olimp = false; } if (ControlOlimp5.IsChecked == true) { Exam.Ege = false; Exam.Olimp = true; } Exam.TitleAndNum = ControlTitleAndNum5.Text; Exam.DocumentIssuedDate = ControlDocumentIssuedDate5.Text; LExams.Add(Exam); EnterRegistrationNumber ERN = new EnterRegistrationNumber(); ERN.ShowDialog(); String RN = ERN.RegNumber; if(RN.Split(new Char[] { '-' }).Length != 3) { MessageBox.Show("Неправильный формат регистрационного номера."); return; } if (RN != "") { //OMFG begins Applicant NewApplicant = new Applicant( RN, ControlFirstName.Text, ControlSecondName.Text, ControlLastName.Text, ControlBirthDate.Text, ControlBirthPlace.Text, Addr, ControlCitizenship.Text, ControlPassport.Text, ControlSerial.Text, ControlNumber.Text, ControlPassportIssuedDate.Text, ControlHomePhone.Text, ControlLearningForm.Text, ControlFunding.Text, Specs, ControlEducation.Text, ControlTypeOfEducationDocument.Text, ControlNumberOfEducationDocument.Text, ControlEducationIssuedDate.Text, LExams.ToArray(), Convert.ToBoolean(ControlAllowUniversityExams.IsChecked), ControlGrounds.Text, ControlFacilities.Text, ControlOlimpiads.Text, Convert.ToBoolean(ControlNeedDorm.IsChecked), ControlIssuedUniversityEducation.Text, Convert.ToBoolean(ControlMATICourses.IsChecked), Convert.ToBoolean(ControlMATISchool.IsChecked), Convert.ToBoolean(ControlAttest.IsChecked), ControlSex.Text, ControlSchoolType.Text, ControlSchoolName.Text ); //OMFG ends if (Convert.ToBoolean(ControlMagistrProof.IsChecked)) { Master NewMaster = new Master( ControlMagistrUniversity.Text, ControlMagistrDiploma.Text, Specs ); GenerateMasterDocuments(NewApplicant, NewMaster); string[] split = NewApplicant.RegNumber.Split(new Char[] { '-' }); GenerateUSECheck(NewApplicant, GetFacultyNumber(split[0])); //USE means Unified State Exam, ЕГЭ короче } else { if (NewApplicant.LearningForm.Equals("очной")) { File.Copy(ProgramPath + @"Шаблоны\MainFormTemplate.xls", ProgramPath + @"Документы (оч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (оч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } else if (NewApplicant.LearningForm.Equals("очно-заочной")) { File.Copy(ProgramPath + @"Шаблоны\MainFormTemplate.xls", ProgramPath + @"Документы (оч-заоч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (оч-заоч)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } else { if (File.Exists(ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls")) { MessageBoxResult result = MessageBox.Show(this, "Документ с таким именем уже существует и будет безвозвратно утерян. Продолжить?", "Предупреждение!", MessageBoxButton.YesNo, MessageBoxImage.Warning, MessageBoxResult.No, MessageBoxOptions.None); if(result == MessageBoxResult.No) return; else File.Delete(ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } File.Copy(ProgramPath + @"Шаблоны\MainFormTemplate.xls", ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); ExcelForm = new ExcelFunc(); ExcelForm.OpenDocument(ProgramPath + @"Документы (др)\" + NewApplicant.SecondName + " " + NewApplicant.RegNumber + ".xls"); } FillExcelForm(NewApplicant); ExcelForm.OpenWorksheet(2); FillExcelRequest(NewApplicant); ExcelForm.OpenWorksheet(3); FillExcelFacultiesList(NewApplicant); ExcelForm.OpenWorksheet(4); FillExcelContract(NewApplicant); ExcelForm.OpenWorksheet(5); FillExcelLKS(NewApplicant); ExcelForm.OpenWorksheet(6); FillExcelProfile(NewApplicant); ExcelForm.OpenWorksheet(7); FillExcelListOfExams(NewApplicant); ExcelForm.OpenWorksheet(8); FillExcelReceipt(NewApplicant); ExcelForm.CloseDocument(); int Fac; if (NewApplicant.Specs[0] != null) { String SFac = NewApplicant.RegNumber.Remove(2, (NewApplicant.RegNumber.Length - 2)); SFac = GetFacultyNumber(SFac); Int32.TryParse(SFac, out Fac); FillSummary(0, NewApplicant); } } } try { ExcelForm.CloseDocument(); ExcelForm.Dispose(); } catch { // Тут нет костыля. Совсем. Иди отсюда мальчик. Или девочка. В общем, вали быстро! // It's a lion! Get in the car! } try { ExcelSummary.CloseDocument(); ExcelForm.Dispose(); } catch { // Тут нет костыля. Совсем. Иди отсюда мальчик. Или девочка. В общем, вали быстро! // It's a lion! Get in the car! } }