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

Bas Couwenberg (@sebastic) gitlab at salsa.debian.org
Sat Jan 22 17:44:17 GMT 2022



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


Commits:
7b3daea8 by Bas Couwenberg at 2022-01-22T18:35:37+01:00
New upstream version 1.5.2+ds
- - - - -
2897040f by Bas Couwenberg at 2022-01-22T18:35:38+01:00
Update upstream source from tag 'upstream/1.5.2+ds'

Update to upstream version '1.5.2+ds'
with Debian dir 55e01f33f6855254c5cf92bf230d0a67c19882cb
- - - - -
4c28f38c by Bas Couwenberg at 2022-01-22T18:35:57+01:00
New upstream release.

- - - - -
3655dd74 by Bas Couwenberg at 2022-01-22T18:36:57+01:00
Set distribution to unstable.

- - - - -


11 changed files:

- .github/workflows/miniconda.yml
- Changelog
- README.md
- debian/changelog
- docs/api.rst
- pyproject.toml
- requirements-dev.txt
- requirements.txt
- src/cftime/__init__.py
- src/cftime/_cftime.pyx
- test/test_cftime.py


Changes:

=====================================
.github/workflows/miniconda.yml
=====================================
@@ -10,7 +10,7 @@ jobs:
     runs-on: ${{ matrix.os }}
     strategy:
       matrix:
-        python-version: [ "3.7", "3.8", "3.9"]
+        python-version: [ "3.7", "3.8", "3.9", "3.10"]
         os: [windows-latest, ubuntu-latest, macos-latest]
         platform: [x64, x32]
 #  debug on a single os/platform/python version
@@ -64,7 +64,7 @@ jobs:
 #       coveralls --service=github-actions
 
     - name: Tarball
-      if: startsWith(matrix.os,'ubuntu')
+      if: startsWith(matrix.os,'ubuntu') && matrix.python-version == '3.9'
       shell: bash -l {0}
       run: |
         source activate TEST
@@ -74,7 +74,7 @@ jobs:
         twine check dist/* ;
  
     - name: Docs
-      if: startsWith(matrix.os,'ubuntu')
+      if: startsWith(matrix.os,'ubuntu') && matrix.python-version == '3.9'
       shell: bash -l {0}
       run: |
         source activate TEST


=====================================
Changelog
=====================================
@@ -1,3 +1,10 @@
+version 1.5.2 (release tag v1.5.2rel)
+=====================================
+ * silently change calendar='gregorian' to 'standard' internally, 
+   since 'gregorian' deprecated in CF v1.9 (issue #256).
+ * add "is_leap_year" function (issue #259).
+ * wheels that work on Apple M1 (arm64) available on pypi.
+   
 version 1.5.1.1
 ===============
  * no code changes, just new binary wheels for python 3.10.


=====================================
README.md
=====================================
@@ -12,7 +12,11 @@ Time-handling functionality from netcdf4-python
 ## News
 For details on the latest updates, see the [Changelog](https://github.com/Unidata/cftime/blob/master/Changelog).
 
+1/22/2022: Version 1.5.2 released (wheels for Apple M1 available on pypi for python 3.8,3.9 and 3.10). is_leap_year
+function added (issue #259).
+
 10/31/2021: Version 1.5.1.1 released (new binary wheels for python 3.10).
+
 10/1/2021:  Version 1.5.1 released. Changed default behavior of ``proleptic_gregorian``
 to has_year_zero=T (since it is allowed in ISO-8601 and CF does not specify the
 year zero convention for this calendar). Raise warning message when trying


=====================================
debian/changelog
=====================================
@@ -1,3 +1,9 @@
+cftime (1.5.2+ds-1) unstable; urgency=medium
+
+  * New upstream release.
+
+ -- Bas Couwenberg <sebastic at debian.org>  Sat, 22 Jan 2022 18:36:47 +0100
+
 cftime (1.5.1.1+ds-1) unstable; urgency=medium
 
   * New upstream release.


=====================================
docs/api.rst
=====================================
@@ -2,5 +2,5 @@ API
 ===
 
 .. automodule:: cftime
-   :members: datetime, date2num, num2date, num2pydate, date2index, time2index
+   :members: datetime, date2num, num2date, num2pydate, date2index, time2index, is_leap_year
    :show-inheritance:


=====================================
pyproject.toml
=====================================
@@ -1,3 +1,3 @@
 [build-system]
-requires = ["setuptools>=41.2", "cython", "wheel", "numpy"]
+requires = ["setuptools>=41.2", "cython", "wheel", "oldest-supported-numpy"]
 build-backend = "setuptools.build_meta"


=====================================
requirements-dev.txt
=====================================
@@ -1,7 +1,7 @@
 check-manifest
 coverage
 coveralls
-cython
+cython>0.26.1
 pytest
 pytest-cov
 sphinx


=====================================
requirements.txt
=====================================
@@ -1 +1 @@
-numpy
+numpy>1.13.3


=====================================
src/cftime/__init__.py
=====================================
@@ -1,5 +1,5 @@
 from ._cftime import (datetime, real_datetime,
-                      _parse_date, _dateparse, _datesplit)
+                      _parse_date, _dateparse, _datesplit, is_leap_year)
 from ._cftime import num2date, date2num, date2index, time2index, num2pydate
 from ._cftime import (microsec_units, millisec_units,
                      sec_units, hr_units, day_units, min_units,


=====================================
src/cftime/_cftime.pyx
=====================================
@@ -38,7 +38,7 @@ cdef int[12] _dayspermonth_leap = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 3
 cdef int[13] _cumdayspermonth = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365]
 cdef int[13] _cumdayspermonth_leap = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]
 
-__version__ = '1.5.1.1'
+__version__ = '1.5.2'
 
 # 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.
@@ -287,8 +287,9 @@ def date2num(dates,units,calendar=None,has_year_zero=None):
         return np.reshape(np.array(times), shape)
 
 
+ at cython.embedsignature(True)
 def num2pydate(times,units,calendar='standard'):
-    """num2pydate(times,units,calendar='standard')
+    """
     Always returns python datetime.datetime
     objects and raise an error if this is not possible.
 
@@ -1050,7 +1051,7 @@ The default format of the string produced by strftime is controlled by self.form
         if calendar == 'gregorian' or calendar == 'standard':
             # dates after 1582-10-15 can be converted to and compared to
             # proleptic Gregorian dates
-            self.calendar = 'gregorian'
+            self.calendar = 'standard'
             if self.to_tuple() >= (1582, 10, 15, 0, 0, 0, 0):
                 self.datetime_compatible = True
             else:
@@ -1394,7 +1395,7 @@ The default format of the string produced by strftime is controlled by self.form
         elif calendar == 'julian':
             #return dt.__class__(*add_timedelta(dt, delta, is_leap_julian, False, has_year_zero),calendar=calendar,has_year_zero=has_year_zero)
             return DatetimeJulian(*add_timedelta(dt, delta, is_leap_julian, False, has_year_zero),has_year_zero=has_year_zero)
-        elif calendar == 'gregorian':
+        elif calendar == 'standard':
             #return dt.__class__(*add_timedelta(dt, delta, is_leap_gregorian, True, has_year_zero),calendar=calendar,has_year_zero=has_year_zero)
             return DatetimeGregorian(*add_timedelta(dt, delta, is_leap_gregorian, True, has_year_zero),has_year_zero=has_year_zero)
         elif calendar == 'proleptic_gregorian':
@@ -1452,7 +1453,7 @@ datetime object."""
                     #return self.__class__(*add_timedelta(self, -other, 
                     #     is_leap_julian, False, has_year_zero),calendar=self.calendar,has_year_zero=self.has_year_zero)
                     return DatetimeJulian(*add_timedelta(self, -other, is_leap_julian, False, has_year_zero),has_year_zero=self.has_year_zero)
-                elif self.calendar == 'gregorian':
+                elif self.calendar == 'standard':
                     #return self.__class__(*add_timedelta(self, -other, 
                     #     is_leap_gregorian, True, has_year_zero),calendar=self.calendar,has_year_zero=self.has_year_zero)
                     return DatetimeGregorian(*add_timedelta(self, -other, is_leap_gregorian, True, has_year_zero),has_year_zero=self.has_year_zero)
@@ -1724,6 +1725,16 @@ cdef tuple add_timedelta_360_day(datetime dt, delta):
 
     return (year, month, day, hour, minute, second, microsecond, -1, -1)
 
+ at cython.embedsignature(True)
+def is_leap_year(year, calendar, has_year_zero=None):
+    """returns `True` if specified year in specified calendar is
+    a leap year. Optional kwarg `has_year_zero`
+    controls whether astronomical year numbering
+    is used and the year zero exists.  If not specified,
+    calendar-specific default is assumed."""
+    # public version of _is_leap (issue #259)
+    return _is_leap(year, calendar, has_year_zero=has_year_zero)
+
 cdef _is_leap(int year, calendar, has_year_zero=None):
     cdef int tyear
     cdef bint leap
@@ -1764,7 +1775,7 @@ cdef _check_calendar(calendar):
         raise ValueError('unsupported calendar')
     calout = calendar
     # remove 'gregorian','noleap','all_leap'
-    if calendar in 'gregorian':
+    if calendar == 'gregorian':
         calout = 'standard'
     if calendar == 'noleap':
         calout = '365_day'
@@ -1922,10 +1933,10 @@ but uses the "julian" calendar.
 cdef class DatetimeGregorian(datetime):
     """
 Phony datetime object which mimics the python datetime object,
-but uses the mixed Julian-Gregorian ("standard", "gregorian") calendar.
+but uses the mixed Julian-Gregorian ("standard") calendar.
     """
     def __init__(self, *args, **kwargs):
-        kwargs['calendar']='gregorian'
+        kwargs['calendar']='standard'
         super().__init__(*args, **kwargs)
 
 @cython.embedsignature(True)


=====================================
test/test_cftime.py
=====================================
@@ -73,7 +73,7 @@ def adjust_calendar(calendar):
     # check for and remove calendar synonyms.
     calendar = calendar.lower()
     if calendar == 'gregorian' or calendar == 'standard':
-        return 'gregorian'
+        return 'standard'
     elif calendar == 'noleap' or calendar == '365_day':
         return 'noleap'
     elif calendar == 'all_leap' or calendar == '366_day':
@@ -506,7 +506,7 @@ class cftimeTestCase(unittest.TestCase):
         units = 'days since 0001-01-01'
         for cap_cal, low_cal in (('STANDARD', 'standard'),
                                  ('NoLeap', 'noleap'),
-                                 ('Gregorian', 'gregorian'),
+                                 ('Standard', 'standard'),
                                  ('ALL_LEAP', 'all_leap')):
             d1 = date2num(d, units, cap_cal)
             d2 = date2num(d, units, low_cal)
@@ -555,15 +555,13 @@ class cftimeTestCase(unittest.TestCase):
         # n should always be 0 as all units refer to the same point in time
         assert_almost_equal(n, 0)
 
-        # list around missing dates in Gregorian calendar
+        # list around missing dates in mixed Julian/Gregorian calendar
         # scalar
         units = 'days since 0001-01-01 12:00:00'
-        t1 = date2num(datetime(1582, 10, 4), units, calendar='gregorian')
-        t2 = date2num(datetime(1582, 10, 15), units, calendar='gregorian')
+        t1 = date2num(datetime(1582, 10, 4), units, calendar='standard')
+        t2 = date2num(datetime(1582, 10, 15), units, calendar='standard')
         self.assertEqual(t1+1, t2)
         # list
-        t1, t2 = date2num([datetime(1582, 10, 4), datetime(1582, 10, 15)], units, calendar='gregorian')
-        self.assertEqual(t1+1, t2)
         t1, t2 = date2num([datetime(1582, 10, 4), datetime(1582, 10, 15)], units, calendar='standard')
         self.assertEqual(t1+1, t2)
         # this should fail: days missing in Gregorian calendar
@@ -860,7 +858,7 @@ class cftimeTestCase(unittest.TestCase):
         jdref=2400000
         with warnings.catch_warnings():
             warnings.simplefilter("ignore",category=cftime.CFWarning)
-            for calendar in ['julian','gregorian','proleptic_gregorian']:
+            for calendar in ['julian','standard','proleptic_gregorian']:
                 has_year_zero=False
                 try:
                     # this should raise ValueError
@@ -916,6 +914,13 @@ class cftimeTestCase(unittest.TestCase):
         assert(d.has_year_zero==True)
         d = d.replace(year=0)
         assert(d.has_year_zero==True)
+        # test leap year function
+        assert(cftime.is_leap_year(2000,calendar='standard'))
+        assert(cftime.is_leap_year(-1,calendar='standard'))
+        assert(cftime.is_leap_year(0,calendar='standard',has_year_zero=True))
+        assert(not cftime.is_leap_year(1,calendar='standard',has_year_zero=True))
+        assert(not cftime.is_leap_year(1,calendar='365_day'))
+        assert(cftime.is_leap_year(1,calendar='366_day'))
 
 
 class TestDate2index(unittest.TestCase):
@@ -1652,7 +1657,7 @@ def test_num2date_only_use_cftime_datetimes_post_gregorian(
 
 
 def test_repr():
-    expected = "cftime.datetime(2000, 1, 1, 0, 0, 0, 0, calendar='gregorian', has_year_zero=False)"
+    expected = "cftime.datetime(2000, 1, 1, 0, 0, 0, 0, calendar='standard', has_year_zero=False)"
     assert repr(datetimex(2000, 1, 1, calendar='standard')) == expected
     expected = "cftime.datetime(2000, 1, 1, 0, 0, 0, 0, calendar='', has_year_zero=False)"
     assert repr(datetimex(2000, 1, 1, calendar=None)) == expected



View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/dcc98c3a07c8751bb3bbd34d57c12f6e472e1fc5...3655dd74d4278aac61d48e8ae31d8db016ffab50

-- 
View it on GitLab: https://salsa.debian.org/debian-gis-team/cftime/-/compare/dcc98c3a07c8751bb3bbd34d57c12f6e472e1fc5...3655dd74d4278aac61d48e8ae31d8db016ffab50
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/20220122/509f24aa/attachment-0001.htm>


More information about the Pkg-grass-devel mailing list