[Git][debian-gis-team/cftime][master] 4 commits: New upstream version 1.1.1+ds

Bas Couwenberg gitlab at salsa.debian.org
Mon Mar 16 04:58:05 GMT 2020



Bas Couwenberg pushed to branch master at Debian GIS Project / cftime


Commits:
7d675063 by Bas Couwenberg at 2020-03-16T05:44:14+01:00
New upstream version 1.1.1+ds
- - - - -
741be807 by Bas Couwenberg at 2020-03-16T05:44:14+01:00
Update upstream source from tag 'upstream/1.1.1+ds'

Update to upstream version '1.1.1+ds'
with Debian dir 4bc2ba5ae6a8d1b1e0fbb59c9796156754fd5e2a
- - - - -
b38d3381 by Bas Couwenberg at 2020-03-16T05:44:27+01:00
New upstream release.

- - - - -
4ebc57e5 by Bas Couwenberg at 2020-03-16T05:44:59+01:00
Set distribution to unstable.

- - - - -


5 changed files:

- Changelog
- README.md
- cftime/_cftime.pyx
- debian/changelog
- test/test_cftime.py


Changes:

=====================================
Changelog
=====================================
@@ -1,5 +1,11 @@
-version 1.1.0 (not yet released)
-================================
+version 1.1.1 (release tag v1.1.1rel)
+=====================================
+
+ * fix microsecond formatting issue, ensure identical results
+   computed for arrays and scales (issue #143, PR #146).
+
+version 1.1.0 (release tag v1.1.0rel)
+=====================================
 
  * improved exceptions for time differences (issue #128, PR #131).
 


=====================================
README.md
=====================================
@@ -12,8 +12,10 @@ Time-handling functionality from netcdf4-python
 ## News
 For details on the latest updates, see the [Changelog](https://github.com/Unidata/cftime/blob/master/Changelog).
 
-2/12/2019:  version 1.1.0 released.  `cftime.datetime` instances are returned by default from `num2date`
-(instead of returning python datetime instances where possible ([issue #136](https://github.com/Unidata/cftime/issues/136)).  `num2pydate`
+3/16/2020:  version 1.1.1 released.  Fix bug in microsecond formatting, ensure identical num2date results if input is an array of times, or a single scalar ([issue #143](https://github.com/Unidata/cftime/issues/143)).
+
+2/12/2020:  version 1.1.0 released.  `cftime.datetime` instances are returned by default from `num2date`
+(instead of returning python datetime instances where possible ([issue #136](https://github.com/Unidata/cftime/issues/136))).  `num2pydate`
 convenience function added (always returns python datetime instances, [issue #134](https://github.com/Unidata/cftime/issues/134)). Fix for
 fraction seconds in reference date string ([issue #140](https://github.com/Unidata/cftime/issues/140)). Added `daysinmonth` attribute 
 ([issue #137](https://github.com/Unidata/cftime/issues/137)).


=====================================
cftime/_cftime.pyx
=====================================
@@ -52,7 +52,7 @@ cdef int32_t* days_per_month_array = [
 _rop_lookup = {Py_LT: '__gt__', Py_LE: '__ge__', Py_EQ: '__eq__',
                Py_GT: '__lt__', Py_GE: '__le__', Py_NE: '__ne__'}
 
-__version__ = '1.1.0'
+__version__ = '1.1.1'
 
 # Adapted from http://delete.me.uk/2005/03/iso8601.html
 # Note: This regex ensures that all ISO8601 timezone formats are accepted - but, due to legacy support for other timestrings, not all incorrect formats can be rejected.
@@ -539,9 +539,10 @@ def DateFromJulianDay(JD, calendar='standard', only_use_cftime_datetimes=True,
             year[i],month[i],day[i],dayofwk[i],dayofyr[i] = _IntJulianDayToDate(ijd,calendar)
 
         if calendar in ['standard', 'gregorian']:
-            ind_before = np.where(julian < 2299160.5)[0]
+            ind_before = np.where(julian < 2299160.5)
+            ind_before = np.asarray(ind_before).any()
         else:
-            ind_before = None
+            ind_before = False
 
         # compute hour, minute, second, microsecond, convert to int32
         hour = np.clip((F * 24.).astype(np.int64), 0, 23)
@@ -572,8 +573,8 @@ def DateFromJulianDay(JD, calendar='standard', only_use_cftime_datetimes=True,
     indxms = microsecond > 1000000-ms_eps
     if indxms.any():
         julian[indxms] = julian[indxms] + 2*ms_eps[indxms]/86400000000.
-        year,month,day,hour,minute,second,microsecond,dayofyr,dayofwk,ind_before =\
-        getdateinfo(julian)
+        year[indxms],month[indxms],day[indxms],hour[indxms],minute[indxms],second[indxms],microsecond2,dayofyr[indxms],dayofwk[indxms],ind_before2 =\
+        getdateinfo(julian[indxms])
         microsecond[indxms] = 0
 
     # check if input was scalar and change return accordingly
@@ -599,7 +600,7 @@ def DateFromJulianDay(JD, calendar='standard', only_use_cftime_datetimes=True,
         # return a 'real' datetime instance if calendar is proleptic
         # Gregorian or Gregorian and all dates are after the
         # Julian/Gregorian transition
-        if len(ind_before) == 0 and not only_use_cftime_datetimes:
+        if ind_before and not only_use_cftime_datetimes:
             is_real_datetime = True
             datetime_type = real_datetime
         else:
@@ -1327,7 +1328,7 @@ Gregorial calendar.
     def __str__(self):
         second = '{:02d}'.format(self.second)
         if self.microsecond:
-            second += '.{}'.format(self.microsecond)
+            second += '.{:06d}'.format(self.microsecond)
 
         return "{:04d}-{:02d}-{:02d} {:02d}:{:02d}:{}".format(
             self.year, self.month, self.day, self.hour, self.minute, second)


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+cftime (1.1.1+ds-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Mon, 16 Mar 2020 05:44:48 +0100
+
 cftime (1.1.0+ds-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
test/test_cftime.py
=====================================
@@ -729,6 +729,21 @@ class cftimeTestCase(unittest.TestCase):
         d = datetime.strptime('2018-01-23 09:27:10.950000',"%Y-%m-%d %H:%M:%S.%f")
         units = 'seconds since 2018-01-23 09:31:42.94'
         assert(cftime.date2num(d, units) == -271.99)
+        # issue 143 - same answer for arrays vs scalars.
+        units = 'seconds since 1970-01-01 00:00:00'
+        times_in = [1261440000.0, 1261440001.0, 1261440002.0, 1261440003.0,
+                    1261440004.0, 1261440005.0]
+        times_out1 = cftime.num2date(times_in, units)
+        times_out2 = []
+        for time_in in times_in:
+            times_out2.append(cftime.num2date(time_in, units))
+        dates1 = [str(d) for d in times_out1]
+        dates2 = [str(d) for d in times_out2]
+        assert(dates1 == dates2)
+        # issue #143 formatting of microseconds
+        d = cftime.num2date(1261440000.015625,units)
+        # on windows only 100 ms precision
+        assert(str(d)[0:24] == '2009-12-22 00:00:00.0156')
 
 class TestDate2index(unittest.TestCase):
 
@@ -1518,6 +1533,5 @@ def test_replace_dayofyr_or_dayofwk_error(date_type, argument):
     with pytest.raises(ValueError):
         date_type(1, 1, 1).replace(**{argument: 3})
 
-
 if __name__ == '__main__':
     unittest.main()



View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/d4f7632f715dc27ab63b52b4f2dae3a2ae58f124...4ebc57e51769d58d2d5d8dd7dd5c84ece23e9154

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/d4f7632f715dc27ab63b52b4f2dae3a2ae58f124...4ebc57e51769d58d2d5d8dd7dd5c84ece23e9154
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-grass-devel/attachments/20200316/9ec46258/attachment-0001.html>


More information about the Pkg-grass-devel mailing list