Ibrahim Jarif created CLIMATE-798:
-------------------------------------

             Summary: Redundant code in evaluations.py
                 Key: CLIMATE-798
                 URL: https://issues.apache.org/jira/browse/CLIMATE-798
             Project: Apache Open Climate Workbench
          Issue Type: Bug
            Reporter: Ibrahim Jarif
            Assignee: Ibrahim Jarif
            Priority: Minor


The following 4 code sections in *evaluation.py* file are redundant and will 
never execute under any working condition.

1. *convert_evaluation_result* function *lines 360 - 365*
{code}
if evaluation_result[0][imetric].ndim !=0:
                result_shape = list(evaluation_result[0][imetric].shape)
                result_shape.insert(0, nmodel)
                result = ma.zeros(result_shape)
                for imodel in range(nmodel):
                    result[imodel,:] = evaluation_result[imodel][imetric]
{code}
The ndim of any possible index of *evaluation_result* array will always be 
*greater than zero* because this function is only called by 
*_run_subregion_evaluation* function (line 273) which appends an *[] element* 
(line 278){code}results.append([])
{code} to the *results* array (the result array is the evaluation_result 
array). So the ndim value of all the indexes of result array *becomes greater 
than zero* ( the ndim value of an empty array i.e array = [[]] is also 1).
So the above lines are never executed. Hence they should be removed.

The next 3 points have same explanation as 1.

2. *convert_evaluation_result* function *lines 381 - 386*.
{code}
if evaluation_result[0][imetric][isubregion].ndim !=0:
                    result_shape = 
list(evaluation_result[0][imetric][isubregion].shape)
                    result_shape.insert(0, nmodel)
                    result = ma.zeros(result_shape)
                    for imodel in range(nmodel):
                        result[imodel,:] = 
evaluation_result[imodel][imetric][isubregion]
{code}

3.*convert_unary_evaluation_result* function *lines 401 - 406*
{code}
if evaluation_result[imetric][0].ndim !=0:
                result_shape = list(evaluation_result[imetric][0].shape)
                result_shape.insert(0, nmodel)
                result = ma.zeros(result_shape)
                for imodel in range(nmodel):
                    result[imodel,:] = evaluation_result[imet
{code}

4.*convert_unary_evaluation_result* function *lines 422 - 427*
{code}
if evaluation_result[imetric][isubregion][0].ndim !=0:
                    result_shape = 
list(evaluation_result[imetric][isubregion][0].shape)
                    result_shape.insert(0, nmodel)
                    result = ma.zeros(result_shape)
                    for imodel in range(nmodel):
                        result[imodel,:] = 
evaluation_result[imetric][isubregion][imodel]
{code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to