| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -29,15 +29,28 @@ | |||
| 29 | 29 | # for profiling | |
| 30 | 30 | tstart = time.time() | |
| 31 | 31 | ||
| 32 | + def on_draw(event): | ||
| 33 | + background = canvas.copy_from_bbox(ax.bbox) | ||
| 34 | + if on_draw.background is None: | ||
| 35 | + gobject.idle_add(update_line) | ||
| 36 | + | ||
| 37 | + on_draw.background = background | ||
| 38 | + | ||
| 39 | + on_draw.background = None | ||
| 40 | + | ||
| 41 | + fig.canvas.mpl_connect('draw_event', on_draw) | ||
| 42 | + | ||
| 32 | 43 | def update_line(*args): | |
| 33 | - print 'you are here', update_line.cnt | ||
| 34 | - if update_line.background is None: | ||
| 35 | - update_line.background = canvas.copy_from_bbox(ax.bbox) | ||
| 44 | + if on_draw.background is None: | ||
| 45 | + return True | ||
| 46 | + | ||
| 47 | + print 'frame', update_line.cnt | ||
| 36 | 48 | ||
| 37 | 49 | # restore the clean slate background | |
| 38 | - canvas.restore_region(update_line.background) | ||
| 50 | + canvas.restore_region(on_draw.background) | ||
| 39 | 51 | # update the data | |
| 40 | 52 | line.set_ydata(np.sin(x+update_line.cnt/10.0)) | |
| 53 | + | ||
| 41 | 54 | # just draw the animated artist | |
| 42 | 55 | ax.draw_artist(line) | |
| 43 | 56 | ||
@@ -54,14 +67,6 @@ def update_line(*args): | |||
| 54 | 67 | return True | |
| 55 | 68 | ||
| 56 | 69 | update_line.cnt = 0 | |
| 57 | - update_line.background = None | ||
| 58 | - | ||
| 59 | - | ||
| 60 | - def start_anim(event): | ||
| 61 | - gobject.idle_add(update_line) | ||
| 62 | - canvas.mpl_disconnect(start_anim.cid) | ||
| 63 | - | ||
| 64 | - start_anim.cid = canvas.mpl_connect('draw_event', start_anim) | ||
| 65 | 70 | ||
| 66 | 71 | ||
| 67 | 72 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -20,9 +20,9 @@ | |||
| 20 | 20 | ||
| 21 | 21 | class UpdateLine(object): | |
| 22 | 22 | def get_bg_bbox(self): | |
| 23 | - | ||
| 23 | + | ||
| 24 | 24 | return self.ax.bbox.padded(-3) | |
| 25 | - | ||
| 25 | + | ||
| 26 | 26 | def __init__(self, canvas, ax): | |
| 27 | 27 | self.cnt = 0 | |
| 28 | 28 | self.canvas = canvas | |
@@ -31,7 +31,7 @@ def __init__(self, canvas, ax): | |||
| 31 | 31 | self.prev_time = time.time() | |
| 32 | 32 | self.start_time = self.prev_time | |
| 33 | 33 | self.prev_pixel_offset = 0. | |
| 34 | - | ||
| 34 | + | ||
| 35 | 35 | ||
| 36 | 36 | self.x0 = 0 | |
| 37 | 37 | self.phases = np.random.random_sample((20,)) * np.pi * 2 | |
@@ -70,7 +70,7 @@ def restore_background_shifted(self, dx_pixel): | |||
| 70 | 70 | # restore the clean slate background | |
| 71 | 71 | self.canvas.restore_region(self.background1) | |
| 72 | 72 | ||
| 73 | - # restore subregion (x1+dx, y1, x2, y2) of the second bg | ||
| 73 | + # restore subregion (x1+dx, y1, x2, y2) of the second bg | ||
| 74 | 74 | # in a offset position (x1-dx, y1) | |
| 75 | 75 | x1, y1, x2, y2 = self.background2.get_extents() | |
| 76 | 76 | self.canvas.restore_region(self.background2, | |
@@ -82,18 +82,18 @@ def restore_background_shifted(self, dx_pixel): | |||
| 82 | 82 | def on_draw(self, *args): | |
| 83 | 83 | self.save_bg() | |
| 84 | 84 | return False | |
| 85 | - | ||
| 85 | + | ||
| 86 | 86 | def update_line(self, *args): | |
| 87 | 87 | ||
| 88 | 88 | if self.background1 is None: | |
| 89 | 89 | return True | |
| 90 | - | ||
| 90 | + | ||
| 91 | 91 | cur_time = time.time() | |
| 92 | 92 | pixel_offset = int((cur_time - self.start_time)*100.) | |
| 93 | 93 | dx_pixel = pixel_offset - self.prev_pixel_offset | |
| 94 | 94 | self.prev_pixel_offset = pixel_offset | |
| 95 | 95 | dx_data = self.get_dx_data(dx_pixel) #cur_time - self.prev_time) | |
| 96 | - | ||
| 96 | + | ||
| 97 | 97 | x0 = self.x0 | |
| 98 | 98 | self.x0 += dx_data | |
| 99 | 99 | self.prev_time = cur_time | |
@@ -109,7 +109,7 @@ def update_line(self, *args): | |||
| 109 | 109 | ||
| 110 | 110 | self.line.set_color(self.color_cycle.next()) | |
| 111 | 111 | ||
| 112 | - # now plot line segment within [x0, x0+dx_data], | ||
| 112 | + # now plot line segment within [x0, x0+dx_data], | ||
| 113 | 113 | # Note that we're only plotting a line between [x0, x0+dx_data]. | |
| 114 | 114 | xx = np.array([x0, self.x0]) | |
| 115 | 115 | self.line.set_xdata(xx) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,7 +9,7 @@ | |||
| 9 | 9 | ''' | |
| 10 | 10 | ||
| 11 | 11 | # The Olson database is updated several times a year. | |
| 12 | - OLSON_VERSION = '2010h' | ||
| 12 | + OLSON_VERSION = '2010o' | ||
| 13 | 13 | VERSION = OLSON_VERSION | |
| 14 | 14 | # Version format for a patch release - only one so far. | |
| 15 | 15 | #VERSION = OLSON_VERSION + '.2' | |
@@ -358,7 +358,7 @@ def __reduce__(self): | |||
| 358 | 358 | return FixedOffset, (self._minutes, ) | |
| 359 | 359 | ||
| 360 | 360 | def dst(self, dt): | |
| 361 | - return None | ||
| 361 | + return ZERO | ||
| 362 | 362 | ||
| 363 | 363 | def tzname(self, dt): | |
| 364 | 364 | return None | |
@@ -387,12 +387,16 @@ def FixedOffset(offset, _tzinfos = {}): | |||
| 387 | 387 | pytz.FixedOffset(-330) | |
| 388 | 388 | >>> one.utcoffset(datetime.datetime.now()) | |
| 389 | 389 | datetime.timedelta(-1, 66600) | |
| 390 | + >>> one.dst(datetime.datetime.now()) | ||
| 391 | + datetime.timedelta(0) | ||
| 390 | 392 | ||
| 391 | 393 | >>> two = FixedOffset(1380) | |
| 392 | 394 | >>> two | |
| 393 | 395 | pytz.FixedOffset(1380) | |
| 394 | 396 | >>> two.utcoffset(datetime.datetime.now()) | |
| 395 | 397 | datetime.timedelta(0, 82800) | |
| 398 | + >>> two.dst(datetime.datetime.now()) | ||
| 399 | + datetime.timedelta(0) | ||
| 396 | 400 | ||
| 397 | 401 | The datetime.timedelta must be between the range of -1 and 1 day, | |
| 398 | 402 | non-inclusive. | |
@@ -530,6 +534,7 @@ def _test(): | |||
| 530 | 534 | 'America/Atikokan', | |
| 531 | 535 | 'America/Atka', | |
| 532 | 536 | 'America/Bahia', | |
| 537 | + 'America/Bahia_Banderas', | ||
| 533 | 538 | 'America/Barbados', | |
| 534 | 539 | 'America/Belem', | |
| 535 | 540 | 'America/Belize', | |
@@ -956,6 +961,7 @@ def _test(): | |||
| 956 | 961 | 'Pacific/Apia', | |
| 957 | 962 | 'Pacific/Auckland', | |
| 958 | 963 | 'Pacific/Chatham', | |
| 964 | + 'Pacific/Chuuk', | ||
| 959 | 965 | 'Pacific/Easter', | |
| 960 | 966 | 'Pacific/Efate', | |
| 961 | 967 | 'Pacific/Enderbury', | |
@@ -981,6 +987,7 @@ def _test(): | |||
| 981 | 987 | 'Pacific/Pago_Pago', | |
| 982 | 988 | 'Pacific/Palau', | |
| 983 | 989 | 'Pacific/Pitcairn', | |
| 990 | + 'Pacific/Pohnpei', | ||
| 984 | 991 | 'Pacific/Ponape', | |
| 985 | 992 | 'Pacific/Port_Moresby', | |
| 986 | 993 | 'Pacific/Rarotonga', | |
@@ -1095,6 +1102,7 @@ def _test(): | |||
| 1095 | 1102 | 'America/Asuncion', | |
| 1096 | 1103 | 'America/Atikokan', | |
| 1097 | 1104 | 'America/Bahia', | |
| 1105 | + 'America/Bahia_Banderas', | ||
| 1098 | 1106 | 'America/Barbados', | |
| 1099 | 1107 | 'America/Belem', | |
| 1100 | 1108 | 'America/Belize', | |
@@ -1155,6 +1163,7 @@ def _test(): | |||
| 1155 | 1163 | 'America/Maceio', | |
| 1156 | 1164 | 'America/Managua', | |
| 1157 | 1165 | 'America/Manaus', | |
| 1166 | + 'America/Marigot', | ||
| 1158 | 1167 | 'America/Martinique', | |
| 1159 | 1168 | 'America/Matamoros', | |
| 1160 | 1169 | 'America/Mazatlan', | |
@@ -1195,6 +1204,8 @@ def _test(): | |||
| 1195 | 1204 | 'America/Santo_Domingo', | |
| 1196 | 1205 | 'America/Sao_Paulo', | |
| 1197 | 1206 | 'America/Scoresbysund', | |
| 1207 | + 'America/Shiprock', | ||
| 1208 | + 'America/St_Barthelemy', | ||
| 1198 | 1209 | 'America/St_Johns', | |
| 1199 | 1210 | 'America/St_Kitts', | |
| 1200 | 1211 | 'America/St_Lucia', | |
@@ -1220,8 +1231,10 @@ def _test(): | |||
| 1220 | 1231 | 'Antarctica/McMurdo', | |
| 1221 | 1232 | 'Antarctica/Palmer', | |
| 1222 | 1233 | 'Antarctica/Rothera', | |
| 1234 | + 'Antarctica/South_Pole', | ||
| 1223 | 1235 | 'Antarctica/Syowa', | |
| 1224 | 1236 | 'Antarctica/Vostok', | |
| 1237 | + 'Arctic/Longyearbyen', | ||
| 1225 | 1238 | 'Asia/Aden', | |
| 1226 | 1239 | 'Asia/Almaty', | |
| 1227 | 1240 | 'Asia/Amman', | |
@@ -1331,42 +1344,54 @@ def _test(): | |||
| 1331 | 1344 | 'Europe/Athens', | |
| 1332 | 1345 | 'Europe/Belgrade', | |
| 1333 | 1346 | 'Europe/Berlin', | |
| 1347 | + 'Europe/Bratislava', | ||
| 1334 | 1348 | 'Europe/Brussels', | |
| 1335 | 1349 | 'Europe/Bucharest', | |
| 1336 | 1350 | 'Europe/Budapest', | |
| 1337 | 1351 | 'Europe/Chisinau', | |
| 1338 | 1352 | 'Europe/Copenhagen', | |
| 1339 | 1353 | 'Europe/Dublin', | |
| 1340 | 1354 | 'Europe/Gibraltar', | |
| 1355 | + 'Europe/Guernsey', | ||
| 1341 | 1356 | 'Europe/Helsinki', | |
| 1357 | + 'Europe/Isle_of_Man', | ||
| 1342 | 1358 | 'Europe/Istanbul', | |
| 1359 | + 'Europe/Jersey', | ||
| 1343 | 1360 | 'Europe/Kaliningrad', | |
| 1344 | 1361 | 'Europe/Kiev', | |
| 1345 | 1362 | 'Europe/Lisbon', | |
| 1363 | + 'Europe/Ljubljana', | ||
| 1346 | 1364 | 'Europe/London', | |
| 1347 | 1365 | 'Europe/Luxembourg', | |
| 1348 | 1366 | 'Europe/Madrid', | |
| 1349 | 1367 | 'Europe/Malta', | |
| 1368 | + 'Europe/Mariehamn', | ||
| 1350 | 1369 | 'Europe/Minsk', | |
| 1351 | 1370 | 'Europe/Monaco', | |
| 1352 | 1371 | 'Europe/Moscow', | |
| 1353 | 1372 | 'Europe/Oslo', | |
| 1354 | 1373 | 'Europe/Paris', | |
| 1374 | + 'Europe/Podgorica', | ||
| 1355 | 1375 | 'Europe/Prague', | |
| 1356 | 1376 | 'Europe/Riga', | |
| 1357 | 1377 | 'Europe/Rome', | |
| 1358 | 1378 | 'Europe/Samara', | |
| 1379 | + 'Europe/San_Marino', | ||
| 1380 | + 'Europe/Sarajevo', | ||
| 1359 | 1381 | 'Europe/Simferopol', | |
| 1382 | + 'Europe/Skopje', | ||
| 1360 | 1383 | 'Europe/Sofia', | |
| 1361 | 1384 | 'Europe/Stockholm', | |
| 1362 | 1385 | 'Europe/Tallinn', | |
| 1363 | 1386 | 'Europe/Tirane', | |
| 1364 | 1387 | 'Europe/Uzhgorod', | |
| 1365 | 1388 | 'Europe/Vaduz', | |
| 1389 | + 'Europe/Vatican', | ||
| 1366 | 1390 | 'Europe/Vienna', | |
| 1367 | 1391 | 'Europe/Vilnius', | |
| 1368 | 1392 | 'Europe/Volgograd', | |
| 1369 | 1393 | 'Europe/Warsaw', | |
| 1394 | + 'Europe/Zagreb', | ||
| 1370 | 1395 | 'Europe/Zaporozhye', | |
| 1371 | 1396 | 'Europe/Zurich', | |
| 1372 | 1397 | 'GMT', | |
@@ -1384,6 +1409,7 @@ def _test(): | |||
| 1384 | 1409 | 'Pacific/Apia', | |
| 1385 | 1410 | 'Pacific/Auckland', | |
| 1386 | 1411 | 'Pacific/Chatham', | |
| 1412 | + 'Pacific/Chuuk', | ||
| 1387 | 1413 | 'Pacific/Easter', | |
| 1388 | 1414 | 'Pacific/Efate', | |
| 1389 | 1415 | 'Pacific/Enderbury', | |
@@ -1409,14 +1435,13 @@ def _test(): | |||
| 1409 | 1435 | 'Pacific/Pago_Pago', | |
| 1410 | 1436 | 'Pacific/Palau', | |
| 1411 | 1437 | 'Pacific/Pitcairn', | |
| 1412 | - 'Pacific/Ponape', | ||
| 1438 | + 'Pacific/Pohnpei', | ||
| 1413 | 1439 | 'Pacific/Port_Moresby', | |
| 1414 | 1440 | 'Pacific/Rarotonga', | |
| 1415 | 1441 | 'Pacific/Saipan', | |
| 1416 | 1442 | 'Pacific/Tahiti', | |
| 1417 | 1443 | 'Pacific/Tarawa', | |
| 1418 | 1444 | 'Pacific/Tongatapu', | |
| 1419 | - 'Pacific/Truk', | ||
| 1420 | 1445 | 'Pacific/Wake', | |
| 1421 | 1446 | 'Pacific/Wallis', | |
| 1422 | 1447 | 'US/Alaska', | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,7 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | # I test for expected version to ensure the correct version of pytz is | |
| 18 | 18 | # actually being tested. | |
| 19 | - EXPECTED_VERSION='2010h' | ||
| 19 | + EXPECTED_VERSION='2010o' | ||
| 20 | 20 | ||
| 21 | 21 | fmt = '%Y-%m-%d %H:%M:%S %Z%z' | |
| 22 | 22 | ||
@@ -44,6 +44,7 @@ def prettydt(dt): | |||
| 44 | 44 | dt.hour, dt.minute, dt.second, | |
| 45 | 45 | dt.tzname(), offset) | |
| 46 | 46 | ||
| 47 | + | ||
| 47 | 48 | class BasicTest(unittest.TestCase): | |
| 48 | 49 | ||
| 49 | 50 | def testVersion(self): | |
@@ -643,6 +644,28 @@ def no_testCreateLocaltime(self): | |||
| 643 | 644 | '2004-10-31 02:00:00 CET+0100' | |
| 644 | 645 | ) | |
| 645 | 646 | ||
| 647 | + | ||
| 648 | + class CommonTimezonesTestCase(unittest.TestCase): | ||
| 649 | + def test_bratislava(self): | ||
| 650 | + # Bratislava is the default timezone for Slovakia, but our | ||
| 651 | + # heuristics where not adding it to common_timezones. Ideally, | ||
| 652 | + # common_timezones should be populated from zone.tab at runtime, | ||
| 653 | + # but I'm hesitant to pay the startup cost as loading the list | ||
| 654 | + # on demand whilst remaining backwards compatible seems | ||
| 655 | + # difficult. | ||
| 656 | + self.failUnless('Europe/Bratislava' in pytz.common_timezones) | ||
| 657 | + self.failUnless('Europe/Bratislava' in pytz.common_timezones_set) | ||
| 658 | + | ||
| 659 | + def test_us_eastern(self): | ||
| 660 | + self.failUnless('US/Eastern' in pytz.common_timezones) | ||
| 661 | + self.failUnless('US/Eastern' in pytz.common_timezones_set) | ||
| 662 | + | ||
| 663 | + def test_belfast(self): | ||
| 664 | + # Belfast uses London time. | ||
| 665 | + self.failUnless('Europe/Belfast' in pytz.all_timezones_set) | ||
| 666 | + self.failIf('Europe/Belfast' in pytz.common_timezones) | ||
| 667 | + self.failIf('Europe/Belfast' in pytz.common_timezones_set) | ||
| 668 | + | ||
| 646 | 669 | def test_suite(): | |
| 647 | 670 | suite = unittest.TestSuite() | |
| 648 | 671 | suite.addTest(doctest.DocTestSuite('pytz')) | |
@@ -651,6 +674,7 @@ def test_suite(): | |||
| 651 | 674 | suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(test_tzinfo)) | |
| 652 | 675 | return suite | |
| 653 | 676 | ||
| 677 | + | ||
| 654 | 678 | if __name__ == '__main__': | |
| 655 | 679 | unittest.main(defaultTest='test_suite') | |
| 656 | 680 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments