Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test_num2date_precision failure on various architectures #293

Closed
sebastic opened this issue Sep 19, 2022 · 3 comments
Closed

test_num2date_precision failure on various architectures #293

sebastic opened this issue Sep 19, 2022 · 3 comments

Comments

@sebastic
Copy link

The Debian package build failed on various architectures due to test failures:


=================================== FAILURES ===================================
___________________________ test_num2date_precision ____________________________

    def test_num2date_precision():
        if sys.platform.startswith("win"):
            pytest.skip("skipping tests that require float128 on windows")
        testdates = [(1271, 3, 18, 19, 41, 33),
                     (1271, 3, 18, 19, 41, 32, 999998)]
        unitinc = ['microseconds', 'seconds', 'minutes', 'hours', 'days']
        for cc in ['standard', 'gregorian', 'julian', 'proleptic_gregorian',
                   'noleap', 'all_leap', '365_day', '366_day', '360_day']:
            for uinc in unitinc:
                if cc in ['standard', 'gregorian', 'julian']:
                    units = uinc + ' since -4713-01-01 12:00:00'
                elif cc in ['proleptic_gregorian']:
                    units = uinc + ' since -4714-01-01 12:00:00'
                elif cc in ['noleap', 'all_leap', '365_day', '366_day', '360_day']:
                    units = uinc + ' since 0000-01-01 12:00:00'
                # scalar
                date = datetimex(*testdates[0], calendar=cc)
                num = date2num(date, units, calendar=cc, longdouble=True)
                date2 = num2date(num, units, calendar=cc)
                assert date == date2
                # array
                date = [ datetimex(*dd, calendar=cc) for dd in testdates ]
                num = date2num(date, units, calendar=cc, longdouble=True)
                date2 = num2date(num, units, calendar=cc)
                for i in range(len(date)):
>                   assert date[i] == date2[i]
E                   AssertionError: assert cftime.datetime(1271, 3, 18, 19, 41, 32, 999998, calendar='standard', has_year_zero=False) == cftime.DatetimeGregorian(1271, 3, 18, 19, 41, 33, 0, has_year_zero=False)

test/test_cftime.py:2210: AssertionError
=============================== warnings summary ===============================
.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_string_format2
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1694: CFWarning: this date/calendar/year zero convention is not supported by CF
    dt = cftime.datetime(-4713, 1, 1, 12, 0, 0, 10)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_string_format2
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1701: CFWarning: this date/calendar/year zero convention is not supported by CF
    dt = cftime.datetime(-713, 1, 1, 12, 0, 0, 10)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_strptime
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1717: CFWarning: this date/calendar/year zero convention is not supported by CF
    d = cftime.datetime.strptime('24/Aug/-4712:17:57:26', '%d/%b/%Y:%H:%M:%S',calendar='julian')

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_strptime
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1719: CFWarning: this date/calendar/year zero convention is not supported by CF
    d = cftime.datetime.strptime('24/August/-4712:17:57:26', '%d/%B/%Y:%H:%M:%S',calendar='julian')

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_strptime
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1721: CFWarning: this date/calendar/year zero convention is not supported by CF
    d = cftime.datetime.strptime("-4712", "%Y", calendar="julian")

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_string_isoformat
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1733: CFWarning: this date/calendar/year zero convention is not supported by CF
    dt = cftime.datetime(-4713, 1, 1, 12, 0, 0, 10)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_string_isoformat
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:1738: CFWarning: this date/calendar/year zero convention is not supported by CF
    dt = cftime.datetime(-713, 1, 1, 12, 0, 0, 10)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_num2date_precision
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:2202: CFWarning: this date/calendar/year zero convention is not supported by CF
    num = date2num(date, units, calendar=cc, longdouble=True)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_num2date_precision
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:2203: CFWarning: this date/calendar/year zero convention is not supported by CF
    date2 = num2date(num, units, calendar=cc)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_num2date_precision
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:2207: CFWarning: this date/calendar/year zero convention is not supported by CF
    num = date2num(date, units, calendar=cc, longdouble=True)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_num2date_precision
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:2208: CFWarning: this date/calendar/year zero convention is not supported by CF
    date2 = num2date(num, units, calendar=cc)

.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py::test_num2date_precision
  /<<PKGBUILDDIR>>/.pybuild/cpython3_3.10_cftime/build/test/test_cftime.py:2213: CFWarning: this date/calendar/year zero convention is not supported by CF
    date2 = num2date(num, units, calendar=cc)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html

---------- coverage: platform linux, python 3.10.7-final-0 -----------
Name                  Stmts   Miss  Cover   Missing
---------------------------------------------------
cftime/__init__.py        5      0   100%
cftime/_strptime.py      99     21    79%   53, 96-97, 102, 109-123, 127, 130, 138-142
---------------------------------------------------
TOTAL                   104     21    80%

=========================== short test summary info ============================
FAILED test/test_cftime.py::test_num2date_precision - AssertionError: assert ...
============ 1 failed, 2271 passed, 12 warnings in 82.00s (0:01:21) ============

Full buildlogs: armel, armhf, mipsel, hppa

@jswhit
Copy link
Collaborator

jswhit commented Sep 19, 2022

This test relies on numpy's longdouble type actually being extended precision. It is not on windows, which is why the test is skipped there. Apparently it's not extended precision on armel, armhf, mipsel or hppa either. The solution is probably to check using numpy.finfo and skip the test if a numpy.longdouble doesn't have any more precision than numpy.float.

@jswhit
Copy link
Collaborator

jswhit commented Sep 19, 2022

PR #294 should fix those failing tests (by skipping them on platforms where numpy.longdouble doesn't have sufficient precision)

@sebastic
Copy link
Author

Confirmed fixed with the changes from #294 on armhf.

@jswhit jswhit closed this as completed Sep 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants