Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43f1b76

Browse files
committed
Fix timezone issue, update code to coding standards.
Signed-off-by: Paul G <[email protected]>
1 parent d61397d commit 43f1b76

File tree

2 files changed

+36
-29
lines changed

2 files changed

+36
-29
lines changed

lib/matplotlib/dates.py

Lines changed: 31 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ def dst(self, dt):
169169

170170

171171
def _get_rc_timezone():
172+
"""
173+
Retrieve the preferred timeszone from the rcParams dictionary.
174+
"""
172175
s = matplotlib.rcParams['timezone']
173176
if s == 'UTC':
174177
return UTC
@@ -247,7 +250,8 @@ def _from_ordinalf(x, tz=None):
247250
dt = datetime.datetime.fromordinal(ix)
248251
remainder = float(x) - ix
249252

250-
dt += datetime.timedelta(seconds = remainder * SEC_PER_DAY)
253+
dt += datetime.timedelta(seconds=remainder * SEC_PER_DAY)
254+
dt = dt.astimezone(tz)
251255

252256
return dt
253257

@@ -752,20 +756,20 @@ def _get_unit(self):
752756

753757
@staticmethod
754758
def get_unit_generic(freq):
755-
if (freq == YEARLY):
759+
if freq == YEARLY:
756760
return DAYS_PER_YEAR
757-
elif (freq == MONTHLY):
761+
elif freq == MONTHLY:
758762
return DAYS_PER_MONTH
759-
elif (freq == WEEKLY):
763+
elif freq == WEEKLY:
760764
return DAYS_PER_WEEK
761-
elif (freq == DAILY):
765+
elif freq == DAILY:
762766
return 1.0
763-
elif (freq == HOURLY):
764-
return (1.0 / HOURS_PER_DAY)
765-
elif (freq == MINUTELY):
766-
return (1.0 / MINUTES_PER_DAY)
767-
elif (freq == SECONDLY):
768-
return (1.0 / SEC_PER_DAY)
767+
elif freq == HOURLY:
768+
return 1.0 / HOURS_PER_DAY
769+
elif freq == MINUTELY:
770+
return 1.0 / MINUTES_PER_DAY
771+
elif freq == SECONDLY:
772+
return 1.0 / SEC_PER_DAY
769773
else:
770774
# error
771775
return -1 # or should this just return '1'?
@@ -1083,7 +1087,7 @@ class MonthLocator(RRuleLocator):
10831087
"""
10841088
Make ticks on occurances of each month month, eg 1, 3, 12.
10851089
"""
1086-
def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None):
1090+
def __init__(self, bymonth=None, bymonthday=1, interval=1, tz=None):
10871091
"""
10881092
Mark every month in *bymonth*; *bymonth* can be an int or
10891093
sequence. Default is ``range(1,13)``, i.e. every month.
@@ -1103,7 +1107,7 @@ class WeekdayLocator(RRuleLocator):
11031107
Make ticks on occurances of each weekday.
11041108
"""
11051109

1106-
def __init__(self, byweekday=1, interval=1, tz=None):
1110+
def __init__(self, byweekday=1, interval=1, tz=None):
11071111
"""
11081112
Mark every weekday in *byweekday*; *byweekday* can be a number or
11091113
sequence.
@@ -1125,7 +1129,7 @@ class DayLocator(RRuleLocator):
11251129
Make ticks on occurances of each day of the month. For example,
11261130
1, 15, 30.
11271131
"""
1128-
def __init__(self, bymonthday=None, interval=1, tz=None):
1132+
def __init__(self, bymonthday=None, interval=1, tz=None):
11291133
"""
11301134
Mark every day in *bymonthday*; *bymonthday* can be an int or
11311135
sequence.
@@ -1143,7 +1147,7 @@ class HourLocator(RRuleLocator):
11431147
"""
11441148
Make ticks on occurances of each hour.
11451149
"""
1146-
def __init__(self, byhour=None, interval=1, tz=None):
1150+
def __init__(self, byhour=None, interval=1, tz=None):
11471151
"""
11481152
Mark every hour in *byhour*; *byhour* can be an int or sequence.
11491153
Default is to tick every hour: ``byhour=range(24)``
@@ -1162,7 +1166,7 @@ class MinuteLocator(RRuleLocator):
11621166
"""
11631167
Make ticks on occurances of each minute.
11641168
"""
1165-
def __init__(self, byminute=None, interval=1, tz=None):
1169+
def __init__(self, byminute=None, interval=1, tz=None):
11661170
"""
11671171
Mark every minute in *byminute*; *byminute* can be an int or
11681172
sequence. Default is to tick every minute: ``byminute=range(60)``
@@ -1181,7 +1185,7 @@ class SecondLocator(RRuleLocator):
11811185
"""
11821186
Make ticks on occurances of each second.
11831187
"""
1184-
def __init__(self, bysecond=None, interval=1, tz=None):
1188+
def __init__(self, bysecond=None, interval=1, tz=None):
11851189
"""
11861190
Mark every second in *bysecond*; *bysecond* can be an int or
11871191
sequence. Default is to tick every second: ``bysecond = range(60)``
@@ -1252,7 +1256,7 @@ def _close_to_dt(d1, d2, epsilon=5):
12521256
delta = d2 - d1
12531257
mus = abs(delta.days * MUSECONDS_PER_DAY + delta.seconds * 1e6 +
12541258
delta.microseconds)
1255-
assert(mus < epsilon)
1259+
assert mus < epsilon
12561260

12571261

12581262
def _close_to_num(o1, o2, epsilon=5):
@@ -1261,7 +1265,7 @@ def _close_to_num(o1, o2, epsilon=5):
12611265
microseconds.
12621266
"""
12631267
delta = abs((o2 - o1) * MUSECONDS_PER_DAY)
1264-
assert(delta < epsilon)
1268+
assert delta < epsilon
12651269

12661270

12671271
def epoch2num(e):
@@ -1304,10 +1308,10 @@ def date_ticker_factory(span, tz=None, numticks=5):
13041308
if span == 0:
13051309
span = 1 / HOURS_PER_DAY
13061310

1307-
minutes = span * MINUTES_PER_DAY
1308-
hours = span * HOURS_PER_DAY
1311+
mins = span * MINUTES_PER_DAY
1312+
hrs = span * HOURS_PER_DAY
13091313
days = span
1310-
weeks = span / DAYS_PER_WEEK
1314+
wks = span / DAYS_PER_WEEK
13111315
months = span / DAYS_PER_MONTH # Approx
13121316
years = span / DAYS_PER_YEAR # Approx
13131317

@@ -1317,17 +1321,17 @@ def date_ticker_factory(span, tz=None, numticks=5):
13171321
elif months > numticks:
13181322
locator = MonthLocator(tz=tz)
13191323
fmt = '%b %Y'
1320-
elif weeks > numticks:
1324+
elif wks > numticks:
13211325
locator = WeekdayLocator(tz=tz)
13221326
fmt = '%a, %b %d'
13231327
elif days > numticks:
13241328
locator = DayLocator(interval=int(math.ceil(days / numticks)), tz=tz)
13251329
fmt = '%b %d'
1326-
elif hours > numticks:
1327-
locator = HourLocator(interval=int(math.ceil(hours / numticks)), tz=tz)
1330+
elif hrs > numticks:
1331+
locator = HourLocator(interval=int(math.ceil(hrs / numticks)), tz=tz)
13281332
fmt = '%H:%M\n%b %d'
1329-
elif minutes > numticks:
1330-
locator = MinuteLocator(interval=int(math.ceil(minutes / numticks)),
1333+
elif mins > numticks:
1334+
locator = MinuteLocator(interval=int(math.ceil(mins / numticks)),
13311335
tz=tz)
13321336
fmt = '%H:%M:%S'
13331337
else:

setupext.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ def get_base_dirs():
153153
'gnu0': ['/usr'],
154154
'aix5': ['/usr/local'],
155155
}
156-
return basedir_map.get(sys.platform, ['/usr/local', '/usr'])
156+
157+
return basedir_map.get(sys.platform, ['/usr/local', '/usr' ])
157158

158159

159160
def get_include_dirs():
@@ -452,6 +453,7 @@ def _check_for_pkg_config(self, package, include_file, min_version=None,
452453
ext = make_extension('test', [])
453454
pkg_config.setup_extension(ext, package)
454455

456+
print(ext.include_dirs)
455457
check_include_file(ext.include_dirs, include_file, package)
456458

457459
return 'version %s' % version
@@ -920,11 +922,12 @@ def add_flags(self, ext):
920922
pkg_config.setup_extension(
921923
ext, 'freetype2',
922924
default_include_dirs=[
925+
'/usr/include/freetype2',
923926
'include/freetype2', 'freetype2',
924927
'lib/freetype2/include',
925928
'lib/freetype2/include/freetype2'],
926929
default_library_dirs=[
927-
'freetype2/lib'],
930+
'freetype2/lib', 'freetype2/config'],
928931
default_libraries=['freetype', 'z'])
929932

930933

0 commit comments

Comments
 (0)