From 450c0000a05204eebd6b27273d5efd2930eb0ad6 Mon Sep 17 00:00:00 2001 From: Christian Clauss Date: Tue, 13 Feb 2024 21:19:18 +0100 Subject: [PATCH] assert is not a function in Python --- test/test_cftime.py | 195 ++++++++++++++++++++++---------------------- 1 file changed, 99 insertions(+), 96 deletions(-) diff --git a/test/test_cftime.py b/test/test_cftime.py index 29db8299..8e9daae7 100644 --- a/test/test_cftime.py +++ b/test/test_cftime.py @@ -6,8 +6,6 @@ DatetimeProlepticGregorian, _parse_date, date2index, date2num, num2date, UNIT_CONVERSION_FACTORS) import copy -import operator -import sys import unittest import warnings from collections import namedtuple @@ -330,17 +328,17 @@ def test_tz_naive(self): for t in (733498.999, 733498.9999, 733498.99999, 733498.999999, 733498.9999999): d = num2date(t, units='days since 0001-01-01 00:00:00') t2 = date2num(d, units='days since 0001-01-01 00:00:00') - assert(abs(t2 - t) < 1e-5) # values should be less than second + assert abs(t2 - t) < 1e-5 # values should be less than second # Check equality testing d1 = datetimex(1979, 6, 21, 9, 23, 12, calendar='standard') d2 = datetime(1979, 6, 21, 9, 23, 12) - assert(d1 == d2) + assert d1 == d2 # check timezone offset d = datetime(2012, 2, 29, 15) # mixed_tz is -6 hours from UTC, mixed is UTC so # difference in elapsed time is -6 hours. - assert(self.cdftime_mixed_tz.date2num( - d) - self.cdftime_mixed.date2num(d) == -6) + assert self.cdftime_mixed_tz.date2num( + d) - self.cdftime_mixed.date2num(d) == -6 # Check comparisons with Python datetime types @@ -402,7 +400,7 @@ def test_tz_naive(self): #issue 344 units = 'hours since 2013-12-12T12:00:00' - assert(1.0 == date2num(num2date(1.0, units), units)) + assert 1.0 == date2num(num2date(1.0, units), units) # test roundtrip accuracy # also tests error found in issue #349 @@ -416,43 +414,49 @@ def roundtrip(delta,eps,units): times2 = date2num(dates1,units,calendar=calendar) dates2 = num2date(times2,units,calendar=calendar) err = np.abs(times1 - times2) - assert(np.all(err