Ibrahim Jarif created CLIMATE-789:
-------------------------------------
Summary: 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
*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)