Ejemplo n.º 1
0
 /// <summary>
 /// Approximated comparison between two dataframes.
 /// It returns 0 if the difference is below the precision
 /// or the difference otherwise, Inf if shapes or schema are different.
 /// </summary>
 public double AlmostEquals(DataFrame df, double precision = 1e-6f, bool exc = false, bool printDf = false)
 {
     if (exc && printDf)
     {
         try
         {
             return(_data.AlmostEquals(df._data, precision, exc));
         }
         catch (Exception e)
         {
             var addition = $"----\n{ToString()}\n-----\n{df.ToString()}";
             throw new Exception(addition, e);
         }
     }
     else
     {
         return(_data.AlmostEquals(df._data, precision, exc));
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Approximated comparison between two dataframes.
 /// It returns 0 if the difference is below the precision
 /// or the difference otherwise, Inf if shapes or schema are different.
 /// </summary>
 public double AlmostEquals(DataFrame df, double precision = 1e-6f, bool exc = false,
                            bool printDf = false, string sortBy = null)
 {
     if (!string.IsNullOrEmpty(sortBy))
     {
         if (!HasColumn(sortBy))
         {
             throw Contracts.Except($"Unable to find column '{sortBy}'.");
         }
         if (!df.HasColumn(sortBy))
         {
             throw Contracts.Except($"Unable to find column '{sortBy}'.");
         }
         var df1 = Copy();
         df1.Sort(new[] { sortBy });
         var df2 = df.Copy();
         df2.Sort(new[] { sortBy });
         return(df1.AlmostEquals(df2, precision, exc, printDf));
     }
     if (exc && printDf)
     {
         try
         {
             return(_data.AlmostEquals(df._data, precision, exc));
         }
         catch (Exception e)
         {
             var addition = $"----\n{ToString()}\n-----\n{df.ToString()}";
             throw new Exception(addition, e);
         }
     }
     else
     {
         return(_data.AlmostEquals(df._data, precision, exc));
     }
 }