climate-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (CLIMATE-789) Remove redundant code in temporal_resolution function
Date Tue, 24 May 2016 17:40:12 GMT

    [ https://issues.apache.org/jira/browse/CLIMATE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15298581#comment-15298581
] 

ASF GitHub Bot commented on CLIMATE-789:
----------------------------------------

Github user jarifibrahim closed the pull request at:

    https://github.com/apache/climate/pull/337


> Remove redundant code in temporal_resolution function
> -----------------------------------------------------
>
>                 Key: CLIMATE-789
>                 URL: https://issues.apache.org/jira/browse/CLIMATE-789
>             Project: Apache Open Climate Workbench
>          Issue Type: Task
>          Components: general
>            Reporter: Ibrahim Jarif
>            Assignee: Ibrahim Jarif
>            Priority: Trivial
>              Labels: easyfix
>
> *Last 8 lines (ValueError Exception condition)* of *temporal_resolution* function of
*dataset.py* are redundant. The condition never occurs as the *times* variable is of type
*DateTime*. All the cases are handled by the *if and elif*. There is no need for the *else*
clause.
> {code}
> def temporal_resolution(self):
>   sorted_times = numpy.sort(self.times)
>   time_resolution = sorted_times[1] - sorted_times[0]
>   num_days = time_resolution.days
>   if num_days == 0:
>     num_hours = time_resolution.seconds / 3600
>     time_resolution = 'hourly' if num_hours >= 1 else 'minutely'
>   elif num_days == 1:
>     time_resolution = 'daily'
>   elif num_days <= 31:
>     time_resolution = 'monthly'
>   elif num_days > 31:
>     time_resolution = 'yearly'
>   else:
>     error = (
>         "Unable to calculate the temporal resolution for the "
>         "dataset. The number of days between two time values is "
>         "an unexpected value: " + str(num_days)
>     )
>     logger.error(error)
>     raise ValueError(error)
> {code}



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

Mime
View raw message