gnudatalanguage / gdl

GDL - GNU Data Language
GNU General Public License v2.0
274 stars 61 forks source link

Check all basic operators results in all possible cases #1784

Closed GillesDuvert closed 5 months ago

GillesDuvert commented 5 months ago

added test_indepth_basic_functions.pro and modified code to insure ~1200 tests on OPERATORS are similar to IDL.

codecov[bot] commented 5 months ago

Codecov Report

Attention: Patch coverage is 78.04054% with 65 lines in your changes are missing coverage. Please review.

Project coverage is 43.73%. Comparing base (2980154) to head (eb9e313).

Files Patch % Lines
src/basic_op_new.cpp 59.01% 25 Missing :warning:
src/basic_op.cpp 70.21% 14 Missing :warning:
src/snippets/basic_op_GtMarkNewCplx.incpp 60.00% 4 Missing :warning:
src/snippets/basic_op_LtMarkNewCplx.incpp 60.00% 4 Missing :warning:
src/snippets/basic_op_AndOpCplx.incpp 57.14% 3 Missing :warning:
src/snippets/basic_op_AndOpInv.incpp 57.14% 3 Missing :warning:
src/snippets/basic_op_LtMarkSNewCplx.incpp 83.33% 2 Missing :warning:
src/snippets/basic_op_AndOpInvS.incpp 90.90% 1 Missing :warning:
src/snippets/basic_op_DivInvSCplx.incpp 91.66% 1 Missing :warning:
src/snippets/basic_op_DivInvSNew.incpp 92.30% 1 Missing :warning:
... and 7 more
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1784 +/- ## ========================================== + Coverage 42.70% 43.73% +1.02% ========================================== Files 361 376 +15 Lines 97331 97398 +67 Branches 19928 19919 -9 ========================================== + Hits 41570 42596 +1026 + Misses 55761 54802 -959 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

GillesDuvert commented 5 months ago

The test_indepth_basic_functions.pro brutally explores 95 different operators defined in files basic_op_xxx.pro, for a combination of the following cases:

  1. The 10 different numeric operand types (BYTE to DCOMPLEX)
  2. The size of each operand: scalar, array of 1 element, array of > 1 element
  3. The respective sizes of the two operands for operators using two operands (like in c= a + b ), the code is not the same when a is smaller of greater than b.
  4. The persistence of the operand, like in c = a + temporary(b)

Because each of these cases need a special code, for speed and memory optimization (this was written by Marc in the very first version of GDL, at least for 90% of the operators), the number of combinations explored is around 11000 cases.

The result of the procedure is a ~24000 lines text file that can be compared with an equivalent IDL output. The present PR introduces a number of code patches or additions to insure even obscure operator+operand combination give the same result as IDL. The GDL and IDL produced files are identical, with the exception of the signedness of a few NaN or Inf results in case or zero division of complex values.

As each operator is also optimized to use parallel processing on operands as soon as the number of elements is greater than !CPU.TPOOL_MIN_ELTS, the test_indepth_basic_functions.pro procedure can also be used to check that the parallelized results are identical to the single cpu ones (*). This has been checked too. _Note that testing the equivalence of results between single and many cpu as performed in the test_indepth_basic_functions.pro procedure with IDL will... crash IDL on some complex values, so this part of procedure is deactivated with IDL._

(*) TPOOL (Thread Pool) using functions cannot in general be expected to provide exactly the same result in parallell or not parallell mode: TOTAL() is an example. But operators do.