Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 2595F2009EE for ; Wed, 18 May 2016 18:42:17 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 243D2160A00; Wed, 18 May 2016 16:42:17 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 6B91E1609B0 for ; Wed, 18 May 2016 18:42:16 +0200 (CEST) Received: (qmail 69403 invoked by uid 500); 18 May 2016 16:42:15 -0000 Mailing-List: contact dev-help@climate.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@climate.apache.org Delivered-To: mailing list dev@climate.apache.org Received: (qmail 69392 invoked by uid 99); 18 May 2016 16:42:15 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 16:42:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 37A6418056A for ; Wed, 18 May 2016 16:42:15 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -4.021 X-Spam-Level: X-Spam-Status: No, score=-4.021 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, RP_MATCHES_RCVD=-0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id a43ssrI0-5eI for ; Wed, 18 May 2016 16:42:14 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with SMTP id 440155F1E7 for ; Wed, 18 May 2016 16:42:14 +0000 (UTC) Received: (qmail 69216 invoked by uid 99); 18 May 2016 16:42:13 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 18 May 2016 16:42:13 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id 7DA7E2C1F79 for ; Wed, 18 May 2016 16:42:13 +0000 (UTC) Date: Wed, 18 May 2016 16:42:13 +0000 (UTC) From: "Ibrahim Jarif (JIRA)" To: dev@climate.incubator.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Resolved] (CLIMATE-789) Remove redundant code in temporal_resolution function MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Wed, 18 May 2016 16:42:17 -0000 [ https://issues.apache.org/jira/browse/CLIMATE-789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Ibrahim Jarif resolved CLIMATE-789. ----------------------------------- Resolution: Fixed > 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)