Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/14/16 22:38:23 (8 years ago)
Author:
mkommend
Message:

#2559: Merged r13502, r13504, r13507, r13508, r13512, r13514, r13517 into stable.

Location:
stable
Files:
3 edited
1 copied

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.DataPreprocessing/3.4

  • stable/HeuristicLab.DataPreprocessing/3.4/Data/TransactionalPreprocessingData.cs

    r13508 r14075  
    216216    }
    217217
     218
     219    public override void InsertRow(int rowIndex) {
     220      SaveSnapshot(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex);
     221      foreach (IList column in variableValues) {
     222        Type type = column.GetType().GetGenericArguments()[0];
     223        column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null);
     224      }
     225      if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) {
     226        TrainingPartition.End++;
     227        if (TrainingPartition.End <= TestPartition.Start) {
     228          TestPartition.Start++;
     229          TestPartition.End++;
     230        }
     231      } else if (TestPartition.Start <= rowIndex && rowIndex <= TestPartition.End) {
     232        TestPartition.End++;
     233        if (TestPartition.End <= TrainingPartition.Start) {
     234          TestPartition.Start++;
     235          TestPartition.End++;
     236        }
     237      }
     238      if (!IsInTransaction)
     239        OnChanged(DataPreprocessingChangedEventType.AddRow, -1, rowIndex);
     240    }
     241    public override void DeleteRow(int rowIndex) {
     242      SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, rowIndex);
     243      foreach (IList column in variableValues) {
     244        column.RemoveAt(rowIndex);
     245      }
     246      if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) {
     247        TrainingPartition.End--;
     248        if (TrainingPartition.End <= TestPartition.Start) {
     249          TestPartition.Start--;
     250          TestPartition.End--;
     251        }
     252      } else if (TestPartition.Start <= rowIndex && rowIndex <= TestPartition.End) {
     253        TestPartition.End--;
     254        if (TestPartition.End <= TrainingPartition.Start) {
     255          TestPartition.Start--;
     256          TestPartition.End--;
     257        }
     258      }
     259      if (!IsInTransaction)
     260        OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex);
     261    }
    218262    public override void DeleteRowsWithIndices(IEnumerable<int> rows) {
    219263      SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, -1);
     
    222266          column.RemoveAt(rowIndex);
    223267        }
     268        if (TrainingPartition.Start <= rowIndex && rowIndex <= TrainingPartition.End) {
     269          TrainingPartition.End--;
     270          if (TrainingPartition.End <= TestPartition.Start) {
     271            TestPartition.Start--;
     272            TestPartition.End--;
     273          }
     274        } else if (TestPartition.Start <= rowIndex && rowIndex <= TestPartition.End) {
     275          TestPartition.End--;
     276          if (TestPartition.End <= TrainingPartition.Start) {
     277            TestPartition.Start--;
     278            TestPartition.End--;
     279          }
     280        }
    224281      }
    225282      if (!IsInTransaction)
    226283        OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, -1);
    227       ResetPartitions();
    228     }
    229 
    230     public override void InsertRow(int rowIndex) {
    231       SaveSnapshot(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex);
    232       foreach (IList column in variableValues) {
    233         Type type = column.GetType().GetGenericArguments()[0];
    234         column.Insert(rowIndex, type.IsValueType ? Activator.CreateInstance(type) : null);
    235       }
    236       if (!IsInTransaction)
    237         OnChanged(DataPreprocessingChangedEventType.AddRow, -1, rowIndex);
    238       ResetPartitions();
    239     }
    240 
    241     public override void DeleteRow(int rowIndex) {
    242       SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, rowIndex);
    243       foreach (IList column in variableValues) {
    244         column.RemoveAt(rowIndex);
    245       }
    246       if (!IsInTransaction)
    247         OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex);
    248       ResetPartitions();
    249284    }
    250285
     
    308343      if (listeners != null) listeners(this, EventArgs.Empty);
    309344    }
    310 
    311 
    312     private void ResetPartitions() {
    313       TrainingPartition = new IntRange();
    314       TestPartition = new IntRange();
    315     }
    316 
    317345    #endregion
    318346
Note: See TracChangeset for help on using the changeset viewer.