You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@climate.apache.org by bo...@apache.org on 2014/05/29 22:53:54 UTC
[1/4] git commit: CLIMATE-448 Use 'dateutil.relativedelta' to get
'next-month' datetime in decode_time_values' function and fixed unittest.
Repository: climate
Updated Branches:
refs/heads/master 67fd821b2 -> fd6f97926
CLIMATE-448 Use 'dateutil.relativedelta' to get 'next-month' datetime in decode_time_values' function and fixed unittest.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/32d648be
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/32d648be
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/32d648be
Branch: refs/heads/master
Commit: 32d648be0eb821cee5595d3ec632e2eaf9f84208
Parents: 23af110
Author: Maziyar Boustani <ma...@yahoo.com>
Authored: Thu May 29 13:09:03 2014 -0700
Committer: Maziyar Boustani <ma...@yahoo.com>
Committed: Thu May 29 13:09:03 2014 -0700
----------------------------------------------------------------------
ocw/tests/test_utils.py | 4 ++--
ocw/utils.py | 5 ++---
2 files changed, 4 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/32d648be/ocw/tests/test_utils.py
----------------------------------------------------------------------
diff --git a/ocw/tests/test_utils.py b/ocw/tests/test_utils.py
index 6044d2f..48beb43 100644
--- a/ocw/tests/test_utils.py
+++ b/ocw/tests/test_utils.py
@@ -39,8 +39,8 @@ class TestDecodeTimes(unittest.TestCase):
self.assertTrue(all([type(x) is datetime.datetime for x in times]))
def test_valid_time_processing(self):
- start_time = datetime.datetime.strptime('1988-06-10 00:00:00', '%Y-%m-%d %H:%M:%S')
- end_time = datetime.datetime.strptime('2008-01-27 00:00:00', '%Y-%m-%d %H:%M:%S')
+ start_time = datetime.datetime.strptime('1989-01-01 00:00:00', '%Y-%m-%d %H:%M:%S')
+ end_time = datetime.datetime.strptime('2008-12-01 00:00:00', '%Y-%m-%d %H:%M:%S')
times = utils.decode_time_values(self.netcdf, 'time')
self.assertEquals(times[0], start_time)
http://git-wip-us.apache.org/repos/asf/climate/blob/32d648be/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index ec4a021..da3dcc1 100644
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -22,7 +22,7 @@ import datetime as dt
import numpy as np
from mpl_toolkits.basemap import shiftgrid
-
+from dateutil.relativedelta import relativedelta
def decode_time_values(dataset, time_var_name):
''' Decode NetCDF time values into Python datetime objects.
@@ -50,8 +50,7 @@ def decode_time_values(dataset, time_var_name):
# datetime.timedelta doesn't support a 'months' option. To remedy
# this, a month == 30 days for our purposes.
for time_val in time_data:
- num_days = 30 * time_val
- times.append(time_base + dt.timedelta(days=num_days))
+ times.append(time_base + relativedelta(months = int(time_val)))
else:
for time_val in time_data:
arg[time_units] = time_val
[3/4] git commit: CLIMATE-448 Use 'dateutil.relativedelta' to get
'next-month' datetime in decode_time_values' function and fixed unittest.
Posted by bo...@apache.org.
CLIMATE-448 Use 'dateutil.relativedelta' to get 'next-month' datetime in decode_time_values' function and fixed unittest.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/435f49ad
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/435f49ad
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/435f49ad
Branch: refs/heads/master
Commit: 435f49ad99c904f5da523c0abb701ef300369df3
Parents: 866c161
Author: Maziyar Boustani <ma...@yahoo.com>
Authored: Thu May 29 13:44:39 2014 -0700
Committer: Maziyar Boustani <ma...@yahoo.com>
Committed: Thu May 29 13:44:39 2014 -0700
----------------------------------------------------------------------
ocw/utils.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/435f49ad/ocw/utils.py
----------------------------------------------------------------------
diff --git a/ocw/utils.py b/ocw/utils.py
index da3dcc1..7abbbfd 100644
--- a/ocw/utils.py
+++ b/ocw/utils.py
@@ -50,7 +50,7 @@ def decode_time_values(dataset, time_var_name):
# datetime.timedelta doesn't support a 'months' option. To remedy
# this, a month == 30 days for our purposes.
for time_val in time_data:
- times.append(time_base + relativedelta(months = int(time_val)))
+ times.append(time_base + relativedelta(months=int(time_val)))
else:
for time_val in time_data:
arg[time_units] = time_val
[4/4] git commit: Merge branch 'CLIMATE-448', Resolve CLIMATE-448,
Merge PR # 49.
Posted by bo...@apache.org.
Merge branch 'CLIMATE-448', Resolve CLIMATE-448, Merge PR # 49.
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/fd6f9792
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/fd6f9792
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/fd6f9792
Branch: refs/heads/master
Commit: fd6f97926ad94c66deac2ab6c0a7c2a021b098df
Parents: 67fd821 435f49a
Author: Maziyar Boustani <ma...@yahoo.com>
Authored: Thu May 29 13:53:06 2014 -0700
Committer: Maziyar Boustani <ma...@yahoo.com>
Committed: Thu May 29 13:53:06 2014 -0700
----------------------------------------------------------------------
ocw-ui/backend/tests/test_local_file_metadata_extractors.py | 8 ++++----
ocw/tests/test_utils.py | 4 ++--
ocw/utils.py | 5 ++---
3 files changed, 8 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
[2/4] git commit: CLIMATE-448 update the backend unittest for
test_local_file_metadata_extractors.py
Posted by bo...@apache.org.
CLIMATE-448 update the backend unittest for test_local_file_metadata_extractors.py
Project: http://git-wip-us.apache.org/repos/asf/climate/repo
Commit: http://git-wip-us.apache.org/repos/asf/climate/commit/866c1611
Tree: http://git-wip-us.apache.org/repos/asf/climate/tree/866c1611
Diff: http://git-wip-us.apache.org/repos/asf/climate/diff/866c1611
Branch: refs/heads/master
Commit: 866c1611f808087356a165c6272544d473753e91
Parents: 32d648b
Author: Maziyar Boustani <ma...@yahoo.com>
Authored: Thu May 29 13:37:21 2014 -0700
Committer: Maziyar Boustani <ma...@yahoo.com>
Committed: Thu May 29 13:37:21 2014 -0700
----------------------------------------------------------------------
ocw-ui/backend/tests/test_local_file_metadata_extractors.py | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/climate/blob/866c1611/ocw-ui/backend/tests/test_local_file_metadata_extractors.py
----------------------------------------------------------------------
diff --git a/ocw-ui/backend/tests/test_local_file_metadata_extractors.py b/ocw-ui/backend/tests/test_local_file_metadata_extractors.py
index f204fdb..2e469dd 100644
--- a/ocw-ui/backend/tests/test_local_file_metadata_extractors.py
+++ b/ocw-ui/backend/tests/test_local_file_metadata_extractors.py
@@ -105,8 +105,8 @@ class TestTimeExtraction(unittest.TestCase):
expected_return = {
"success": True,
"time_name": "time",
- "start_time": "1988-06-10 00:00:00",
- "end_time": "2008-01-27 00:00:00"
+ "start_time": "1989-01-01 00:00:00",
+ "end_time": "2008-12-01 00:00:00"
}
file_location = os.path.abspath('tests/example_data/lat_lon_time.nc')
@@ -119,8 +119,8 @@ class TestTimeExtraction(unittest.TestCase):
expected_return = {
"success": True,
"time_name": "time",
- "start_time": "1988-06-10 00:00:00",
- "end_time": "2008-01-27 00:00:00"
+ "start_time": "1989-01-01 00:00:00",
+ "end_time": "2008-12-01 00:00:00"
}
file_location = os.path.abspath('tests/example_data/lat_lon_time.nc')