def test_leapyear(self): """leapyear should give known output for known input""" leaps = [ 1600, 1604, 1608, 1612, 1616, 1620, 1624, 1628, 1632, 1636, 1640, 1644, 1648, 1652, 1656, 1660, 1664, 1668, 1672, 1676, 1680, 1684, 1688, 1692, 1696, 1704, 1708, 1712, 1716, 1720, 1724, 1728, 1732, 1736, 1740, 1744, 1748, 1752, 1756, 1760, 1764, 1768, 1772, 1776, 1780, 1784, 1788, 1792, 1796, 1804, 1808, 1812, 1816, 1820, 1824, 1828, 1832, 1836, 1840, 1844, 1848, 1852, 1856, 1860, 1864, 1868, 1872, 1876, 1880, 1884, 1888, 1892, 1896, 1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, 1936, 1940, 1944, 1948, 1952, 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040 ] for i in range(1600, 2041): if i in leaps: self.assertTrue(t.leapyear(i)) else: self.assertFalse(t.leapyear(i)) data = (1993 + numpy.array(range(10)), 1900, [1993 + val for val in range(10)]) real_ans = (numpy.array([ 365, 365, 365, 366, 365, 365, 365, 366, 365, 365 ]), 365, numpy.array( [365, 365, 365, 366, 365, 365, 365, 366, 365, 365])) for i, val in enumerate(real_ans): if i == 0: numpy.testing.assert_array_equal(val.tolist(), t.leapyear(data[i], True)) else: numpy.testing.assert_array_equal(val, t.leapyear(data[i], True)) real_ans = (numpy.array([ False, False, False, True, False, False, False, True, False, False ]), False, [ False, False, False, True, False, False, False, True, False, False ]) for i, val in enumerate(real_ans): if i == 0: numpy.testing.assert_array_equal(val.tolist(), t.leapyear(data[i], False)) else: numpy.testing.assert_array_equal(val, t.leapyear(data[i], False))
def test_leapyear(self): """leapyear should give known output for known input""" leaps = [1600, 1604, 1608, 1612, 1616, 1620, 1624, 1628, 1632, 1636, 1640, 1644, 1648, 1652, 1656, 1660, 1664, 1668, 1672, 1676, 1680, 1684, 1688, 1692, 1696, 1704, 1708, 1712, 1716, 1720, 1724, 1728, 1732, 1736, 1740, 1744, 1748, 1752, 1756, 1760, 1764, 1768, 1772, 1776, 1780, 1784, 1788, 1792, 1796, 1804, 1808, 1812, 1816, 1820, 1824, 1828, 1832, 1836, 1840, 1844, 1848, 1852, 1856, 1860, 1864, 1868, 1872, 1876, 1880, 1884, 1888, 1892, 1896, 1904, 1908, 1912, 1916, 1920, 1924, 1928, 1932, 1936, 1940, 1944, 1948, 1952, 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040] for i in range(1600, 2041): if i in leaps: self.assertTrue(t.leapyear(i)) else: self.assertFalse(t.leapyear(i)) data = (1993 + numpy.array(range(10)), 1900, [1993 + val for val in range(10)]) real_ans = ( numpy.array([365, 365, 365, 366, 365, 365, 365, 366, 365, 365]), 365, numpy.array([365, 365, 365, 366, 365, 365, 365, 366, 365, 365])) for i, val in enumerate(real_ans): if i == 0: numpy.testing.assert_array_equal(val.tolist(), t.leapyear(data[i], True)) else: numpy.testing.assert_array_equal(val, t.leapyear(data[i], True)) real_ans = (numpy.array([False, False, False, True, False, False, False, True, False, False]), False, [False, False, False, True, False, False, False, True, False, False]) for i, val in enumerate(real_ans): if i == 0: numpy.testing.assert_array_equal(val.tolist(), t.leapyear(data[i], False)) else: numpy.testing.assert_array_equal(val, t.leapyear(data[i], False))