IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jun 1, 2006, 2:55:23 PM (20 years ago)
Author:
Paul Price
Message:

Addition of a vast quantity of assertions in public functions. Adopted a policy of using assert() within file-static functions (since they are only called internally, any errors there are problems with the program) and using the PS_ASSERT_WHATEVER() macros within public functions. Cleaned a few things up in the process.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psModules/src/imcombine/pmReadoutCombine.c

    r7259 r7278  
    55 *  @author GLG, MHPCC
    66 *
    7  *  @version $Revision: 1.13 $ $Name: not supported by cvs2svn $
    8  *  @date $Date: 2006-06-01 03:39:15 $
     7 *  @version $Revision: 1.14 $ $Name: not supported by cvs2svn $
     8 *  @date $Date: 2006-06-02 00:55:23 $
    99 *
    1010 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    3030                            )
    3131{
     32    assert(stats);
     33
    3234    switch (option) {
    3335    case PS_STAT_SAMPLE_MEAN:
     
    9698    if (zero) {
    9799        PS_ASSERT_VECTOR_TYPE(zero, PS_TYPE_F32, false);
    98         if (zero->n != inputs->n) {
    99             psError(PS_ERR_UNKNOWN, true, "Zero vector has incorrect size (%d vs %d).\n",
    100                     zero->n, inputs->n);
    101             return false;
    102         }
     100        PS_ASSERT_VECTOR_SIZE(zero, inputs->n, false);
    103101    }
    104102    if (scale) {
    105103        PS_ASSERT_VECTOR_TYPE(scale, PS_TYPE_F32, false);
    106         if (scale->n != inputs->n) {
    107             psError(PS_ERR_UNKNOWN, true, "Scale vector has incorrect size (%d vs %d).\n",
    108                     scale->n, inputs->n);
    109             return false;
    110         }
    111     }
    112     assert(params->fracLow >= 0.0 && params->fracLow < 1.0);
    113     assert(params->fracHigh >= 0.0 && params->fracHigh < 1.0);
    114     assert(params->combine == PS_STAT_SAMPLE_MEAN ||
    115            params->combine == PS_STAT_SAMPLE_MEDIAN ||
    116            params->combine == PS_STAT_ROBUST_MEDIAN ||
    117            params->combine == PS_STAT_FITTED_MEAN ||
    118            params->combine == PS_STAT_CLIPPED_MEAN);
     104        PS_ASSERT_VECTOR_SIZE(scale, inputs->n, false);
     105    }
     106    PS_ASSERT_FLOAT_WITHIN_RANGE(params->fracLow, 0.0, 1.0, false);
     107    PS_ASSERT_FLOAT_WITHIN_RANGE(params->fracHigh, 0.0, 1.0, false);
     108    if (params->combine != PS_STAT_SAMPLE_MEAN && params->combine != PS_STAT_SAMPLE_MEDIAN &&
     109            params->combine != PS_STAT_ROBUST_MEDIAN && params->combine != PS_STAT_FITTED_MEAN &&
     110            params->combine != PS_STAT_CLIPPED_MEAN) {
     111        psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Combination method is not SAMPLE_MEAN, SAMPLE_MEDIAN, "
     112                "ROBUST_MEDIAN, FITTED_MEAN or CLIPPED_MEAN.\n");
     113        return false;
     114    }
    119115
    120116    psStats *stats = psStatsAlloc(params->combine); // The statistics to use in the combination
Note: See TracChangeset for help on using the changeset viewer.