Skip to content

Commit

Permalink
Merge pull request #6554 from anntzer/fix-gtktools
Browse files Browse the repository at this point in the history
MNT: Update mpl_toolkits.gtktools.
  • Loading branch information
tacaswell committed Jun 20, 2016
1 parent 16f6655 commit c1410f9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
4 changes: 4 additions & 0 deletions lib/mpl_toolkits/exceltools.py
Expand Up @@ -33,6 +33,10 @@
import matplotlib.mlab as mlab


cbook.warn_deprecated("2.0", name="mpl_toolkits.exceltools",
alternative="openpyxl", obj_type="module")


def xlformat_factory(format):
"""
copy the format, perform any overrides, and attach an xlstyle instance
Expand Down
19 changes: 8 additions & 11 deletions lib/mpl_toolkits/gtktools.py
Expand Up @@ -39,11 +39,15 @@

import copy
import gtk, gobject
import numpy as npy
import numpy as np
import matplotlib.cbook as cbook
from matplotlib.cbook import warn_deprecated
import matplotlib.mlab as mlab


warn_deprecated("2.0", name="mpl_toolkits.gtktools", obj_type="module")


def error_message(msg, parent=None, title=None):
"""
create an error message dialog with string msg. Optionally set
Expand Down Expand Up @@ -164,7 +168,7 @@ def __call__(self, column):
val = model.get_value(thisiter, self.i)
try: val = float(val.strip().rstrip('%'))
except ValueError: pass
if mlab.safe_isnan(val): val = npy.inf # force nan to sort uniquely
if mlab.safe_isnan(val): val = np.inf # force nan to sort uniquely
dsu.append((val, rownum))
dsu.sort()
if not self.num%2: dsu.reverse()
Expand Down Expand Up @@ -326,19 +330,15 @@ def rec2gtk(r, formatd=None, rownum=0, autowin=True):
format = formatd.get(name)
if format is None:
format = mlab.defaultformatd.get(dt.type, mlab.FormatObj())
#print 'gtk fmt factory', i, name, format, type(format)
format = gtkformat_factory(format, i)
formatd[name] = format


colheaders = r.dtype.names
scroll = SortedStringsScrolledWindow(colheaders, formatd)

ind = npy.arange(len(r.dtype.names))
for row in r:
scroll.add_row(row)


if autowin:
win = gtk.Window()
win.set_default_size(800,600)
Expand Down Expand Up @@ -387,7 +387,7 @@ def __init__(self, r, formatd=None, stringd=None):
formatd = mlab.get_formatd(r)

self.stringd = stringd
self.callbacks = cbook.CallbackRegistry(['cell_changed'])
self.callbacks = cbook.CallbackRegistry()

self.r = r

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

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

r = np.rec.fromarrays([clientid, dates, weekdays, gains, prices, up],
names='clientid,date,weekdays,gains,prices,up')
names=str('clientid,date,weekdays,gains,prices,up'))

# some custom formatters
formatd = mlab.get_formatd(r)
Expand Down

0 comments on commit c1410f9

Please sign in to comment.