Exemple #1
0
        //Methods
        /// <summary>
        /// Plans set of values to be tested.
        /// </summary>
        /// <param name="min">Min value</param>
        /// <param name="minErr">Error corresponding to min value</param>
        /// <param name="max">Min value</param>
        /// <param name="maxErr">Error corresponding to max value</param>
        private void Replan(double min, double minErr, double max, double maxErr)
        {
            double stepSize = (max - min) / _settings.NumOfSteps;
            double value    = min;

            _planIdx = 0;
            for (int i = 0; i <= _settings.NumOfSteps; i++)
            {
                _plannedValues[i] = new ValueError {
                    Value = value, Error = double.NaN
                };
                if (i == 0 && !double.IsNaN(minErr))
                {
                    //Error is already known
                    _plannedValues[i].Error = minErr;
                    _planIdx = 1;
                }
                else if (i == _settings.NumOfSteps && !double.IsNaN(maxErr))
                {
                    //Error is already known
                    _plannedValues[i].Error = maxErr;
                }
                value += stepSize;
            }
            return;
        }
        /// <summary>
        /// delete given data from a selected table
        /// </summary>
        public void DeleteData()
        {
            string table = TablesComboBox.SelectedItem.ToString();

            if (CheckID(DeleteIDBox))
            {
                ValueError.Clear();
                switch (table)
                {
                case "Students":
                    int stdid = Convert.ToInt32(DeleteIDBox.Text.ToString());
                    Data.RemoveItem(stdid);
                    break;

                case "Courses":
                    int courseid = Convert.ToInt32(DeleteIDBox.Text.ToString());
                    Data.RemoveItem(courseid);
                    break;

                case "Instructors":
                    int instid = Convert.ToInt32(DeleteIDBox.Text.ToString());
                    Data.RemoveItem(instid);
                    break;

                case "Enrollments":
                    int stdEnroll = Convert.ToInt32(DeleteIDBox.Text.ToString());
                    Data.RemoveItem(stdEnroll);
                    break;
                }
            }
        }
 protected void RaiseError(ValueError error)
 {
     if (this._errorHandlers.Count > 0)
     {
         var handler = this._errorHandlers.Peek();
         handler(this, new ErrorEventArg(error));
     }
 }
        private void ViewButton_Click(object sender, EventArgs e)
        {
            ClearDataGridView();

            if (FilterByComboBox.SelectedItem.ToString() == "None")
            {
                UpdateDataGridView(Data.GetAll());
            }

            else if (CheckID(FilterIDBox))
            {
                ValueError.Clear();
                int       id        = Convert.ToInt32(FilterIDBox.Text);
                DataTable dataTable = GetDataTable(id);
                UpdateDataGridView(dataTable);
            }
        }
 /// <summary>
 /// returns true if the givin id is integer false otherwise
 /// </summary>
 /// <returns>Bool</returns>
 private bool CheckID(TextBox box)
 {
     if (FilterIDBox.Text != "")
     {
         try
         {
             int ID = Convert.ToInt32(box.Text);
             return(true);
         }
         catch (Exception ex)
         {
             ValueError.SetError(box, ex.ToString());
             return(false);
         }
     }
     else
     {
         ValueError.SetError(box, "ID Value is empty");
         return(false);
     }
 }
        /// <summary>
        /// insert given data to a selected table
        /// </summary>
        private void InsertData()
        {
            string table = TablesComboBox.SelectedItem.ToString();

            if (CheckID(InsertIDBox))
            {
                ValueError.Clear();
                switch (table)
                {
                case "Students":
                    int    stdid   = Convert.ToInt32(InsertIDBox.Text.ToString());
                    string stdname = InsertNameBox.Text.ToString();
                    Data.AddItem(stdid, stdname);
                    break;

                case "Courses":
                    int    courseid   = Convert.ToInt32(InsertIDBox.Text.ToString());
                    string coursename = InsertNameBox.Text.ToString();
                    string coursedesc = InsertCourseDescBox.Text.ToString();
                    int    courseinst = Convert.ToInt32(InsertCourseInstBox.Text.ToString());
                    Data.AddItem(courseid, coursename, coursedesc, courseinst);
                    break;

                case "Instructors":
                    int    instid   = Convert.ToInt32(InsertIDBox.Text.ToString());
                    string instname = InsertNameBox.Text.ToString();
                    Data.AddItem(instid, instname);
                    break;

                case "Enrollments":
                    int courseEnroll = Convert.ToInt32(InsertIDBox.Text.ToString());
                    int stdEnroll    = Convert.ToInt32(InsertNameBox.Text.ToString());
                    Data.AddItem(courseEnroll, stdEnroll);
                    break;
                }
            }
        }
Exemple #7
0
 /// <summary>
 /// Raises the ValueError event and performs custom processing</summary>
 protected virtual void OnValueError()
 {
     ValueError.Raise(this, EventArgs.Empty);
 }
 assert_raises(ValueError, cval.train_test_split, range(3), range(42))
 assert_raises(ValueError, cval.train_test_split, range(3), test_size  = 0.6,
 assert_raises(ValueError, cval.train_test_split)
 public ErrorEventArg(ValueError error)
 {
     this.Error = error;
 }
 assert_raises(ValueError, cval.train_test_split, range(3), range(42))
 assert_raises(ValueError, cval.train_test_split, range(3), test_size=0.6,
 assert_raises(ValueError, cval.train_test_split)