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

Skip to content

Commit 9572d60

Browse files
committed
Update & deprecate mpl_toolkits.{gtk,excel}tools.
- On Py2, np.rec.fromarrays cannot take a unicode string as names (but this module __future__-imports unicode_strings). - CallbackRegistry ctor signature has changed.
1 parent c489bff commit 9572d60

File tree

2 files changed

+12
-11
lines changed

2 files changed

+12
-11
lines changed

lib/mpl_toolkits/exceltools.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@
3333
import matplotlib.mlab as mlab
3434

3535

36+
cbook.warn_deprecated("2.0", name="mpl_toolkits.exceltools",
37+
alternative="openpyxl", obj_type="module")
38+
39+
3640
def xlformat_factory(format):
3741
"""
3842
copy the format, perform any overrides, and attach an xlstyle instance

lib/mpl_toolkits/gtktools.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,15 @@
3939

4040
import copy
4141
import gtk, gobject
42-
import numpy as npy
42+
import numpy as np
4343
import matplotlib.cbook as cbook
44+
from matplotlib.cbook import warn_deprecated
4445
import matplotlib.mlab as mlab
4546

4647

48+
warn_deprecated("2.0", name="mpl_toolkits.gtktools", obj_type="module")
49+
50+
4751
def error_message(msg, parent=None, title=None):
4852
"""
4953
create an error message dialog with string msg. Optionally set
@@ -164,7 +168,7 @@ def __call__(self, column):
164168
val = model.get_value(thisiter, self.i)
165169
try: val = float(val.strip().rstrip('%'))
166170
except ValueError: pass
167-
if mlab.safe_isnan(val): val = npy.inf # force nan to sort uniquely
171+
if mlab.safe_isnan(val): val = np.inf # force nan to sort uniquely
168172
dsu.append((val, rownum))
169173
dsu.sort()
170174
if not self.num%2: dsu.reverse()
@@ -326,19 +330,15 @@ def rec2gtk(r, formatd=None, rownum=0, autowin=True):
326330
format = formatd.get(name)
327331
if format is None:
328332
format = mlab.defaultformatd.get(dt.type, mlab.FormatObj())
329-
#print 'gtk fmt factory', i, name, format, type(format)
330333
format = gtkformat_factory(format, i)
331334
formatd[name] = format
332335

333-
334336
colheaders = r.dtype.names
335337
scroll = SortedStringsScrolledWindow(colheaders, formatd)
336338

337-
ind = npy.arange(len(r.dtype.names))
338339
for row in r:
339340
scroll.add_row(row)
340341

341-
342342
if autowin:
343343
win = gtk.Window()
344344
win.set_default_size(800,600)
@@ -387,7 +387,7 @@ def __init__(self, r, formatd=None, stringd=None):
387387
formatd = mlab.get_formatd(r)
388388

389389
self.stringd = stringd
390-
self.callbacks = cbook.CallbackRegistry(['cell_changed'])
390+
self.callbacks = cbook.CallbackRegistry()
391391

392392
self.r = r
393393

@@ -586,9 +586,6 @@ def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
586586
if __name__=='__main__':
587587

588588
import datetime
589-
import gtk
590-
import numpy as np
591-
import matplotlib.mlab as mlab
592589
N = 10
593590
today = datetime.date.today()
594591
dates = [today+datetime.timedelta(days=i) for i in range(N)] # datetimes
@@ -599,7 +596,7 @@ def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
599596
clientid = list(xrange(N)) # ints
600597

601598
r = np.rec.fromarrays([clientid, dates, weekdays, gains, prices, up],
602-
names='clientid,date,weekdays,gains,prices,up')
599+
names=str('clientid,date,weekdays,gains,prices,up'))
603600

604601
# some custom formatters
605602
formatd = mlab.get_formatd(r)

0 commit comments

Comments
 (0)